BigFan
February 16, 2021, 9:24am
1
Hi all
I keep getting and error message in the File Editor (automations.yaml)
missed comma between flow collection entries at line 36, column 8:
{% if is_state("trigger.json.valu …
^
- alias: Receive Message
trigger:
- platform: webhook
webhook_id: alarm_status
action:
{% if is_state("trigger.json.value_id", "on") %}
service: input_boolean.turn_on
entity_id: input_boolean.alarm_status
{% elif is_state("trigger.json.value_id", "off") %}
service: input_boolean.turn_off
entity_id: input_boolean.alarm_status
{% endif %}
Any help would be appreciated. Thanks
tom_l
February 16, 2021, 10:52am
2
key: value
You can template a value. You can’t template a key. You have both in your templates.
Also your indentation of alias:
does not match the rest of your automation. But I’ll assume that is a copy/paste error.
action:
service: >
{% if is_state("trigger.json.value_id", "on") %}
input_boolean.turn_on
{% elif is_state("trigger.json.value_id", "off") %}
input_boolean.turn_off
{% endif %}
entity_id: input_boolean.alarm_status
If the trigger.jason.value_id can be anything other than on or off you need an else case too. If it can only be on or off you could simplify the template to:
action:
service: "input_boolean.turn_{{ state('trigger.json.value_id') }}"
entity_id: input_boolean.alarm_status
1 Like
Try this:
- alias: Receive Message
trigger:
- platform: webhook
webhook_id: alarm_status
action:
service: >
input_boolean.turn_{{ trigger.json.value_id }}
entity_id: input_boolean.alarm_status
2 Likes
BigFan
February 16, 2021, 11:12am
4
Thanks tom_I
Unfortunately, I could not get your suggestions to work - nevertheless I’m very new to HA and learned a lot from your response. I bet you it’s maybe the way I entered it. I tried Burningstone’s solution below and it worked.
Thanks again!
tom_l
February 16, 2021, 11:33am
6
Yeah I stuffed it up, I should have written:
service: "input_boolean.turn_{{ trigger.json.value_id }}"
2 Likes