Hi all.
I have this two automations to turn on a suction fan when i turn on the bathroom light and keep it on for x minutes after the switch-off of the lamp.
- id: '1657758456346'
alias: Accensione Ventola Bagno con Luce
trigger:
- entity_id: switch.light
platform: state
from: "off"
to: "on"
condition: []
action:
- service: switch.turn_on
entity_id: switch.fan
- id: '1612488456346'
alias: Spegnimento ritardato Ventola Bagno
trigger:
- entity_id: switch.light
platform: state
from: "on"
to: "off"
condition: []
action:
- delay: 00:05:00
- service: switch.turn_off
entity_id: switch.fan
If i turn on the light, the fan start and when i turn off the light the fan stay on for 5 minutes. OK
The problem occurs when, after turning off the light, i switch it on and then off a second time: the fan stops instead of being switched on.
In that case it would reset automatically if you switch on the light again before the 5 minutes end. It will only turn off the fan if the light has been off for 5 consecutive minutes.
Yes you shouldnt start the script when turning on the lamp. If you use the script from petro you need to stop it in the automation turning the light on. And start it in the automation turning the light off.
However, give my automation a try with the trigger state for 5 minutes. This works like a charm for me in several different automations.