BigFan
1
Hi All
I have now tried so many options… with no luck. Can someone please assist?
I want the switch to change state ONLY if it’s different
value = on or off
item = part of input_boolean name
I keep on getting errors when I do a Configuration check.
- alias: Receive Message
trigger:
- platform: webhook
webhook_id: !secret the_key
condition: template
value_template: >
{{ input_boolean.alarm_{{ trigger.json.item }}.state != {{ trigger.json.value }} }}
action:
service: >
input_boolean.turn_{{ trigger.json.value }}
data:
entity_id: >
input_boolean.alarm_{{ trigger.json.item }}
Thank you
finity
2
You didn’t say what the error was so I’m making an assumption (but an educated one)
try this:
value_template: >
{% set item = trigger.json.item %}
{{ states.input_boolean.alarm_~item~.state != trigger.json.value }}
I’m not sure it will work but I think it should.
BigFan
3
Thank you finity
It still does not work. The error message is still:
Invalid config for [automation]: Expected a dictionary @ data[‘condition’][0]. Got None extra keys not allowed @ data[‘value_template’]. Got None.
finity
4
That helped. Your indentation is off and missing some stuff
try this:
- alias: Receive Message
trigger:
- platform: webhook
webhook_id: !secret the_key
condition:
condition: template
value_template: >
{% set item = trigger.json.item %}
{{ states.input_boolean.alarm_~item~.state != trigger.json.value }}
action:
service: >
input_boolean.turn_{{ trigger.json.value }}
data:
entity_id: >
input_boolean.alarm_{{ trigger.json.item }}
BigFan
5
Thank you, but now I get this error:
Invalid config for [automation]: invalid template (TemplateSyntaxError: unexpected ‘.’) for dictionary value @ data[‘condition’][0][‘value_template’]. Got None.
BigFan
6
Hi finity
value_template: >
{% set itm = trigger.json.item %}
{{ states("input_boolean.alarm_" + itm +".state") != trigger.json.value }}
Gives no errors - Now I just have to check if it actually works