Home Assistant SIP Gateway

Hi,

is it possible to send the caller number to a script action?

Something like this maybe:

action:
     domain: script
     service: turn_on
     entity_id: script.ha_sip_forward_call
     service_data:
         variables:
             message: "test"
             caller: "{{ caller }}"

Yes, this is available in the webhook callback with {{trigger.json.caller}}. See also GitHub - arnonym/ha-plugins: Home-Assistant SIP Gateway

Thank you for the quick reply.

Yes, that’s available if you trigger an automation with a webhook, but I would like to directly call a script in an action from an incoming call and give the caller number as a variable.

The dirty workaround would be to use a webhook in an automation and call the script from there, but I was hoping to call the script directly from my sip-1-inciming.yaml

I’m afraid it’s not possible to do that in the incoming-yaml file, as this is not parsed by home-assistant. If you don’t want to mix up incoming.yaml and webhooks you can do it like described in Generating dynamic Menus and messages on HA Entity State · Issue #86 · arnonym/ha-plugins · GitHub. That way you also don’t need to access the config directory to change your sip actions, but can do it directly from the home-assistant UI. Personally I don’t feel dirty doing it that way.

And you can even have different menus per caller, as you can use conditions to accept certain calls only.

That’s actually a good idea, but for some reason the jump command isn’t working there. The logs say:

| 20:26:46.660766 [ ] Webhook response 200 b''
| 20:26:46.664727 [1] Scheduled post action: jump
| 20:26:46.664788 [1] Could not find menu id: forward

This is my config, which was working fine in sip-1-incoming.yaml (except for the trigger parts):

service: hassio.addon_stdin
metadata: {}
data:
  addon: c7744bff_ha-sip
  input:
    command: answer
    number: "{{ trigger.json.parsed_caller }}"
    menu:
      message: >-
        Welcome message
      choices:
        "1":
          id: weiterleitung
          message: >-
            Ok, forward to who?
          choices:
            "1":
              id: call_a
              message: Ok, you will be connected to A
              post_action: jump forward
            "2":
              id: call_b
              message: Ok, you will be connected to B
              post_action: jump forward
            "999999999999999":
              id: forward
              message: Ok
              action:
                domain: script
                service: turn_on
                entity_id: script.ha_sip_forward_call
                service_data:
                  variables:
                    caller: "{{ trigger.json.parsed_caller }}"
                    message: Ok

The menu from the file and menu from stdin are handled exactly the same. At the beginning of every call ha-sip logs the parsed menu. Can you check if the choice is correctly parsed in the logs?

@j_d , @ Cao_Hoa , @Joerg

You asked for a stand-alone docker version. Fyi - with todays release it is possible.
You will need an Mqtt Broker like Mosquitto for the communcation. If that is set up - all you need to do is to create your own .env file with your connection details. Then you can do a docker compose up and post your commands as json to hasip/execute! Enjoy! :partying_face:

2 Likes

@Cao_Hoa see above. As a new member I can only mention two people in one post.

Thank you very much, it’s great to see your reply to create a version for using docker. I will use it for whatever purpose I will inform you. have a nice day

Thanks a lot, that’s awesome news!!

Now I have to spent some time to set it up and think of some useful automations :smile:

@arnonym I know I am a little bit late to the party, but I just wanted to say that this add-on is probably the absolute best thing I have ever added to my HA! I have a grandstream UCM IP PBX at home and this really ties everything together really splendidly. I’ve (so far) used the “Announcement Center” in the PBX to upload about 8 .wav files for things like doors being opened, motion detection, etc - and can now trigger them through automations using this add-on. The announcements play in perfect unison across all the IP phones. I’ve only just scratched the surface with what’s possible with this add-on but still wanted to say thanks!

2 Likes

hi, does TTS work for anyone with Piper?

Uhm…what about the error after the 2016.6 update?

Really awesome its working great for me. However I havent been able to get it working with piper TTS - has anyone else managed to do this?

Hi @arnonym , sorry to bother you with this. I’ve finally stumbled across your incredible work and I am a little stuck with a call menu. I’m trying to call into my Home Assistant, but the DTMF tones aren’t working. I have an option to hang-up if no menu option selected, so I know the menu is working. I’m unable to hear the tones when I call the system. I saw a previous post with a similar issue and changing the ‘method’, however this looked like it was for an outbound call. I’m using the HA-SIP service as an operator, that I can call inbound. Hope this makes sense. Thanks again for your amazing work on this.

I got HA-SIP connected to my 3CX portal. Incoming calls trigger the webhook but I would love to see the number on screen. It seems so simple no one mentioned it in the docs :slight_smile:
Even better if I can select the caller ID for two different screens (doorphone and landline)
Any example code available and where to place it?
I left the webhook option in the add-on standard and just trigger on the webhook now.

Can I somehow initiate a call to 2 phones (one internal, and one external) from HA? So make both phones ring, and after they both pick up, they can speak to each other?