Home Assistant SIP Gateway

Home Assistant Core won’t work with this add-on, because it’s using the hassio.addon_stdin service to communicate with the add-on, which is not available without the hassio supervisor.

I created an IPPI account for testing and I was able to register the SIP client. Your config looks fine, but I had to use the special SIP password instead of the web password:

Did you try that?

yes, both are the same so i couldn’t mismatch.

Do you have any special characters like # in there? Please put the passwords in quotes like password: "xxxxxxxx".

i tried to quote the password as suggested
but i get an error too:

14:32:07.373    pjsua_acc.c  ....IP address change detected for account 0 (HAIP:5060 --> EXT_IP:5060). Updating registration (using method 4)
14:32:07.373    pjsua_acc.c  ....Contact for acc 0 updated: <sip:ebonnet@EXT_IP:5060;ob>;+sip.ice
14:32:07.373 sip_auth_clien  ...Unable to set auth for tdta0x16e143c: can not find credential for ippi.fr/Digest
14:32:07.373    pjsua_acc.c  ....SIP registration error: No suitable credential (PJSIP_ENOCREDENTIAL) [status=171101]
| 14:32:07.374149 [1] OnRegState: 401 Unauthorized
14:32:08.349    pjsua_aud.c  Closing sound device after idle for 1 second(s)
14:32:08.349    pjsua_aud.c  .Closing null sound device..

i think about one thing, as i have a livebox (which couldn’t be passthru) and all my network under a router, i have perhaps an issue with that ?
I tried to add a NAT from externel_IP:5060 to My_router_IP:5060 but couldn’t succeed because my livebox said this NAT it’s already used.
So could that be the problem ?

I don’t think so as this usually leads to more subtle problems like time-outs or interrupted calls. Here you’re getting a 401. Please try with realm set to “*” again.

ok thanks you

Thank you very much

here we area, seems to be OK

17:23:02.951   pjsua_core.c  .RX 525 bytes Response msg 200/REGISTER/cseq=17362 (rdata0xf0b274) from UDP 194.169.214.30:5060:
SIP/2.0 200 OK

Via: SIP/2.0/UDP EXT_IP:5060;received=EXT_IP;rport=5060;branch=z9hG4bKPj1oqIVO4v-XFQrDUukCgIHfr-OLi-rYGN

From: <sip:[email protected]>;tag=b4bnD0d7JWXZMDFCCIhOE3ED8jRdWjVD

To: <sip:[email protected]>;tag=de5ec607ac420ca7ba13a950717a2ed1.ab4c

Call-ID: L9pzSKKDhiDIDNqQyQfhftZQwOqhzIXl

CSeq: 17362 REGISTER

Contact: <sip:ebonnet@EXT_IP:5060;ob>;expires=300, <sip:ebonnet@EXT_IP:1024;ob>;expires=215

Server: OpenSIPS (1.8.2-tls (i386/linux))

Content-Length: 0



--end msg--
17:23:02.951    pjsua_acc.c  ....SIP outbound status for acc 0 is not active
17:23:02.951    pjsua_acc.c  ....sip:[email protected]: registration success, status=200 (OK), will re-register in 300 seconds
17:23:02.951    pjsua_acc.c  ....Keep-alive timer started for acc 0, destination:194.169.214.30:5060, interval:12s
| 17:23:02.951367 [1] OnRegState: 200 OK

So now what is the next step, the goal is to receive the call from my doorbell, when the ring button is pressed is ?

edit: i have this registration on IPPI

You can listen for the web-hook event incoming_call and answer the call like described in GitHub - arnonym/ha-plugins: Home-Assistant SIP Gateway

Please read the docs thoroughly and ask specific questions if you’re stuck.

