diff --git a/README.md b/README.md index fbc37c4..435f6f3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Send voice notifications via SIP phone calls from Home Assistant. - 📞 Place SIP calls from automations - 🔊 Play audio from HTTP/HTTPS URLs (MP3, WAV, etc.) - 🗣️ Text-to-speech support -- ⚡ One-step installation (add-on includes integration) - 🔧 Configurable call duration ## Installation @@ -18,7 +17,7 @@ Settings → Add-ons → Add-on Store → ⋮ (menu) → Repositories Add URL: ``` -https://git.aymerick.fr/openclaw-bot/ha-sip-notifier +https://git.aymerick.fr/Aymerick/ha-sip-notifier ``` ### 2. Install the "SIP Voice Notifier" add-on @@ -46,9 +45,28 @@ default_duration: 30 ### 4. Start the add-on -Click Start. The service `sip_notifier.send_notification` will be automatically available! +Click Start. -### 5. Restart Home Assistant (if needed) +### 5. Add the service to Home Assistant + +**IMPORTANT:** Add this to your `/config/configuration.yaml`: + +```yaml +rest_command: + sip_notification: + url: "http://088d3b92-sip-notifier:8099/send_notification" + method: POST + content_type: "application/json" + payload: > + { + "destination": "{{ destination }}", + {% if audio_url is defined %}"audio_url": "{{ audio_url }}",{% endif %} + {% if message is defined %}"message": "{{ message }}",{% endif %} + "duration": {{ duration | default(30) }} + } +``` + +### 6. Restart Home Assistant Settings → System → Restart @@ -57,7 +75,7 @@ Settings → System → Restart ### Play Audio from URL ```yaml -service: sip_notifier.send_notification +service: rest_command.sip_notification data: destination: "+15551234567" audio_url: "https://example.com/alert.mp3" @@ -67,7 +85,7 @@ data: ### Text-to-Speech ```yaml -service: sip_notifier.send_notification +service: rest_command.sip_notification data: destination: "+15551234567" message: "Emergency! Water leak detected!" @@ -84,11 +102,49 @@ automation: entity_id: binary_sensor.water_leak to: "on" action: - service: sip_notifier.send_notification - data: - destination: "+15551234567" - message: "EMERGENCY! Water leak detected in basement!" - duration: 45 + - service: rest_command.sip_notification + data: + destination: "+15551234567" + message: "EMERGENCY! Water leak detected in basement!" + duration: 45 +``` + +## Optional: Friendlier Service Name + +Add a script to make it easier to use: + +```yaml +script: + sip_voice_notification: + alias: "Send Voice Notification" + fields: + destination: + description: "Phone number" + required: true + audio_url: + description: "Audio URL" + required: false + message: + description: "TTS message" + required: false + duration: + description: "Duration" + default: 30 + sequence: + - service: rest_command.sip_notification + data: + destination: "{{ destination }}" + audio_url: "{{ audio_url | default('') }}" + message: "{{ message | default('') }}" + duration: "{{ duration }}" +``` + +Then use: +```yaml +service: script.sip_voice_notification +data: + destination: "+15551234567" + message: "Test message" ``` ## SIP Providers @@ -101,13 +157,22 @@ automation: - Cost: ~$0.009/min - Canadian provider, good value -## Documentation +## Troubleshooting -Full documentation available in the add-on README. +### Service not found + +1. Check you added `rest_command` to configuration.yaml +2. Restart Home Assistant +3. Check for syntax errors in configuration.yaml + +### Call fails + +Check add-on logs: +Settings → Add-ons → SIP Voice Notifier → Log ## Support -Issues and questions: https://git.aymerick.fr/openclaw-bot/ha-sip-notifier/issues +Repository: https://git.aymerick.fr/Aymerick/ha-sip-notifier ## License diff --git a/SETUP_SERVICE.md b/SETUP_SERVICE.md new file mode 100644 index 0000000..f1fe174 --- /dev/null +++ b/SETUP_SERVICE.md @@ -0,0 +1,124 @@ +# Setting Up the sip_notifier Service + +The add-on is running, but you need to add the service to Home Assistant manually. + +## Add to your `configuration.yaml` + +Add this to `/config/configuration.yaml`: + +```yaml +rest_command: + sip_notification: + url: "http://088d3b92-sip-notifier:8099/send_notification" + method: POST + content_type: "application/json" + payload: > + { + "destination": "{{ destination }}", + {% if audio_url is defined %}"audio_url": "{{ audio_url }}",{% endif %} + {% if message is defined %}"message": "{{ message }}",{% endif %} + "duration": {{ duration | default(30) }} + } +``` + +## Restart Home Assistant + +Settings → System → Restart + +## Usage + +After restart, use the service: + +```yaml +service: rest_command.sip_notification +data: + destination: "+15551234567" + message: "Hello from Home Assistant!" + duration: 20 +``` + +Or with audio URL: + +```yaml +service: rest_command.sip_notification +data: + destination: "+15551234567" + audio_url: "https://example.com/alert.mp3" + duration: 30 +``` + +## Alternative: Create a Script + +If you prefer a more friendly name, add this to `configuration.yaml`: + +```yaml +script: + sip_voice_notification: + alias: "Send Voice Notification" + description: "Place a SIP call and play audio" + fields: + destination: + description: "Phone number (+15551234567)" + example: "+15551234567" + required: true + audio_url: + description: "HTTP(S) URL to audio file" + example: "https://example.com/alert.mp3" + required: false + message: + description: "Text message for TTS" + example: "Emergency alert" + required: false + duration: + description: "Call duration in seconds" + example: 30 + default: 30 + sequence: + - service: rest_command.sip_notification + data: + destination: "{{ destination }}" + audio_url: "{{ audio_url | default('') }}" + message: "{{ message | default('') }}" + duration: "{{ duration | default(30) }}" +``` + +Then use: + +```yaml +service: script.sip_voice_notification +data: + destination: "+15551234567" + message: "This is a test" +``` + +## Example Automation + +```yaml +automation: + - alias: "Water Leak Alert" + trigger: + platform: state + entity_id: binary_sensor.water_leak + to: "on" + action: + - service: rest_command.sip_notification + data: + destination: "+15551234567" + message: "EMERGENCY! Water leak detected!" + duration: 40 +``` + +## Troubleshooting + +### Service not found after restart + +1. Check configuration.yaml syntax +2. Check Home Assistant logs for errors +3. Verify add-on is running (Settings → Add-ons) + +### Call fails + +Check add-on logs: +Settings → Add-ons → SIP Voice Notifier → Log + +Look for SIP connection errors or audio conversion issues. diff --git a/sip-notifier/config.yaml b/sip-notifier/config.yaml index 94caddf..4a4b876 100644 --- a/sip-notifier/config.yaml +++ b/sip-notifier/config.yaml @@ -1,5 +1,5 @@ name: "SIP Voice Notifier" -version: "2.0.3" +version: "2.0.4" slug: "sip-notifier" description: "Send voice notifications via SIP phone calls (includes integration)" arch: diff --git a/sip-notifier/run.sh b/sip-notifier/run.sh index 63535d7..e5f0c14 100644 --- a/sip-notifier/run.sh +++ b/sip-notifier/run.sh @@ -12,5 +12,16 @@ 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 "" + # Start the service exec python3 /app/sip_service.py