Remove service auto-registration, add clear setup instructions (v2.0.8)

This commit is contained in:
2026-02-08 15:12:37 +01:00
parent 52adc9fdee
commit b081832eb7
3 changed files with 119 additions and 257 deletions

View File

@@ -24,44 +24,6 @@ app = Flask(__name__)
# Global config
CONFIG = {}
DEFAULT_SAMPLE_RATE = 8000
SUPERVISOR_TOKEN = os.environ.get('SUPERVISOR_TOKEN')
def register_service():
"""Register service with Home Assistant via Supervisor."""
if not SUPERVISOR_TOKEN:
_LOGGER.warning("No SUPERVISOR_TOKEN, skipping service registration")
return
try:
headers = {
'Authorization': f'Bearer {SUPERVISOR_TOKEN}',
'Content-Type': 'application/json',
}
# Register service via Supervisor API
response = requests.post(
'http://supervisor/services',
headers=headers,
json={
'domain': 'sip_notifier',
'service': 'send_notification',
'addon': '088d3b92_sip-notifier'
},
timeout=10
)
if response.status_code in [200, 201]:
_LOGGER.info("✅ Service registered: sip_notifier.send_notification")
return True
else:
_LOGGER.warning(f"Service registration status: {response.status_code}")
_LOGGER.debug(f"Response: {response.text}")
return False
except Exception as e:
_LOGGER.error(f"Failed to register service: {e}")
return False
def download_and_convert_audio(url: str) -> str:
@@ -265,16 +227,15 @@ if __name__ == '__main__':
'default_duration': int(os.getenv('DEFAULT_DURATION', 30))
}
# Register service with Home Assistant
_LOGGER.info("Registering service with Home Assistant...")
time.sleep(2) # Wait for supervisor to be ready
if register_service():
_LOGGER.info("Service registration successful")
else:
_LOGGER.warning("Service registration failed - will be available via REST API on port 8099")
_LOGGER.info("SIP Voice Notifier ready (using pyVoIP from git)")
_LOGGER.info("Service: sip_notifier.send_notification")
_LOGGER.info("=" * 60)
_LOGGER.info("SIP Voice Notifier Add-on Ready")
_LOGGER.info("=" * 60)
_LOGGER.info("Using pyVoIP from git (latest version)")
_LOGGER.info(f"SIP Server: {CONFIG.get('sip_server', 'not configured')}")
_LOGGER.info(f"SIP User: {CONFIG.get('sip_user', 'not configured')}")
_LOGGER.info("")
_LOGGER.info("To use this add-on, add configuration to configuration.yaml")
_LOGGER.info("See add-on README for details")
_LOGGER.info("=" * 60)
_LOGGER.info("Starting Flask service on port 8099")
app.run(host='0.0.0.0', port=8099, debug=False)