def test_get_lights_by_ids(m): m.register_uri('GET', 'http://127.0.0.1/api/fake/lights', json=LIGHTS) assert len(bridge.get_lights_by_ids(BRIDGE_IP, USERNAME, light_ids=['1'])) == 1 assert len(bridge.get_lights_by_ids(BRIDGE_IP, USERNAME, light_ids=['1', '2'])) == 2 assert len(bridge.get_lights_by_ids(BRIDGE_IP, USERNAME)) == 2
def update_controllers(self): self.ambilight_controller = AmbilightController( bridge.get_lights_by_ids(self.settings.bridge_ip, self.settings.bridge_user, self.settings.ambilight_group.split(',')), self.settings) self.theater_controller = TheaterController( bridge.get_lights_by_ids(self.settings.bridge_ip, self.settings.bridge_user, self.settings.theater_group.split(',')), self.settings) self.static_controller = StaticController( bridge.get_lights_by_ids(self.settings.bridge_ip, self.settings.bridge_user, self.settings.static_group.split(',')), self.settings) xbmclog('Kodi Hue: In Hue.update_controllers() instantiated following ' 'controllers {} {} {}'.format( self.theater_controller, self.ambilight_controller, self.static_controller, ))
def update_controllers(self): if (self.ambilight_controller == None or (self.ambilight_controller != None and set(self.settings.ambilight_group.split(',')) != set( self.ambilight_controller.lights.keys()))): self.ambilight_controller = AmbilightController( bridge.get_lights_by_ids( self.settings.ambilight_group.split(',')), self.settings) if (self.theater_controller == None or (self.theater_controller != None and set(self.settings.theater_group.split(',')) != set( self.theater_controller.lights.keys()))): self.theater_controller = TheaterController( bridge.get_lights_by_ids( self.settings.theater_group.split(',')), self.settings) if (self.static_controller == None or (self.static_controller != None and set(self.settings.static_group.split(',')) != set( self.static_controller.lights.keys()))): self.static_controller = StaticController( bridge.get_lights_by_ids( self.settings.static_group.split(',')), self.settings) xbmclog('In Hue.update_controllers() instantiated following ' 'controllers {} {} {}'.format( self.theater_controller, self.ambilight_controller, self.static_controller, ))
def update_controllers(self): self.ambilight_controller = AmbilightController( bridge.get_lights_by_ids( self.settings.bridge_ip, self.settings.bridge_user, self.settings.ambilight_group.split(',')), self.settings ) self.theater_controller = TheaterController( bridge.get_lights_by_ids( self.settings.bridge_ip, self.settings.bridge_user, self.settings.theater_group.split(',')), self.settings ) self.static_controller = StaticController( bridge.get_lights_by_ids( self.settings.bridge_ip, self.settings.bridge_user, self.settings.static_group.split(',')), self.settings ) xbmclog( 'Kodi Hue: In Hue.update_controllers() instantiated following ' 'controllers {} {} {}'.format( self.theater_controller, self.ambilight_controller, self.static_controller, ) )
def multiselect_lights(bridge_ip, bridge_user, label, exclude, preselect): xbmclog('Kodi Hue: In multiselect_lights(bridge_ip={}, bridge_user={}, ' 'label={}, exclude={}, preselect={})'.format( bridge_ip, bridge_user, label, exclude, preselect)) lights = bridge.get_lights_by_ids(bridge_ip, bridge_user) actual_lights = [] items = [] preselect_items = [] index = 0 for light_id, light in lights.items(): if str(light_id) not in exclude.split(','): items.append(xbmcgui.ListItem(label=light.name)) actual_lights.append(light) if str(light_id) in preselect.split(','): preselect_items.append(index) index += 1 selected = xbmcgui.Dialog().multiselect(label, items, preselect=preselect_items) if selected: light_ids = [str(actual_lights[idx].light_id) for idx in selected] return ','.join(light_ids) return ''
def multiselect_lights(bridge_ip, bridge_user, label, exclude, preselect): xbmclog('Kodi Hue: In multiselect_lights(bridge_ip={}, bridge_user={}, ' 'label={}, exclude={}, preselect={})'.format( bridge_ip, bridge_user, label, exclude, preselect) ) lights = bridge.get_lights_by_ids(bridge_ip, bridge_user) actual_lights = [] items = [] preselect_items = [] index = 0 for light_id, light in lights.items(): if str(light_id) not in exclude.split(','): items.append(xbmcgui.ListItem(label=light.name)) actual_lights.append(light) if str(light_id) in preselect.split(','): preselect_items.append(index) index += 1 selected = xbmcgui.Dialog().multiselect(label, items, preselect=preselect_items) if selected: light_ids = [str(actual_lights[idx].light_id) for idx in selected] return ','.join(light_ids) return ''