Afternoon All
As you may have noticed from recent posts I’m spending some time on my automations.
I’m trying to do some housing keeping and reduce text where possible.
At the moment I have two automations linked to an input boolean (for a fan). One for on and one for off.
I’m trying to join these but I’m having an issue:
- alias: "ib_Bed Fan (smart)"
id: '90000000000123'
trigger:
platform: state
entity_id: input_boolean.bed_fan
action:
- service_template: >
{% if is_state('input_boolean.bed_fan', 'off') %}
switch.turn_off
{% else %}
switch.turn_on
{% endif %}
entity_id: switch.plug_005b
- delay: '00:30:00'
- service: switch.turn_off
entity_id: switch.plug_005b
What I’m trying to achieve is when I turn on the input boolean to turn on the fan for 30 minutes then off. When I turn off the input boolean turn off the fan (and as it doesn’t matter, turns it “off” again 30 minutes later, leave that in so I can group them together rather than have 2 automations as I do now).
If I don’t add the extra actions (ie delay and switch turn off) it works great:
- alias: "ib_Bed Fan (smart)"
id: '90000000000123'
trigger:
platform: state
entity_id: input_boolean.bed_fan
action:
service_template: >
{% if is_state('input_boolean.bed_fan', 'off') %}
switch.turn_off
{% else %}
switch.turn_on
{% endif %}
entity_id: switch.plug_005b