Home Assistant SIP Gateway

Hi Gerwazy,

yes, that should work. I do it like this:

service: hassio.addon_stdin
data_template:
    addon: c7744bff_ha-sip
    input:
        command: hangup
        number: sip:**[email protected]

As the number you need to specify the same string you used for the dial command. If this is not working please set the log level in the add-ons configuration to 2 and post the log here where you tried to hang-up the call.

1 Like

I did in the same way. The trick was to wait 5 seconds after trigger :slight_smile:

      - delay:
          hours: 0
          minutes: 0
          seconds: 5
          milliseconds: 0
      - service: hassio.addon_stdin
        data:
          addon: c7744bff_ha-sip
          input:
            command: hangup
            number: "{{ trigger.json.parsed_caller }}"
1 Like

@arnonym
Hi Arne,

I have tried multiple times but I cant find a way to create a sub menu using the config file. I have users authenticate with pin after the welcome message and this works but is there a way to give them a menu after the ‘PIN menu’? (a sub menu of sorts) so I could, say, press 1 to unlock door etc… but AFTER the first menu where I ask for pin

I hope this was clear enough for you to understand.

Thanks

Hi Tristan,

that’s exactly what I’m doing with my setup. The config file looks like this:

allowed_numbers:
    - "5551234"
menu:
    message: Please enter your access code
    choices_are_pin: true
    timeout: 20
    choices:
        '1234':
            id: success
            message: Welcome. Please press 1, 2 or 3
            language: en
            timeout: 30
            choices:
                1:
                    message: "Door has been opened"
                    action:
                        domain: switch
                        service: turn_on
                        entity_id: switch.main_door
                    post_action: return
                2:
                    message: "Garage has been opened"
                    action:
                        domain: cover
                        service: open_cover
                        entity_id: cover.garage
                    post_action: return
                3:
                    message: "Garage has been closed"
                    action:
                        domain: cover
                        service: close_cover
                        entity_id: cover.garage
                    post_action: return
        'default':
            id: wrong_code
            message: Wrong code, please try again
            post_action: return
        'timeout':
            message: Bye.
            post_action: hangup

Hope this is helpful!

1 Like

I finished my voicemail system based on HA-sip

to give info to callers when i cant pickup the phone.

https://github.com/…asterisk-homeassistant-tools

Thanks much for this add-on. I am using it to make emergency calls. I tell my Google Assistant “I need help”, which triggers a HASS script to call my children and play a message.

Three things:

  1. It took a while but I figured out how to use Nabu Casa’s TTS. The configuration in the tts: section of ha-sip is
platform: cloud
language: en-US
service_name: cloud_say

I very much prefer the voices offered by Nabu Casa.

  1. It works fine with sipgate.co.uk.

  2. Question: iIs there a way to make it repeat the message until the other side hangs up?

In case it helps someone, here is the script:

alias: Call phone for help
description: Call a phone number for help
sequence:
  - service: hassio.addon_stdin
    data:
      addon: c7744bff_ha-sip
      input:
        command: dial
        number: sip:{{ number }}@sipgate.co.uk
        ring_timeout: 30
        sip_account: 1
        menu:
          message: >-
            Your message here. Repeat:
            Your message here.
          post_action: hangup
mode: single
max: 10

Thanks again.

Hi @cbhaley,

thanks for the input on how to use Nabu Casa’s TTS and the feedback on your SIP provider!

There was no way to repeat the message, but now there is in version 2.5.

You can specify repeat_message as your post_action and it will re-read it until the timeout is reached. So if you are fine with 5 minutes of repeating you can leave the default time-out, or change it to fit your use-case. The new post_action is also described in the docs.

Regards,
Arne

Thanks much! It works well.

Here is the script:

service: hassio.addon_stdin
data:
  addon: c7744bff_ha-sip
  input:
    command: dial
    number: sip:{{ number }}@sipgate.co.uk
    ring_timeout: 30
    sip_account: 1
    menu:
      timeout: 20
      message: >-
        This is the repeating message.
      post_action: repeat_message
