I have an automation which turns off the Smart Plug powering my AV system at a specific time unless it is being used. It detects if my Apple TV status is not ‘playing’ as one of the conditions:
- condition: not
conditions:
- condition: state
entity_id: media_player.living_room_appletv
state: playing
If it doesn’t run because it fails to meet this condition, I’d like it to try again every 15 minutes.
Is there a reason you can’t add a second trigger for the media player state changing from playing? That is generally the preferred method rather than using continuous polling.
I don’t want the power to be turned off if I press pause for a few minutes. I guess what I am trying to acheive is:
If the time is after 11pm
and the Apple TV has not been in the “playing” state for 10 minutes
then turn off the smart plug.
It’s the after 11pm bit I don’t know how to achieve. Also, if I wanted the time to be after midnight, then I would want the rule to only trigger between say 1am and 5am to avoid things getting turned off during a long pause during daytime.
trigger:
- platform: time
at: " 23:00:00" (or Whatever your specific time is)
- platform: state
entity_id: media_player.living_room_appletv
from: playing
for: "00:10:00"
condition:
- condition: time
after: "23:00:00"
before: "05:00:00"
- condition: not
conditions:
- condition: state
entity_id: media_player.living_room_appletv
state: playing