Auto-register service via Supervisor API on startup (v2.0.5)
This commit is contained in:
@@ -12,16 +12,29 @@ bashio::log.info "SIP Server: ${SIP_SERVER}"
|
||||
bashio::log.info "SIP User: ${SIP_USER}"
|
||||
bashio::log.info "Default Duration: ${DEFAULT_DURATION}s"
|
||||
|
||||
bashio::log.info "Add-on ready - listening on port 8099"
|
||||
bashio::log.info "To use from Home Assistant, add this to your configuration.yaml:"
|
||||
bashio::log.info ""
|
||||
bashio::log.info "rest_command:"
|
||||
bashio::log.info " sip_notification:"
|
||||
bashio::log.info " url: http://088d3b92-sip-notifier:8099/send_notification"
|
||||
bashio::log.info " method: POST"
|
||||
bashio::log.info " content_type: application/json"
|
||||
bashio::log.info " payload: '{\"destination\": \"{{ destination }}\", \"message\": \"{{ message }}\", \"duration\": {{ duration | default(30) }}}'"
|
||||
bashio::log.info ""
|
||||
# Wait for supervisor to be ready
|
||||
sleep 3
|
||||
|
||||
# Start the service
|
||||
# Register service with Home Assistant via Supervisor API
|
||||
bashio::log.info "Registering sip_notifier.send_notification service with Home Assistant..."
|
||||
|
||||
# Get add-on slug
|
||||
ADDON_SLUG="088d3b92_sip-notifier"
|
||||
|
||||
# Register the service
|
||||
curl -sSL -X POST \
|
||||
-H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"addon\": \"${ADDON_SLUG}\",
|
||||
\"service\": \"send_notification\"
|
||||
}" \
|
||||
"http://supervisor/services/sip_notifier/send_notification" \
|
||||
&& bashio::log.info "Service registered successfully!" \
|
||||
|| bashio::log.warning "Service registration failed (may already exist)"
|
||||
|
||||
bashio::log.info "Add-on ready - listening on port 8099"
|
||||
bashio::log.info "Service available as: sip_notifier.send_notification"
|
||||
|
||||
# Start the Flask service
|
||||
exec python3 /app/sip_service.py
|
||||
|
||||
Reference in New Issue
Block a user