Home Assistant SIP Gateway

@arnonym
Is there a way to connect this extension to Voice over IP integration?
That I call the number I wrote in the extension and the voice assistant answers me?
Thank you

Hi Robert,

did not see your post, so sorry for the late answer. You don’t need to call the destination extension before transfering a call. Looks like you did everything right, to check what is going wrong I recommend checking the logs and post again, if you need help interpreting those.

Arne

Hi Meni,

I actually tried that with varying success, as the integration was not able to detect when the given command was completed (I guess silence detection is not working correctly), but that could also depend on the hardware you’re using.

To do this you will need to create an account without user/password like this:

enabled: true
registrar_uri: sip:<LAN IP address of your home assistant without the angle brackets>
id_uri: ""
realm: "*"
user_name: ""
password: ""
answer_mode: accept
settle_time: 1
incoming_call_file: ""

Also by default the sip integration is listening on the same port as ha-sip, so you need to change one of them. I changed the sip integration to port 5061 and ha-sip stayed on 5060.

After that you can dial

service: hassio.addon_stdin
data_template:
    addon: c7744bff_ha-sip
    input:
        command: dial
        number: sip:ha@<LAN IP address of your home assistant without the angle brackets>:5061
        webhook_to_call: 
            call_established: voice-assistant-connected

to connect to the voice assistant (probably you want to do this after a call_established web-hook is called on the incoming call from your sip phone, you need to use the global web-hook from the ha-sip configuration for this).

Finally you can connect both calls with

service: hassio.addon_stdin
data_template:
    addon: c7744bff_ha-sip
    input:
        command: bridge_audio
        number: sip:<id of your sip phone call>
        bridge_to: sip:<id of the sip integration/voice assistant call>

probably also on a web-hook callback (I already included this option on the call to the voice assistant: voice-assistant-connected). You can look up the ID’s in the ha-sip log ("Registering call with id ").

After writing that down (all from memory, I did that test over a month ago), that seems rather complex but I hope you get an idea how this is working.

Good luck and keep me informed :slight_smile:

Arne

1 Like

Thank you,
I’m checking it, so far I haven’t succeeded,
He connects to the voice assistant but there is no response,
I saw that Opus codecs need to be installed. Is it installed in your extension?
Thanks

Yes, the Opus codec is included. You can see the list of supported codecs in the logs when the plugin starts.

1 Like

I had the same issue after switching to a newer version of HA
After the update I got the error, that the base_url in my configurations.yaml is not accepted.
After deleting the base_url I got the same sound.

Anyway, I changed to Nabu Casa tts using:

platform: cloud
language: de-DE
service_name: cloud_say

Which works well.
At the beginning I had started with en-US and changed to de

Long story short:
de only creates a beep sound
de-DE works well.

I hope it helps (if not fixed already) - just wanted to share my findings…

1 Like

Bonjour,

J’ai ceci comme erreur.
Pourtant mon DNS est bon et je peux faire un ping avec linux.

Pouvez-vous m’aider svpl ?

