We have a challenge that our kids sometimes turn the TV on, but then just walks away leaving it on until an adult turns it off again.
We only use our TV with a Chromecast, so I would like to let the TV run in 15 minutes, then check if the Chromecast is playing, and if not turn the TV off.
I tried to make an app like below, but that doesn’t turn the TV off? I suppose it is the run_in() it is wrong?
import appdaemon.plugins.hass.hassapi as hass
class tv_off(hass.Hass):
def initialize(self):
self.listen_state(self.tv,"media_player.ps59d7000_ps59d7000", new="on")
def tv (self, entity, attribute, old, new, kwargs):
if self.run_in("media_player.ps59d7000_ps59d7000",900) == "on" and self.get_state("media_player.stue") == "off" :
self.turn_off("media_player.ps59d7000_ps59d7000")