1 Like

Hi,

Thanks for your job with this add on :grin:

Im trying to have a script wich will do those actions:

  • Call a number when a webhook is received
  • during this call wait xx second and send dtmf: “2222#” closed the call
  • Then 20 sc later call back again the same phone wait xx second send dtmf “2222#”
  • Then wait xx second and send dtmf “APHONENUMBER#”
  • Wait again xx second and send new dtmf: “0”
  • Close the call few second later.

Thanks for your help

At this time im juste able to send an outgoing call with a TTS message in loop but that’s not my aim.

Hi,

you’ll find the docs to the add-on at GitHub - arnonym/ha-plugins: Home-Assistant SIP Gateway.

The wait between actions you can do with a built-in action.

If you have questions about the docs or some details don’t hesitate to ask!

Regards,
Arne

Hi Arne,

I recently switched from “DSS VoIP Notifier” to your addon. It works with the Nabucasa TTS and doesn‘t start to play the message immediately, regardless of the other site takes the call or not, which is the most important feature for me.

Actually I just want to say: thank you for your hard and excellent work.

I hope you keep maintaining the addon.

You should really offer a donate option🙂

Best

Eric

hello, i just begin with SIP, so i’m noob even with the parameter.
So start with your add-on i need some help to understand what i need to change in the config to match the SIP account i have with IPPI

  • where do i enter
    id ?
    domain ?
    proxy ?
    password ?
    sip number ?

i see that all info are SIP:xxxx
may i have to enter SIP:my_info or just my_info ?

the goal of the SIP is to get some incoming call from my Doorbird doorstation when the ring is pressed and people speak.

thank you for your help and i apologize for basic asking

Hi Berno,

please try it with these settings:

registrar_uri: "sip:domain"
id_uri: "sip:sip_number@domain"
realm: "*"
user_name: "id"
password: "password"

Currently a proxy setting is not supported, as most people use some kind of local SIP server. But it might work without also.

Regards,
Arne

ok added that in my config, start the addon and get a long journal
do you want i post this journal ? to see if there is problem ?
now how could i test the right function ?

the goal of the SIP is to get some incoming call from my Doorbird doorstation when the ring is pressed and people speak.

can you switch to docker compose?

If there is lots of logging it’s mostly because the authentication did not work. You could try sip_number for user_name, or sip:id@domin for the id_uri. I don’t have an IPPI account, so I can’t help with that.

home assistant is using docker for add-ons, so no.

I am using home-assistant /core runs in docker compose

no i’m with HAOS

i tried this parameter

enabled: true
registrar_uri: sip:sip.ippi.com
id_uri: sip:[email protected]
realm: sip.ippi.com
user_name:ebonnet
password: xxxxxxxx
answer_mode: listen
settle_time: 1
incoming_call_file: ""

with these info from IPPI

sip flag SIP	ebonnet
sip flag SIP	8xx 7xx 975

Identifiant SIP	ebonnet
Mot de passe	•••••••
Domaine/Realm	sip.ippi.com
Proxy & Registrar SIP	sip.ippi.com

