I’m trying to make my Flic buttons (integrated as input boolean) behave like buttons not toggle switches. I have the following in my automation.yaml, but only the last entry actually behaves correctly.
Your indentation is out. Should look like this (first one only shown, rest should be the same):
- alias: "Flic2 singleclick act as button"
trigger:
- platform: state
entity_id: input_boolean.flic2_singleclick
action:
- service: >
{% if states.input_boolean.state == "off" %} !!!! THIS WON'T WORK
input_boolean.turn_on
{% else %}
input_boolean.turn_off
{% endif %}
data:
entity_id: input_boolean.flic2_singleclick
The - denotes the start of a list, then all the elements of that list need to be similarly indented — your alias, trigger and action.
Where there’s only one element to the list, as under your trigger and action, it’s not strictly necessary to include the -, but it’s a good habit to get into, so I’ve done it here. When you then add other triggers, it looks like this:
trigger:
- platform: state
entity_id: input_boolean.flic2_singleclick
- platform: time
at: "12:34:56"
In your original file, you created a trigger and action and then overwrote them twice, with the last one being the final version, because they weren’t part of the list under the alias due to the incorrect indentation.
I’ve also highlighted a broken line. You have different versions of the test in the three automations:
{% if states.input_boolean.state == "off" %}
{% if input_boolean.flic3_singleclick == "off" %}
{% if states.input_boolean.state == "off" %}
and none of these will work. If you’re looking at the flic3 entity, you want:
{% if states('input_boolean.flic3_singleclick') == 'off' %}