Within automations.yaml I have placed this code:
- alias: Fan
trigger:
platform: state
entity_id: light.bathroom
to: 'off'
action:
service: switch.turn_on
entity_id: switch.sonoff218
When the state of the light in the batroom (Philips Hue) changes to OFF the fan (Sonoff) starts running. So far so good but I did not succeed adding a timer function so the fan stops after a certain time.
Can someone help me to add this timer function?