16:54:16.327 pjsua_acc.c …Acc 0: Registration sent
16:54:17.326 pjsua_aud.c Closing sound device after idle for 1 second(s)
16:54:17.326 pjsua_aud.c .Closing null sound device…
16:54:18.327 resolver.c Re-transmitting 39 bytes to NS 0 (91.121.129.133:53): DNS SRV query for _sip._udp.sip5.ovh.be: Success
16:54:20.328 resolver.c Re-transmitting 39 bytes to NS 0 (91.121.129.133:53): DNS SRV query for _sip._udp.sip5.ovh.be: Success
16:54:22.328 resolver.c Re-transmitting 39 bytes to NS 0 (91.121.129.133:53): DNS SRV query for _sip._udp.sip5.ovh.be: Success
16:54:24.328 resolver.c Re-transmitting 39 bytes to NS 0 (91.121.129.133:53): DNS SRV query for _sip._udp.sip5.ovh.be: Success
16:54:26.328 _sip._udp.sip5.ovh.be DNS SRV resolution failed for _sip._udp.sip5.ovh.be: Operation timed out (PJ_ETIMEDOUT)
16:54:26.328 _sip._udp.sip5.ovh.be DNS SRV resolution failed for _sip._udp.sip5.ovh.be, trying resolving A/AAAA record for sip5.ovh.be
16:54:26.328 resolver.c Transmitting 29 bytes to NS 0 (91.121.129.133:53): DNS A query for sip5.ovh.be: Success
16:54:28.328 resolver.c Re-transmitting 29 bytes to NS 0 (91.121.129.133:53): DNS A query for sip5.ovh.be: Success
16:54:30.328 resolver.c Error transmitting request: No working DNS nameserver (PJLIB_UTIL_EDNSNOWORKINGNS)
16:54:30.328 _sip._udp.sip5.ovh.be DNS A record resolution failed: Operation timed out (PJ_ETIMEDOUT)
16:54:30.328 sip_resolve.c DNS A/AAAA record resolution failed: Operation timed out (PJ_ETIMEDOUT)
16:54:30.328 tsx0x7f98e7f8a548 Failed to send Request msg REGISTER/cseq=35437 (tdta0x7f98e7ee09a8)! err=70009 (Operation timed out (PJ_ETIMEDOUT))
16:54:30.328 pjsua_acc.c …SIP registration failed, status=503 (Operation timed out (PJ_ETIMEDOUT))
16:54:30.328 pjsua_acc.c …Scheduling re-registration retry for acc 0 in 1 seconds…
| 16:54:30.328787 [1] OnRegState: 503 Operation timed out (PJ_ETIMEDOUT)
16:54:32.050 pjsua_acc.c Contact for acc 0 updated: sip:[email protected]:5060;ob;+sip.ice
16:54:32.051 pjsua_acc.c Acc 0: setting registration…
16:54:32.052 sip_resolve.c …Failed to resolve ‘sip5.ovh.be’: No working DNS nameserver (PJLIB_UTIL_EDNSNOWORKINGNS)
16:54:32.052 tsx0x7f98e7f89c28 …Failed to send Request msg REGISTER/cseq=26423 (tdta0x7f98e7ede528)! err=320046 (No working DNS nameserver (PJLIB_UTIL_EDNSNOWORKINGNS))
16:54:32.052 pjsua_acc.c …SIP registration failed, status=503 (No working DNS nameserver (PJLIB_UTIL_EDNSNOWORKINGNS))
16:54:32.052 pjsua_acc.c …Scheduling re-registration retry for acc 0 in 307 seconds…
| 16:54:32.053340 [1] OnRegState: 503 No working DNS nameserver (PJLIB_UTIL_EDNSNOWORKINGNS)
16:54:32.053 sip_reg.c .Error sending request: No working DNS nameserver (PJLIB_UTIL_EDNSNOWORKINGNS)
16:54:32.053 pjsua_acc.c Scheduling re-registration retry for acc 0 in 296 seconds…

Hi Sacha,

your nameserver is probably fine, but the problem is that your SIP provider is using NAPTR records to let you resolve the SIP server which pjsip (the SIP library used by ha-sip) does not support currently.

See also Deutsche Telekom, SIP registration failed · Issue #30 · arnonym/ha-plugins · GitHub

Regards,
Arne

1 Like

Has the proxy option become available? I would like to use my FTTH provider SIP account. However, it is mandatory to use a proxy address/port for the SIP account to work. Thanks!

No, proxy is still not supported.

Ok. Thanks for your feedback. Is it planned to include such feature in the near future?

Probably not by me, as I don’t have a use for it. Pull requests are always welcome regardless.

hi @sgrayban I succeeded according to these instructions, :grinning:
it connects but disconnects quickly,
I get this error,
Would love your help

