Closed LukasGrebe closed 5 months ago
You can use the normal home assistant templating features if you're getting called from home assistant and define your menu in the action or if you act on the web-hook for incoming calls and accept the call from there. But you can only get the state from moment you accepted the call. If this was changed in the call or from outside, there's no way to get the current state.
Could you provide an example where I call into ha-sip (ha-sip accepts the incoming call) and will then tell me a status of an entity? I'm not sure how a webhook could respond to ha-sip.
First you need to set answer_mode: listen
on your SIP account in the ha-sip config and set a webhook name.
Then you can create an automation acting on the webhook:
alias: Accept incoming call
description: ""
trigger:
- platform: webhook
allowed_methods:
- POST
local_only: true
webhook_id: sip_call_webhook_id
condition:
- condition: template
value_template: "{{ trigger.json.parsed_caller==\"0234123456\" }}"
action:
- service: hassio.addon_stdin
data:
addon: c7744bff_ha-sip
input:
command: answer
number: "0234123456"
menu:
message: |
{% if is_state('light.livingroom', 'on') %}
The light is on.
{% else %}
The light is off.
{% endif %}
post_action: hangup
mode: single
You need to change the webhook_id
to match your ha-sip config. Also you need to replace the phone number to the phone you're calling from. If you're unsure what the parsed number is, you can call and take a look in the log of ha-sip.
That's awesome! Thanks!
I couldn't find this in the doc - is there any way to use the template engine for messages or in other ways act upon entity states?
eg creating a light on-off menu: