I’m using this automation to turn off the Air Purifier when I open the window and turn back on when I close it. But it’s triggering even when the window is closed all the time.
alias: Air Purifier - Turn On/Off when the Window is closed/open for 30s
mode: single
trigger:
- platform: state
entity_id: binary_sensor.livingroom_window
for: '00:00:30'
condition: []
action:
- entity_id: fan.air_purifier
data: {}
service: >-
{% if is_state('binary_sensor.livingroom_window', 'on') %}
fan.turn_off
{% elif is_state('binary_sensor.livingroom_window', 'off') %}
fan.turn_on
{% endif %}