| 20:58:25.898045 [3] Connect audio stream of "sip:[email protected]:5062" and "0000000"
20:58:25.898            pjsua_aud.c !Conf connect: 5 --> 3
20:58:25.898           conference.c  .Port 5 (sip:[email protected]:5062) transmitting to port 3 (sip:[email protected])
20:58:25.898            pjsua_aud.c  Conf connect: 3 --> 5
20:58:25.898           conference.c  .Port 3 (sip:[email protected]) transmitting to port 5 (sip:[email protected]:5062)
| 20:58:25.898118 [3] Audio streams connected.
20:58:25.916     strm0x7fc7025d3b78 !Resetting jitter buffer in stream playback start
20:58:25.916     strm0x7fc7025d2728  Resetting jitter buffer in stream playback start
20:58:29.321     strm0x7fc7025d2728  Jitter buffer reset
20:58:33.887     strm0x7fc7025d2728  Jitter buffer reset
20:58:41.060     strm0x7fc7025d2728  Jitter buffer reset

Hi @ all,

I am using HA on a Pi4 and try to get an Automation running where a NFC Tag opens a door.
When I create an automation, I get the following error:

Triggered manually at 12. Oktober 2023 um 19:53:23
Aufruf eines Dienstes 'Home Assistant Supervisor: Daten in das Add-on stdin schreiben.' von
Stopped because an error was encountered at 12. Oktober 2023 um 19:53:23 (runtime: 0.01 seconds)

Not a valid add-on slug for dictionary value @ data['addon']

I was asking Google and found out, that there seems to be a Bug in HA with addon name like ha-sip (the - sign seems to be the issue).
As The Bug tracker mentioned that the Bug is fixed and I got the latest HA Version today, the problem still exist.
Does anyone encountered the same issue?

Hi @MWTeddy,

this should be fixed with the current version of home-assistant and ha-sip 3.1. The slug of ha-sip used in the stdin action is as follows:

service: hassio.addon_stdin
data:
    addon: c7744bff_ha-sip

Please re-check if everythings configured like mentioned!

Arne

1 Like

Hi @arnonym ,

thanks for replying.
This is what I try:

service: hassio.addon_stdin
data:
 addon: c7744bff_ha-sip
 input:
   command: dial
   number: sip:**[email protected]
   webhook_to_call_after_call_was_established: another_webhook_id
   webhook_to_call:
     call_established: another_webhook_id
     entered_menu: another_webhook_id
     dtmf_digit: another_webhook_id
     call_disconnected: another_webhook_id
   ring_timeout: 15
   sip_account: 1

All is up to date but still, I get the error.

@arnonym ,

I got it to work. The automation was not properly set.

Seems, it work like a charme for me.

1 Like

I am very interested in this topic and currently I am not succeeding in a working integration with SIP Intercom and DTMF interaction.

As a background, I have an outdoor Intercom which SIP call an interior tablet. After the call is established with a press of a button, I have a mapped button which sends a DTMF code for opening the door. I also have a button which disconnects the call.

Until now I only managed to get a call from the exterior post and fake a ringbell sound with a pop-up camera (with Browser Mode).

I am pretty new at SIP communications and don’t know exactly how I can integrate this in HA. I also don’t need the 2-way audio, I just need to receive the call and have 3 buttons mapped (1 - answer call, 2 - send DTMF for door opening, 3 - hang up the call) with the live video stream from the camera, which already works.

The help will be very much appreciated and may help others in the future.

Hi @arnonym
I just recently came across your addon, and now I can’t believe how my HA could do without this for all those years :sweat_smile: There is just one thing I wasn’t able to achieve so far:

I would like to be able to call my home assistant and then after some menu choices be transfered to another number. The transfer function works well if the initial call is an outgoing call from ha-sip, but if it is an incoming (external) call (mode: accept) I only get a warning in the logs:

[  ] Warning: call not in progress: sip:[email protected]

The reason for the warning is that incoming calls are not listet in the states “current_call_dict” and therefore not found by “is_active” which triggers the warning in command_handler.py:

case 'transfer':
    if not self.is_active(number):
        log(None, 'Warning: call not in progress: %s' % number)
        return
    current_call = self.get_call_from_state_unsafe(number)

Is there a way to achieve this anyway?

Hi @dongore,

it’s not that the call is not in current_call_dict, but its id is different to an outgoing call. Take a look in the log for “Registering call with id ‘number’” and use number printed there for the stdin action. I wanted to change that already, but left it like that for backwards-compatibility reasons.

Hope this helps,
Arne