Home Assistant SIP Gateway

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

Wow, thank your for the lightning fast reply! It’s working now.
The id ist just the incoming phone number without the sip: prefix. I tried this before, but the clue was to put it in quotes, because without them it would cut of the leading zero.

Thank you!

1 Like

Hi there,
Great plugin - I try to open my door using it… But I am struggling with the TTS options:
I Installed HA and I am using the marytts speech synthesizer.
When I make an outgoing call to my PBX there is either silence or, if I press a random button on the phone connected to the call, a beep occurs.
I seems the langugage is wrong.
in the HA log an error message is printed:

“2023-12-05 19:24:06.733 ERROR (MainThread) [homeassistant.components.http.view] Unable to serialize to JSON. Bad data found at $.error=Language ‘en’ not supported(<class ‘homeassistant.exceptions.HomeAssistantError’>”

I checked the supported languages:

“The value ‘en’ of parameter ‘locale’ is not valid: The locale is not supported.
Supported locales: de,en_GB,en_US,fr,it,lb,ru,sv,te,tr.”

so I tried to set the language to en_US or de
But the error from the HA log stays the same, whatever language I set in the preferences of the Plugin, the TTS settings in HA or the congfiguration.yaml of HA, or direclty in the code of a sample automation.

Any clue what I could do to make this work?
Thank you.

I made a little Progress:
I did reset every settings I found, and now the langugate is set to “en” or “en_US” - The error message about the wrong language is gone.
I dont understand why at some locations “en” is the correct language and somewhere else “en_US” is correct, but this does of course not matter.

Now, when I make a call (without an error appearing the logs), there is still no message spoken by the TTS and the call is hung up nearly immediately.
After this the HA-SIP service unregisters itself from the PBX and stops.

Could this be a NAT problem? HA is running inside a NAT environment (VM with docker). SIP needs port 5060 for signalling which normally is not a problem with NAT, but SIP also needs RTP port to be open to send and receive audio.
Are the any additional tasks I need to do to configure NAT to forward udp ports needed for RTP to HA?

I’m trying to do this too, or similar…
I have 2 phones connected to a 2port grandstream and both autodial into ha-sip when hook off, so with a menu i would like phone1 to call phone2…
like, “Press phone to call” …press 2 and phone 2 rings and when you answer, you talk to phone 1…
Do you have some hints on how to configure this, or if you can share your config ?

unless i’m missing something, but how is a call ‘kept’ online when calling ha-sip ?

so i’m doing : (from dev tools, services)

service: hassio.addon_stdin
data:
  addon: c7744bff_ha-sip
  input:
    command: dial
    number: sip:[email protected]:5060

this is a phone connected to a Grandsteam HT802 (2 phone ports)
Phone rings and I can pick up, but I cant get to bridge those two phones from an home assistant automation…

But if I pick up both phones and manually brigde them, it works…like this

service: hassio.addon_stdin
data:
  addon: c7744bff_ha-sip
  input:
    command: bridge_audio
    number: port_02
    bridge_to: port_01

I hear the echo kick in instantly and they are bridged…

When trying to brigde from automation, it says “Warning: call not in progress: port_01” but i’ve picked up the phone…

nervermind, it all works now :slight_smile:

both phones autodials into ha-sip and with a menu, phone1 can call phone 2 and vice versa.
ha-sip is doing all the dialing, and when pick up, a webhook automation is run and bridge the calls.

BUT…

is it possible to fix watchdog, so it detects if the addon have crashed ?

Assertion failed: a->addr.sa_family == PJ_AF_INET || a->addr.sa_family == PJ_AF_INET6 (../src/pj/sock_common.c: pj_sockaddr_get_len: 392)
Fatal Python error: Aborted

Current thread 0x00007f13307a8b48 (most recent call first):
  File "/root/.local/lib/python3.11/site-packages/pjsua2-2.14-py3.11-linux-x86_64.egg/pjsua2.py", line 6468 in libHandleEvents
  File "/ha-sip/main.py", line 105 in main
  File "/ha-sip/main.py", line 113 in <module>

Extension modules: yaml._yaml, _pjsua2, charset_normalizer.md (total: 3)
/run.sh: line 46:   258 Aborted                 (core dumped) python3 /ha-sip/main.py
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

after this ha-sip is not responding, but the green light is on and its not restarted…