Hello,
I am just getting started with appdaemon and even python in general. I have been making progress over the last week but now I must ask for some advice.
I have a callback that should fire when a particular media_play
changes state to idle
.
self.advance_track = self.listen_state(self.next_track, "media_player."+self.media_player, new="idle", duration = "1")
In HA the media_player
is selected from input_select
.
self.media_player = self.get_state("input_select.gmusic_player")
How is the best way to change the value of my self.media_player
variable that trigger my callback?
Right now I am using a separate callback to cancel / recreate the self.advance_track
callback with the new value of self.media_player
.
self.listen_state(self.select_player, input_select.gmusic_player)
def select_player(self)
self.cancel_listen_state(self.advance_track)
self.media_player = self.get_state("input_select.gmusic_player")
self.advance_track = self.listen_state(self.next_track, "media_player."+self.media_player, new="idle", duration = "1"
This seems to work but Iām wondering if this is the best way to handle something like this.