bmcgair
(Bmcgair)
September 4, 2019, 10:01pm
1
I’ve tested my service via HA and it works from the dev console like so:
but when I call the service from my appdaemon code like so nothing happens:
self.log("Switch to Alexa, movie")
self.call_service("remote/send_command", entity_id = remote.artison, command = "movie")
self.call_service("media_player/select_source", entity_id = "media_player.strza810es_9565ff", source = "Alexa")
Any ideas? I see my log message so I know I’m hitting that code. It just doesn’t do the command like it does from the HA interface. The subsequent media_player/select_source works from the HA interface too, but not here.
bmcgair
(Bmcgair)
September 4, 2019, 10:18pm
2
OK well I guess I solved my own problem. Apparently I have to explicitly turn the devices on even though they were already on?
self.log("Switch to Alexa, music")
self.call_service("remote/turn_on", entity_id = "remote.artison")
self.call_service("remote/send_command", entity_id = "remote.artison", command = "music")
self.call_service("media_player/turn_on", entity_id = "media_player.strza810es_9565ff")
self.call_service("media_player/select_source", entity_id = "media_player.strza810es_9565ff", source = "Alexa")
You can also use self.turn_on instead of calling the turn_on service. Like this:
self.log("Switch to Alexa, music")
self.turn_on("remote.artison")
self.call_service("remote/send_command", entity_id = "remote.artison", command = "music")
self.turn_on("media_player.strza810es_9565ff")
self.call_service("media_player/select_source", entity_id = "media_player.strza810es_9565ff", source = "Alexa"