def bedroom_tv_off(event): bedroom_tv_off.log.info("bedroom_tv_off") global t_brtvPowerOff Voice.say("Turning off Bedroom TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) events.postUpdate("shutdownKodiBedroomProxy", "OFF") if t_brtvPowerOff is None: t_brtvPowerOff = ScriptExecution.createTimer(DateTime.now().plusSeconds(30), lambda: brtvoffbody())
def AT_tv_on(event): global t_attvPowerOff AT_tv_on.log.info("AT_tv_on") Voice.say("Turning on attic TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) events.postUpdate("shutdownKodiAtticProxy", "ON") # //check if a shutdown timer is running - then stop it before turning stuff on if t_attvPowerOff is not None: t_attvPowerOff = None events.sendCommand("wifi_socket_5_power", "ON")
def fr_tv_off(event): fr_tv_off.log.info("front room_tv_off") global t_frtvPowerOff Voice.say("Turning off front room TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) events.postUpdate("shutdownKodiFrontRoomProxy", "OFF") # events.sendCommand("amplifierStandby", "OFF") if t_frtvPowerOff is None: t_frtvPowerOff = ScriptExecution.createTimer(DateTime.now().plusSeconds(30), lambda: frtvoffbody())
def AT_tv_off(event): AT_tv_off.log.info("attic_tv_off") global t_attvPowerOff Voice.say("Turning off attic TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) events.postUpdate("shutdownKodiAtticProxy", "OFF") # events.sendCommand("amplifierStandby", "OFF") #if the power switch socket is ON then we are OK to do the shutdown routine #if items["wifi_socket_5_power"] == ON: if t_attvPowerOff is None: #shutdown timer is not currently running t_attvPowerOff = ScriptExecution.createTimer(DateTime.now().plusSeconds(30), lambda: attvoffbody())
def conservatory_tv_off(event): conservatory_tv_off.log.info("conservatory_tv_off") global t_CTtvPowerOff Voice.say("Turning off Conservatory TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) # events.postUpdate("shutdownKodiConservatoryProxy", "OFF") - this routine can be removed if this works LogAction.logError("Shutdown Conservatory Kodi","Shutdown Conservatory Kodi: {}", event.itemName) events.sendCommand("kodiConservatory_systemcommand","Shutdown") events.sendCommand("amplifierStandby", "OFF") if t_CTtvPowerOff is None: t_CTtvPowerOff = ScriptExecution.createTimer(DateTime.now().plusSeconds(30), lambda: tvoffbody())
def bedroom_tv_on(event): # global t_tvPowerOff global t_brtvPowerOff bedroom_tv_on.log.info("bedroom_tv_on") Voice.say("Turning on Bedroom TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) #!stop the off timer if it ewas previously tiggered so it dosent interrupt if t_brtvPowerOff is not None: t_brtvPowerOff = None # t_brtvPowerOff=None events.postUpdate("shutdownKodiBedroomProxy", "ON") events.sendCommand("wifi_socket_3_power", "ON")
def conservatory_tv_on(event): global t_CTtvPowerOff conservatory_tv_on.log.info("conservatory_tv_on") Voice.say("Turning on conservatory TV", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(50)) # events.postUpdate("shutdownKodiConservatoryProxy", "ON") events.sendCommand("CT_TV433PowerSocket", "ON") events.sendCommand("amplifier_power", "ON") events.sendCommand("CT_pi_kodi_bg_wifisocket_1_power", "ON") if t_CTtvPowerOff is not None: t_CTtvPowerOff = None t_ampStandbyON = ScriptExecution.createTimer(DateTime.now().plusSeconds(45), lambda: events.sendCommand("amplifierStandby", "ON")) t_ampVideo01 = ScriptExecution.createTimer(DateTime.now().plusSeconds(50), lambda: events.sendCommand("amplifiervideo1", "ON"))
def tts(ttsSay, ttsPrio=PRIO['MODERATE'], **keywords): ''' Text To Speak function. First argument is positional and mandatory. Remaining arguments are optionally keyword arguments. Examples: .. code-block:: tts("Hello") tts("Hello", PRIO['HIGH'], ttsRoom='Kitchen', ttsVol=42, ttsLang='en-GB', ttsVoice='Brian') Args: ttsSay (str): text to speak ttsPrio (str): (optional) priority as defined by PRIO (defaults to PRIO['MODERATE']) **keywords: ``ttsRoom`` (room to speak in), ``ttsVol`` (volume), ``ttsLang`` (language), ``ttsVoice`` (voice), ``ttsEngine`` (engine) Returns: bool: ``True``, if sound was sent, else ``False`` ''' log = logging.getLogger(LOG_PREFIX + ".community.sonos.speak") def getDefaultRoom(): # Search for the default room to speak in for the_key, the_value in sonos['rooms'].iteritems(): if the_value['defaultttsdevice']: return the_key return 'All' if getItemValue(customItemNames['allowTTSSwitch'], scope.ON) != scope.ON and ttsPrio <= PRIO['MODERATE']: log.info( u"[{}] is OFF and ttsPrio is too low to speak [{}] at this moment". format(customItemNames['allowTTSSwitch'].decode('utf8'), ttsSay)) return False ttsRoom = getDefaultRoom( ) if 'ttsRoom' not in keywords else keywords['ttsRoom'] ttsRooms = [] if ttsRoom == 'All' or ttsRoom is None: for the_key, the_value in sonos['rooms'].iteritems(): ttsRooms.append(sonos['rooms'][the_key]) log.debug(u"TTS room found: [{}]".format( sonos['rooms'][the_key]['name'].decode('utf8'))) else: sonosSpeaker = sonos['rooms'].get(ttsRoom, None) if sonosSpeaker is None: log.warn( u"Room [{}] wasn't found in the sonos rooms dictionary".format( ttsRoom.decode('utf8'))) return ttsRooms.append(sonosSpeaker) log.debug(u"TTS room found: [{}]".format( sonosSpeaker['name'].decode('utf8'))) for room in ttsRooms: ttsVol = None if 'ttsVol' not in keywords else keywords['ttsVol'] if not ttsVol or ttsVol >= 70: if ttsPrio == PRIO['LOW']: ttsVol = 30 elif ttsPrio == PRIO['MODERATE']: ttsVol = 40 elif ttsPrio == PRIO['HIGH']: ttsVol = 60 elif ttsPrio == PRIO['EMERGENCY']: ttsVol = 70 else: ttsVol = room['ttsvolume'] ttsLang = room['ttslang'] if 'ttsLang' not in keywords else keywords[ 'ttsLang'] ttsVoice = room[ 'ttsvoice'] if 'ttsVoice' not in keywords else keywords['ttsVoice'] ttsEngine = room[ 'ttsengine'] if 'ttsEngine' not in keywords else keywords[ 'ttsEngine'] #Voice.say(ttsSay, "{}:{}".format(ttsEngine, ttsVoice), room['audiosink']) Voice.say(ttsSay, "{}:{}".format(ttsEngine, ttsVoice), room['audiosink'], scope.PercentType(ttsVol)) # Volume is not well implemented log.info(u"TTS: Speaking [{}] in room [{}] at volume [{}]".format( ttsSay, room['name'].decode('utf8'), ttsVol)) return True
def saytest(event): saytest.log.info("saytest rulel now") Voice.say("This is a test message", "voicerss:enGB", "chromecast:chromecast:GHM_Conservatory", PercentType(65)) events.postUpdate(ir.getItem("Send_Audio_to_GHM"), "OFF") Audio.playSound("chromecast:chromecast:GHM_Conservatory","input_ok_3_clean.mp3")