Hi,
Is there a way to write a single automation to turn off any fan that has been running for over 8 hours.
I have fan’s all over the house but my kids refuse to turn them off.
I can write 11 separate automations but would love to simplify this in 1 automation.
Thank you!
tom_l
March 19, 2025, 3:01am
2
Just list he 11 fans in the trigger.
triggers:
- trigger: state
entity_id:
- fan.one
- fan.two
- fan.three
# ...
- fan.eleven
to: 'on'
for:
hours: 8
actions:
- action: fan.turn_off
target:
entity_id: "{{ trigger.to_state.entity_id }}"
Thank you so much for the quick responds.
I’m able to get all Fan’s in a trigger but how do I stop the Fan that was running for 8 hours without stopping any other Fan’s?
The automation does not accept:
target:
entity_id: “{{ trigger.to_state.entity_id }}”
Jorggs
(Jorggs)
March 19, 2025, 5:59am
4
I believe you want trigger.entity_id
Thanks Jorggs.
If I use:
action: fan.turn_off
metadata: {}
data: {}
target:
entity_id: trigger.entity_id
The Fan does not stop after the configured time.
Hellis81
(Hellis81)
March 19, 2025, 6:13am
6
Please post your yaml in a code block </>
.
Joggers was just meaning the inner part. So the correct should be
...
entity_id: "{{ trigger.entity_id }}"
1 Like
It works. Thank you both so much!
p.s. I will do my best to post code properly in the future.
1 Like
Jorggs
(Jorggs)
March 19, 2025, 9:31am
8
Glad you got it working, thank you @Hellis81 for clarifying my poor reply