I am making a simple automation where I can tell my kids how much time they have left to watch tv. I have loaded all their apps into a separate launcher which triggers the automation to begin when selected. Here is my code so far:
alias: Media Time Track
description: ""
trigger:
- platform: state
entity_id:
- media_player.shield_tv
attribute: source
to: dxidev.sideloadchannel3
condition: []
action:
- wait_template: >-
{{ states.media_player.shield_tv.attributes.source !=
'dxidev.sideloadchannel3' }}
continue_on_timeout: true
- wait_for_trigger:
- platform: state
entity_id:
- media_player.shield_tv
to: playing
- From here I want a timer to start a countdown for a set time, let’s say 2 hours, while the state is “playing”.
- Any time the state changes to something else (pause, idle, etc) before the timer is finished pause the timer.
- When the timer hits 30 minutes remaining send a notification that 30 minutes are left. When the timer is finished send a notification that time is up.
I thought of using an input boolean to turn on when the state is playing and off when that changes or a while loop until the timer is finished, but I can’t wrap my head around it. Any help would be appreciated, thanks.