Untitled
unknown
python
2 years ago
1.9 kB
6
Indexable
async def make_announcement(self, entity_id, msg, volume_level): self.log("Merging speakers. Caller: " + entity_id + " message: " + msg + " volume: " + volume_level) state = "announcement in progress" chromecast = Speakers.speakers["chromecast"] kitchen_bluesound = Speakers.speakers["kitchen"] merge = Speakers.speakers["merge"] self.call_service("script/merge_speakers_for_announcement") self.log("speakers merged") try: await merge.wait_state("off", timeout = 10) except TimeOutException: self.log("merge speakers script timed out") pass # didn't complete on time try: await kitchen_bluesound.wait_state("playing", timeout = 10) except TimeOutException: self.log("merge bluesound playing timed out") pass # didn't complete on time try: await chromecast.wait_state("idle", timeout = 5) except TimeOutException: self.log("merge bluesound chromecast ready") pass # didn't complete on time #wait(1) self.call_service("tts/google_translate_say",message = msg, entity_id="media_player.speakers") self.log("message initiated") #time.sleep(12) #listener kills thread... try: await chromecast.wait_state("playing", timeout = 3) except TimeOutException: self.log("chromecast playing timed out") pass # didn't complete on time try: await chromecast.wait_state("idle", timeout = 15) # wait for chromecast to finish playing message except TimeOutException: self.log("chromecast idle timed out") pass # didn't complete on time #self.listen_state(self.call_service("script/store_bluesound_attributes"),"media_player.chromecast_hd", new="idle", oneshot=true) self.call_service("script/store_bluesound_attributes") self.log("speakers restored")
Editor is loading...