and i got this log

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Python 3.9.2
| 10:48:27.781087 [1] No file name for incoming call config specified.
| 10:48:27.781453 [2] No file name for incoming call config specified.
10:48:27.784 os_core_unix.c !pjlib 2.13 for POSIX initialized
10:48:27.787 sip_endpoint.c  .Creating endpoint instance...
10:48:27.788          pjlib  .select() I/O Queue created (0x12ecf50)
10:48:27.788 sip_endpoint.c  .Module "mod-msg-print" registered
10:48:27.788 sip_transport.  .Transport manager created.
10:48:27.788   pjsua_core.c  .PJSUA state changed: NULL --> CREATED
10:48:27.788 sip_endpoint.c  .Module "mod-pjsua-log" registered
10:48:27.788 sip_endpoint.c  .Module "mod-tsx-layer" registered
10:48:27.788 sip_endpoint.c  .Module "mod-stateful-util" registered
10:48:27.789 sip_endpoint.c  .Module "mod-ua" registered
10:48:27.789 sip_endpoint.c  .Module "mod-100rel" registered
10:48:27.789 sip_endpoint.c  .Module "mod-pjsua" registered
10:48:27.789 sip_endpoint.c  .Module "mod-invite" registered
10:48:27.789          pjlib  ..select() I/O Queue created (0x12be804)
10:48:27.794 sip_endpoint.c  .Module "mod-evsub" registered
10:48:27.794 sip_endpoint.c  .Module "mod-presence" registered
10:48:27.794 sip_endpoint.c  .Module "mod-mwi" registered
10:48:27.794 sip_endpoint.c  .Module "mod-refer" registered
10:48:27.794 sip_endpoint.c  .Module "mod-pjsua-pres" registered
10:48:27.794 sip_endpoint.c  .Module "mod-pjsua-im" registered
10:48:27.795 sip_endpoint.c  .Module "mod-pjsua-options" registered
10:48:27.795   pjsua_core.c  .No SIP worker threads created
10:48:27.795   pjsua_core.c  .pjsua version 2.13 for Linux-5.15.84/armv7l/glibc-2.31 initialized
10:48:27.795   pjsua_core.c  .PJSUA state changed: CREATED --> INIT
10:48:27.795    pjsua_aud.c  Setting null sound device..
10:48:27.795    pjsua_aud.c  .Opening null sound device..
10:48:27.797   pjsua_core.c  SIP UDP socket reachable at HAIP:5060
10:48:27.797   udp0x1303c40  SIP UDP transport started, published address is HAIP:5060
10:48:27.797   pjsua_core.c  PJSUA state changed: INIT --> STARTING
10:48:27.797 sip_endpoint.c  .Module "mod-unsolicited-mwi" registered
10:48:27.797   pjsua_core.c  .PJSUA state changed: STARTING --> RUNNING
10:48:27.798    pjsua_acc.c  Adding account: id=sip:[email protected]
10:48:27.798    pjsua_acc.c  .Account sip:[email protected] added with id 0
10:48:27.798    pjsua_acc.c  .Acc 0: setting registration..
10:48:27.798    pjsua_acc.c  ..Contact for acc 0 updated: <sip:ebonnet@HAIP:5060;ob>;+sip.ice
10:48:27.809   pjsua_core.c  ...TX 500 bytes Request msg REGISTER/cseq=27807 (tdta0x130843c) to UDP 194.169.214.30:5060:
REGISTER sip:sip.ippi.com SIP/2.0

Via: SIP/2.0/UDP 192.168.0.56:5060;rport;branch=z9hG4bKPjMcQ26tbwucRQX0qvufP8VTTEjihLdMEw

Max-Forwards: 70

From: <sip:[email protected]>;tag=Zm3y6uVCOV4P3eoLcIjhvhGl73j8cDI9
To: <sip:[email protected]>
Call-ID: vmG8xeUQOVeLvHUKK7iXDrMTFJDVZA6p
CSeq: 27807 REGISTER
Contact: <sip:ebonnet@IP_HA:5060;ob>;+sip.ice
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0
--end msg-
10:48:27.809    pjsua_acc.c  ..Acc 0: Registration sent
10:48:27.833   pjsua_core.c  .RX 513 bytes Response msg 401/REGISTER/cseq=27807 (rdata0x1305274) from UDP 194.169.214.30:5060:
SIP/2.0 401 Unauthorized

Via: SIP/2.0/UDP 192.168.0.56:5060;received=EXT_IP;rport=5060;branch=z9hG4bKPjMcQ26tbwucRQX0qvufP8VTTEjihLdMEw

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

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

Call-ID: vmG8xeUQOVeLvHUKK7iXDrMTFJDVZA6p

CSeq: 27807 REGISTER

WWW-Authenticate: Digest realm="ippi.fr", nonce="6435200739f335d1ca988a36f4dbd4041e5d4794"

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

Content-Length: 0



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

where
HAIP = ip of my HA
EXT_IP = external IP of my provider connexion