i read the doc but i’m a little bit lost

  • i assume that i have to add a file in /config/sip-1-incoming.yaml ==> that name is open or do i have to register this name somewher ?
  • there is several ‘webhook’ discribed ==> where do i enter the ‘webhook’ in configuration.yaml in the new file created ?
  • if i want to answer to a call from my doorbell ==> what weebhook may i enter (i have created a SIP number in my doorbell 555555555)
  1. The name of that config file must match the name from the add-on config. If you use the config file approach for incoming calls you don’t need to configure a web-hook for the start.

  2. The web-hooks are used from triggers or actions in an automation.

  3. As stated above, if you’re using the incoming.yaml approach, you don’t need a web-hook for that.

Nonetheless, a sample automation that listens for the incoming_call event on a web-hook and sends a message with the calling number via telegram looks like that:

alias: "SIP: Incoming calls"
description: ""
trigger:
  - platform: webhook
    webhook_id: sip_call_webhook_id
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: |
              {{ trigger.json.event == "incoming_call" }}
        sequence:
          - service: notify.telegram_house_bot
            data:
              message: Got a call from {{trigger.json.caller}}
    default: []
mode: single

where do you add this sequence , in configuration.yaml or in configuration of the add-on ha-sip ?

The snippet is an automation in yaml format.

@arnonym I really enjoy your plugin,
I have a problem, I would appreciate your help.
that I activate a service, I can only activate the turn_off service in the light domain, and not the turn_on service (in the FAN domain I was able to activate both turn_off and turn_on)
Also another problem is that I run the unlock or lock service in the lock domain
I manage to run the service, but the extension crashes and needs to be restarted,
Would love your help

This is my code

menu:
    message: ABC
    choices_are_pin: true
    timeout: 20
    choices:
        '1234':
            id: success
            message: ABC
            timeout: 30
            choices:
                1:
                    message: "ABC"
                    action:
                        domain: light
                        service: turn_on
                        entity_id: light.yeelight_ceiling3_0x566b5a2
                    post_action: return
                2:
                    message: "ABC"
                    action:
                        domain: light
                        service: turn_off
                        entity_id: light.turn_off
                    post_action: return
        'default':
            id: wrong_code
            message: ABC
            post_action: return
        'timeout':
            message: ABC.
            post_action: hangup

Hi Meni,

can you please post the part of the log where the crash is happening? Keep in mind that you might need to remove personal information first.

Arne

This is the log before the crash,

| 10:30:32.515368 [1] onDtmfDigit: digit 2
| 10:30:32.515429 [ ] Calling webhook sip_call_webhook_id with data {'event': 'dtmf_digit', 'caller': '"+90000000" <sip:[email protected]>', 'parsed_caller': '+900000, 'digit': '2', 'sip_account': 1}
| 10:30:32.521800 [ ] Webhook response 200 b''
| 10:30:32.521860 [1] Current input: 2
| 10:30:32.521882 [1] Playing message: AAAA
10:30:33.009            pjsua_aud.c !Destroying player 0..
10:30:33.009            pjsua_aud.c  Creating file player: /tmp/tmpm4m1pqgw.wav..
10:30:33.009           wav_player.c  .File player '/tmp/tmpm4m1pqgw.wav' created: samp.rate=24000, ch=1, bufsize=4KB, filesize=44KB
10:30:33.009            pjsua_aud.c  .Player created, id=0, slot=2
10:30:33.009            pjsua_aud.c  Conf connect: 2 --> 1
10:30:33.009           conference.c  .Port 2 (/tmp/tmpm4m1pqgw.wav) transmitting to port 1 (sip:[email protected])
| 10:30:33.009393 [1] Calling home assistant service on domain lock service lock with entity lock.delet
/run.sh: line 36:   236 Segmentation fault      (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

@arnonym
I think I understood what the problem is, when there is an error and the operation cannot be performed, it crashes,
Perhaps it can be defined that instead of crashing, it will return a message that an error has occurred and it is unable to perform an operation,

Another question, is it possible to configure in the state of an incoming call that it will read a variable message from a template?

Hi @meni123,

I currently have no idea what’s causing the segmentation fault, I will look into that later.

On your question about using variables in the incoming call yaml: that’s not possible right now, but there is this work-around described here which you can use to accomplish the same: Things I have discovered · Issue #40 · arnonym/ha-plugins · GitHub

1 Like