def __init__(self, light_group_id, hue_connection, media_type, initial_state=STATE_STOPPED, video_info_tag=xbmc.InfoTagVideo): self.light_group_id = light_group_id self.bridge = hue_connection.bridge self.enabled = ADDON.getSettingBool( f"group{self.light_group_id}_enabled") self.start_behavior = ADDON.getSettingBool( f"group{self.light_group_id}_startBehavior") self.start_scene = ADDON.getSettingString( f"group{self.light_group_id}_startSceneID") self.pause_behavior = ADDON.getSettingBool( f"group{self.light_group_id}_pauseBehavior") self.pause_scene = ADDON.getSettingString( f"group{self.light_group_id}_pauseSceneID") self.stop_behavior = ADDON.getSettingBool( f"group{self.light_group_id}_stopBehavior") self.stop_scene = ADDON.getSettingString( f"group{self.light_group_id}_stopSceneID") self.state = initial_state self.media_type = media_type self.video_info_tag = video_info_tag self.last_media_type = self.media_type self.lights = self.bridge.lights self.group0 = self.bridge.groups[0] if self.enabled: super().__init__()
def check_active_time(): service_enabled = CACHE.get(f"{ADDONID}.service_enabled") daylight = CACHE.get("script.service.hue.daylight") # xbmc.log("[script.service.hue] Schedule: {}, daylightDisable: {}, daylight: {}, startTime: {}, endTime: {}".format(ADDON.getSettingBool("enableSchedule"), ADDON.getSettingBool("daylightDisable"), daylight, # ADDON.getSettingBool("startTime"), ADDON.getSettingBool("endTime"))) if ADDON.getSettingBool("daylightDisable") and daylight: xbmc.log("[script.service.hue] Disabled by daylight") return False if service_enabled: if ADDON.getSettingBool("enableSchedule"): start = convert_time(ADDON.getSettingString("startTime")) end = convert_time(ADDON.getSettingString("endTime")) now = datetime.datetime.now().time() if (now > start) and (now < end): # xbmc.log("[script.service.hue] Enabled by schedule") return True # xbmc.log("[script.service.hue] Disabled by schedule") return False # xbmc.log("[script.service.hue] Schedule not enabled") return True # xbmc.log("[script.service.hue] Service disabled") return False
def __init__(self, monitor, silent=True, discover=False): self.bridge = None self.bridge_ip = ADDON.getSettingString("bridgeIP") self.bridge_user = ADDON.getSettingString("bridgeUser") self.monitor = monitor self.connected = False if discover: self.discover_bridge() else: self.connect_bridge(silent)
def _validate_schedule(): xbmc.log( f"[script.service.hue] Validate schedule. Schedule Enabled: {ADDON.getSettingBool('enableSchedule')}" ) if ADDON.getSettingBool("enableSchedule"): try: convert_time(ADDON.getSettingString("startTime")) convert_time(ADDON.getSettingString("endTime")) # xbmc.log("[script.service.hue] Time looks valid") except ValueError as e: ADDON.setSettingBool("EnableSchedule", False) xbmc.log(f"[script.service.hue] Invalid time settings: {e}") notification(_("Hue Service"), _("Invalid start or end time, schedule disabled"), icon=xbmcgui.NOTIFICATION_ERROR)