From eaf59e4967e862985158d93ac4cfa8d8e5c0958f Mon Sep 17 00:00:00 2001 From: Alexander Falkenstern Date: Thu, 22 Feb 2024 21:57:09 +0100 Subject: [PATCH] Don't overwrite already known lamp types. --- BridgeEmulator/HueObjects/__init__.py | 637 ++++++++++++------------- BridgeEmulator/lights/light_types.py | 235 +++++---- BridgeEmulator/lights/protocols/hue.py | 43 +- 3 files changed, 482 insertions(+), 433 deletions(-) diff --git a/BridgeEmulator/HueObjects/__init__.py b/BridgeEmulator/HueObjects/__init__.py index acfd13645..69092112f 100644 --- a/BridgeEmulator/HueObjects/__init__.py +++ b/BridgeEmulator/HueObjects/__init__.py @@ -1,15 +1,15 @@ -import uuid -import logManager -import random -import weakref -from lights.light_types import lightTypes, archetype -from sensors.sensor_types import sensorTypes +from lights.light_types import archetype, lightTypes from lights.protocols import protocols +from sensors.sensor_types import sensorTypes from threading import Thread from datetime import datetime from pprint import pprint from copy import deepcopy from time import sleep +import uuid +import logManager +import random +import weakref logging = logManager.logger.get_logger(__name__) @@ -89,24 +89,19 @@ def setGroupAction(group, state, scene=None): # apply max and min brightness limis if "bri" in lightsState[light().id_v1]: if "min_bri" in light().protocol_cfg and light().protocol_cfg["min_bri"] > lightsState[light().id_v1]["bri"]: - lightsState[light().id_v1]["bri"] = light( - ).protocol_cfg["min_bri"] + lightsState[light().id_v1]["bri"] = light().protocol_cfg["min_bri"] if "max_bri" in light().protocol_cfg and light().protocol_cfg["max_bri"] < lightsState[light().id_v1]["bri"]: - lightsState[light().id_v1]["bri"] = light( - ).protocol_cfg["max_bri"] + lightsState[light().id_v1]["bri"] = light().protocol_cfg["max_bri"] if light().protocol == "mqtt" and not light().state["on"]: continue # end limits if light().protocol in ["native_multi", "mqtt"]: if light().protocol_cfg["ip"] not in queueState: - queueState[light().protocol_cfg["ip"]] = { - "object": light(), "lights": {}} + queueState[light().protocol_cfg["ip"]] = {"object": light(), "lights": {}} if light().protocol == "native_multi": - queueState[light().protocol_cfg["ip"]]["lights"][light( - ).protocol_cfg["light_nr"]] = lightsState[light().id_v1] + queueState[light().protocol_cfg["ip"]]["lights"][light().protocol_cfg["light_nr"]] = lightsState[light().id_v1] elif light().protocol == "mqtt": - queueState[light().protocol_cfg["ip"]]["lights"][light( - ).protocol_cfg["command_topic"]] = lightsState[light().id_v1] + queueState[light().protocol_cfg["ip"]]["lights"][light().protocol_cfg["command_topic"]] = lightsState[light().id_v1] else: light().setV1State(lightsState[light().id_v1]) for device, state in queueState.items(): @@ -162,19 +157,21 @@ def __init__(self, data): self.active = data["active"] if "active" in data else False self.script_id = data["script_id"] if "script_id" in data else "" - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getV2Api()], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getV2Api()], + "id": str(uuid.uuid4()), + "type": "add" + } eventstream.append(streamMessage) def __del__(self): - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "type": "behavior_instance"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "type": "behavior_instance"}], + "id": str(uuid.uuid4()), + "type": "delete" + } eventstream.append(streamMessage) logging.info(self.name + " behaviour instance was destroyed.") @@ -218,16 +215,19 @@ def update_attr(self, newdata): setattr(self, key, updateAttribute) else: setattr(self, key, value) - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getV2Api()], - "id": str(uuid.uuid4()), - "type": "update" - } + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getV2Api()], + "id": str(uuid.uuid4()), + "type": "update" + } eventstream.append(streamMessage) def save(self): - result = {"id": self.id_v2, "metadata": {"name": self.name}, "configuration": self.configuration, "enabled": self.enabled, "active": self.active, - "script_id": self.script_id} + result = { + "id": self.id_v2, "metadata": {"name": self.name}, "configuration": self.configuration, + "enabled": self.enabled, "active": self.active, "script_id": self.script_id + } if self.name != None: result["metadata"] = {"name": self.name} @@ -254,89 +254,92 @@ def __init__(self, data): self.modelid = data["modelid"] self.id_v1 = data["id_v1"] self.id_v2 = data["id_v2"] if "id_v2" in data else genV2Uuid() - self.uniqueid = data["uniqueid"] if "uniqueid" in data else generate_unique_id( - ) - self.state = data["state"] if "state" in data else deepcopy( - lightTypes[self.modelid]["state"]) + self.uniqueid = data["uniqueid"] if "uniqueid" in data else generate_unique_id() + self.state = data["state"] if "state" in data else deepcopy(lightTypes[self.modelid]["state"]) self.protocol = data["protocol"] if "protocol" in data else "dummy" - self.config = data["config"] if "config" in data else deepcopy( - lightTypes[self.modelid]["config"]) - self.protocol_cfg = data["protocol_cfg"] if "protocol_cfg" in data else { - } + self.config = data["config"] if "config" in data else deepcopy(lightTypes[self.modelid]["config"]) + self.protocol_cfg = data["protocol_cfg"] if "protocol_cfg" in data else {} self.streaming = False self.dynamics = deepcopy(lightTypes[self.modelid]["dynamics"]) self.effect = "no_effect" # entertainment - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": str(uuid.uuid5( - uuid.NAMESPACE_URL, self.id_v2 + 'entertainment')), "type": "entertainent"}], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'entertainment')), "type": "entertainent"}], + "id": str(uuid.uuid4()), + "type": "add" + } streamMessage["id_v1"] = "/lights/" + self.id_v1 streamMessage["data"][0].update(self.getV2Entertainment()) eventstream.append(streamMessage) # zigbee_connectivity - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getZigBee()], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getZigBee()], + "id": str(uuid.uuid4()), + "type": "add" + } eventstream.append(streamMessage) # light - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getV2Api()], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getV2Api()], + "id": str(uuid.uuid4()), + "type": "add" + } eventstream.append(streamMessage) # device - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getDevice()], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getDevice()], + "id": str(uuid.uuid4()), + "type": "add" + } streamMessage["data"][0].update(self.getDevice()) eventstream.append(streamMessage) def __del__(self): ## light ## - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "type": "light"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "type": "light"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/lights/" + self.id_v1 eventstream.append(streamMessage) ## device ## - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.getDevice()["id"], "type": "device"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.getDevice()["id"], "type": "device"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/lights/" + self.id_v1 eventstream.append(streamMessage) # Zigbee Connectivity - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.getZigBee()["id"], "type": "zigbee_connectivity"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.getZigBee()["id"], "type": "zigbee_connectivity"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/lights/" + self.id_v1 eventstream.append(streamMessage) # Entertainment - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.getV2Entertainment()["id"], "type": "entertainment"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.getV2Entertainment()["id"], "type": "entertainment"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/lights/" + self.id_v1 eventstream.append(streamMessage) @@ -350,23 +353,26 @@ def update_attr(self, newdata): setattr(self, key, updateAttribute) else: setattr(self, key, value) - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getDevice()], - "id": str(uuid.uuid4()), - "type": "update" - } + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getDevice()], + "id": str(uuid.uuid4()), + "type": "update" + } eventstream.append(streamMessage) def getV1Api(self): result = lightTypes[self.modelid]["v1_static"] result["config"] = self.config - result["state"] = {"on": self.state["on"]} - if "bri" in self.state and self.modelid not in ["LOM001", "LOM004", "LOM010"]: + result["state"] = { "on": self.state["on"] } + + device = lightTypes[self.modelid] + if ('bri' in self.state) and ('bri' in device['state']): result["state"]["bri"] = int(self.state["bri"]) if self.state["bri"] is not None else 1 - if "ct" in self.state and self.modelid not in ["LOM001", "LOM004", "LOM010", "LTW001"]: + if ('ct' in self.state) and ('ct' in device['state']): result["state"]["ct"] = self.state["ct"] result["state"]["colormode"] = self.state["colormode"] - if "xy" in self.state and self.modelid not in ["LOM001", "LOM004", "LOM010", "LTW001", "LWB010"]: + if ('xy' in self.state) and ('xy' in device['state']): result["state"]["xy"] = self.state["xy"] result["state"]["hue"] = self.state["hue"] result["state"]["sat"] = self.state["sat"] @@ -381,7 +387,6 @@ def getV1Api(self): return result def updateLightState(self, state): - if "xy" in state and "xy" in self.state: self.state["colormode"] = "xy" elif "ct" in state and "ct" in self.state: @@ -426,11 +431,12 @@ def setV2State(self, state): self.genStreamEvent(state) def genStreamEvent(self, v2State): - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "type": "light"}], - "id": str(uuid.uuid4()), - "type": "update" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "type": "light"}], + "id": str(uuid.uuid4()), + "type": "update" + } streamMessage["id_v1"] = "/lights/" + self.id_v1 streamMessage["data"][0].update(v2State) streamMessage["data"][0].update( @@ -438,8 +444,7 @@ def genStreamEvent(self, v2State): eventstream.append(streamMessage) def getDevice(self): - result = {"id": str(uuid.uuid5( - uuid.NAMESPACE_URL, self.id_v2 + 'device'))} + result = {"id": str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'device'))} result["id_v1"] = "/lights/" + self.id_v1 result["identify"] = {} result["metadata"] = { @@ -468,8 +473,7 @@ def getDevice(self): def getZigBee(self): result = {} - result["id"] = str(uuid.uuid5(uuid.NAMESPACE_URL, - self.id_v2 + 'zigbee_connectivity')) + result["id"] = str(uuid.uuid5(uuid.NAMESPACE_URL,self.id_v2 + 'zigbee_connectivity')) result["id_v1"] = "/lights/" + self.id_v1 result["mac_address"] = self.uniqueid[:23] result["owner"] = { @@ -489,50 +493,49 @@ def getBridgeHome(self): def getV2Api(self): result = {} result["alert"] = {"action_values": ["breathe"]} + # gradient lights if self.modelid in ["LCX002", "915005987201", "LCX004", "LCX006"]: - result["effects"] = { - "effect_values": [ - "no_effect", - "candle", - "fire" - ], - "status": self.effect, - "status_values": [ - "no_effect", - "candle", - "fire" - ] + result["gradient"] = { + "points": self.state["gradient"]["points"], + "points_capable": self.protocol_cfg["points_capable"] } - result["gradient"] = {"points": self.state["gradient"]["points"], - "points_capable": self.protocol_cfg["points_capable"]} # color lights only - if self.modelid in ["LST002", "LCT001", "LCT015", "LCX002", "915005987201", "LCX004", "LCX006", "LCA005"]: - colorgamut = lightTypes[self.modelid]["v1_static"]["capabilities"]["control"]["colorgamut"] + capabilities = lightTypes[self.modelid]["v1_static"]["capabilities"] + if ("colorgamut" in capabilities["control"]) and ("colorgamuttype" in capabilities["control"]): + colorgamut = capabilities["control"]["colorgamut"] result["color"] = { "gamut": { "blue": {"x": colorgamut[2][0], "y": colorgamut[2][1]}, "green": {"x": colorgamut[1][0], "y": colorgamut[1][1]}, "red": {"x": colorgamut[0][0], "y": colorgamut[0][1]} }, - "gamut_type": lightTypes[self.modelid]["v1_static"]["capabilities"]["control"]["colorgamuttype"], + "gamut_type": capabilities["control"]["colorgamuttype"], "xy": { "x": self.state["xy"][0], "y": self.state["xy"][1] } } - if "ct" in self.state: + result["effects"] = { + "effect_values": [ "no_effect", "candle", "fire" ], + "status": "no_effect", + "status_values": [ "no_effect", "candle", "fire" ] + } + + if ("ct" in self.state) and ("ct" in capabilities["control"]): + ct_value = self.state["ct"] + ct = capabilities["control"]["ct"] result["color_temperature"] = { - "mirek": self.state["ct"] if self.state["colormode"] == "ct" else None, + "mirek": ct_value if self.state["colormode"] == "ct" else None, "mirek_schema": { - "mirek_maximum": 500, - "mirek_minimum": 153 - } + "mirek_maximum": ct["max"], + "mirek_minimum": ct["min"] + }, + "mirek_valid": (ct_value is not None) and (ct["min"] <= ct_value <= ct["max"]) } - result["color_temperature"]["mirek_valid"] = True if self.state[ - "ct"] != None and self.state["ct"] < 500 and self.state["ct"] > 153 else False result["color_temperature_delta"] = {} + if "bri" in self.state: bri_value = self.state["bri"] if bri_value is None or bri_value == "null": @@ -542,25 +545,15 @@ def getV2Api(self): "min_dim_level": 0.1 # Adjust this value as needed } result["dimming_delta"] = {} + result["dynamics"] = self.dynamics - result["effects"] = { - "effect_values": [ - "no_effect", - "candle", - "fire" - ], - "status": "no_effect", - "status_values": [ - "no_effect", - "candle", - "fire" - ] - } result["identify"] = {} result["id"] = self.id_v2 result["id_v1"] = "/lights/" + self.id_v1 - result["metadata"] = {"name": self.name, "function": "mixed", - "archetype": archetype[self.config["archetype"]]} + result["metadata"] = { + "name": self.name, "function": "mixed", + "archetype": archetype[self.config["archetype"]] + } result["mode"] = "normal" if "mode" in self.state and self.state["mode"] == "streaming": result["mode"] = "streaming" @@ -571,16 +564,13 @@ def getV2Api(self): "rid": str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'device')), "rtype": "device" } - result["product_data"] = {"function": "mixed"} - result["signaling"] = {"signal_values": [ - "no_signal", - "on_off"]} + result["product_data"] = { "function": "mixed" } + result["signaling"] = { "signal_values": [ "no_signal", "on_off" ] } result["type"] = "light" return result def getV2Entertainment(self): - entertainmenUuid = str(uuid.uuid5( - uuid.NAMESPACE_URL, self.id_v2 + 'entertainment')) + entertainmenUuid = str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'entertainment')) result = { "equalizer": True, "id": entertainmenUuid, @@ -592,11 +582,8 @@ def getV2Entertainment(self): "rtype": "light" } } - result["owner"] = { - "rid": self.getDevice()["id"], "rtype": "device"} - result["segments"] = { - "configurable": False - } + result["owner"] = { "rid": self.getDevice()["id"], "rtype": "device" } + result["segments"] = { "configurable": False } if self.modelid == "LCX002": result["segments"]["max_segments"] = 7 result["segments"]["segments"] = [ @@ -707,45 +694,49 @@ def save(self): class EntertainmentConfiguration(): def __init__(self, data): - self.name = data["name"] if "name" in data else "Group " + \ - data["id_v1"] + self.name = data["name"] if "name" in data else "Group " + data["id_v1"] self.id_v1 = data["id_v1"] self.id_v2 = data["id_v2"] if "id_v2" in data else genV2Uuid() self.configuration_type = data["configuration_type"] if "configuration_type" in data else "3dspace" self.lights = [] - self.action = {"on": False, "bri": 100, "hue": 0, "sat": 254, "effect": "none", "xy": [ - 0.0, 0.0], "ct": 153, "alert": "none", "colormode": "xy"} + self.action = { + "on": False, "bri": 100, "hue": 0, "sat": 254, "effect": "none", + "xy": [0.0, 0.0], "ct": 153, "alert": "none", "colormode": "xy" + } self.sensors = [] self.type = data["type"] if "type" in data else "Entertainment" self.configuration_type = data["configuration_type"] if "configuration_type" in data else "screen" self.locations = weakref.WeakKeyDictionary() - self.stream = {"proxymode": "auto", - "proxynode": "/bridge", "active": False, "owner": None} + self.stream = {"proxymode": "auto", "proxynode": "/bridge", "active": False, "owner": None} self.state = {"all_on": False, "any_on": False} self.dxState = {"all_on": None, "any_on": None} - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getV2Api()], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getV2Api()], + "id": str(uuid.uuid4()), + "type": "add" + } eventstream.append(streamMessage) def __del__(self): # Groupper light - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "type": "grouped_light"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "type": "grouped_light"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/groups/" + self.id_v1 eventstream.append(streamMessage) + ### Entertainment area ### - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.getV2Api()["id"], "type": "entertainment_configuration"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.getV2Api()["id"], "type": "entertainment_configuration"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/groups/" + self.id_v1 eventstream.append(streamMessage) logging.info(self.name + " entertainment area was destroyed.") @@ -766,11 +757,12 @@ def update_attr(self, newdata): setattr(self, key, updateAttribute) else: setattr(self, key, value) - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getV2Api()], - "id": str(uuid.uuid4()), - "type": "update" - } + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getV2Api()], + "id": str(uuid.uuid4()), + "type": "update" + } eventstream.append(streamMessage) def update_state(self): @@ -831,19 +823,15 @@ def getV1Api(self): return result def getV2Api(self): - - gradienStripPositions = [{"x": -0.4000000059604645, "y": 0.800000011920929, "z": -0.4000000059604645}, - {"x": -0.4000000059604645, - "y": 0.800000011920929, "z": 0.0}, - {"x": -0.4000000059604645, "y": 0.800000011920929, - "z": 0.4000000059604645}, - {"x": 0.0, "y": 0.800000011920929, - "z": 0.4000000059604645}, - {"x": 0.4000000059604645, "y": 0.800000011920929, - "z": 0.4000000059604645}, - {"x": 0.4000000059604645, - "y": 0.800000011920929, "z": 0.0}, - {"x": 0.4000000059604645, "y": 0.800000011920929, "z": -0.4000000059604645}] + gradienStripPositions = [ + {"x": -0.4000000059604645, "y": 0.800000011920929, "z": -0.4000000059604645}, + {"x": -0.4000000059604645, "y": 0.800000011920929, "z": 0.0}, + {"x": -0.4000000059604645, "y": 0.800000011920929, "z": 0.4000000059604645}, + {"x": 0.0, "y": 0.800000011920929, "z": 0.4000000059604645}, + {"x": 0.4000000059604645, "y": 0.800000011920929, "z": 0.4000000059604645}, + {"x": 0.4000000059604645, "y": 0.800000011920929, "z": 0.0}, + {"x": 0.4000000059604645, "y": 0.800000011920929, "z": -0.4000000059604645} + ] result = { "configuration_type": self.configuration_type, @@ -874,8 +862,7 @@ def getV2Api(self): channel_id = 0 for light in self.lights: if light(): - result["light_services"].append( - {"rtype": "light", "rid": light().id_v2}) + result["light_services"].append({"rtype": "light", "rid": light().id_v2}) entertainmentUuid = str(uuid.uuid5( uuid.NAMESPACE_URL, light().id_v2 + 'entertainment')) result["locations"]["service_locations"].append({"equalization_factor": 1, "positions": self.locations[light()], @@ -934,11 +921,12 @@ def setV1Action(self, state, scene=None): self.genStreamEvent(v2State) def genStreamEvent(self, v2State): - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "type": "grouped_light"}], - "id": str(uuid.uuid4()), - "type": "update" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "type": "grouped_light"}], + "id": str(uuid.uuid4()), + "type": "update" + } streamMessage["id_v1"] = "/groups/" + self.id_v1 streamMessage.update(v2State) eventstream.append(streamMessage) @@ -1025,79 +1013,84 @@ def __init__(self, data): self.state = {"all_on": False, "any_on": False} self.dxState = {"all_on": None, "any_on": None} - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getV2Room() if self.type == "Room" else self.getV2Zone()], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getV2Room() if self.type == "Room" else self.getV2Zone()], + "id": str(uuid.uuid4()), + "type": "add" + } eventstream.append(streamMessage) def groupZeroStream(self, rooms, lights): - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"children": [], "id": str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'bridge_home')), "id_v1":"/groups/0", "type": "bridge_home"}], - "id": str(uuid.uuid4()), - "type": "update" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"children": [], "id": str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'bridge_home')), "id_v1":"/groups/0", "type": "bridge_home"}], + "id": str(uuid.uuid4()), + "type": "update" + } for room in rooms: - streamMessage["data"][0]["children"].append( - {"rid": room, "rtype": "room"}) + streamMessage["data"][0]["children"].append({"rid": room, "rtype": "room"}) for light in lights: - streamMessage["data"][0]["children"].append( - {"rid": light, "rtype": "light"}) + streamMessage["data"][0]["children"].append({"rid": light, "rtype": "light"}) eventstream.append(streamMessage) def __del__(self): # Groupper light - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "id_v1": "/groups/" + self.id_v1, "type": "grouped_light"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "id_v1": "/groups/" + self.id_v1, "type": "grouped_light"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/groups/" + self.id_v1 eventstream.append(streamMessage) + ### room / zone #### - elementId = self.getV2Room( - )["id"] if self.type == "Room" else self.getV2Zone()["id"] + elementId = self.getV2Room()["id"] if self.type == "Room" else self.getV2Zone()["id"] elementType = "room" if self.type == "Room" else "zone" - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": elementId, "id_v1": "/groups/" + self.id_v1, "type": elementType}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": elementId, "id_v1": "/groups/" + self.id_v1, "type": elementType}], + "id": str(uuid.uuid4()), + "type": "delete" + } eventstream.append(streamMessage) logging.info(self.name + " group was destroyed.") def add_light(self, light): self.lights.append(weakref.ref(light)) - elementId = self.getV2Room( - )["id"] if self.type == "Room" else self.getV2Zone()["id"] + elementId = self.getV2Room()["id"] if self.type == "Room" else self.getV2Zone()["id"] elementType = "room" if self.type == "Room" else "zone" - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"alert": {"action_values": ["breathe"]}, "id": self.id_v2, "id_v1": "/groups/" + self.id_v1, "on":{"on": self.action["on"]}, "type": "grouped_light", }], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"alert": {"action_values": ["breathe"]}, "id": self.id_v2, "id_v1": "/groups/" + self.id_v1, "on":{"on": self.action["on"]}, "type": "grouped_light", }], + "id": str(uuid.uuid4()), + "type": "add" + } eventstream.append(streamMessage) - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"grouped_services": [{"rid": self.id_v2, "rtype": "grouped_light"}], "id": elementId, "id_v1": "/groups/" + self.id_v1, "type": elementType}], - "id": str(uuid.uuid4()), - "type": "update" - } + + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"grouped_services": [{"rid": self.id_v2, "rtype": "grouped_light"}], "id": elementId, "id_v1": "/groups/" + self.id_v1, "type": elementType}], + "id": str(uuid.uuid4()), + "type": "update" + } eventstream.append(streamMessage) groupChildrens = [] groupServices = [] for light in self.lights: if light(): - groupChildrens.append( - {"rid": light().getDevice()["id"], "rtype": "device"}) + groupChildrens.append({"rid": light().getDevice()["id"], "rtype": "device"}) groupServices.append({"rid": light().id_v2, "rtype": "light"}) groupServices.append({"rid": self.id_v2, "rtype": "grouped_light"}) - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"children": groupChildrens, "id": elementId, "id_v1": "/groups/" + self.id_v1, "services": groupServices, "type": elementType}], - "id": str(uuid.uuid4()), - "type": "update" - } + + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"children": groupChildrens, "id": elementId, "id_v1": "/groups/" + self.id_v1, "services": groupServices, "type": elementType}], + "id": str(uuid.uuid4()), + "type": "update" + } eventstream.append(streamMessage) def add_sensor(self, sensor): @@ -1116,12 +1109,13 @@ def update_attr(self, newdata): else: setattr(self, key, value) - streamMessage = {"creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getV2Room() if self.type == "Room" else self.getV2Zone()], - "owner": { - "rid": self.getV2Room()["id"] if self.type == "Room" else self.getV2Zone()["id"], - "rtype": "room" if self.type == "Room" else "zone" - }, + streamMessage = { + "creationtime": datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getV2Room() if self.type == "Room" else self.getV2Zone()], + "owner": { + "rid": self.getV2Room()["id"] if self.type == "Room" else self.getV2Zone()["id"], + "rtype": "room" if self.type == "Room" else "zone" + }, "id": str(uuid.uuid4()), "type": "update" } @@ -1153,23 +1147,25 @@ def setV1Action(self, state, scene=None): def genStreamEvent(self, v2State): for light in self.lights: if light(): - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": light().id_v2, "id_v1": "/lights/" + light().id_v1, "owner": {"rid": light().getDevice()["id"], "rtype":"device"}, "type": "light"}], - "id": str(uuid.uuid4()), - "type": "update" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": light().id_v2, "id_v1": "/lights/" + light().id_v1, "owner": {"rid": light().getDevice()["id"], "rtype":"device"}, "type": "light"}], + "id": str(uuid.uuid4()), + "type": "update" + } streamMessage["data"][0].update(v2State) eventstream.append(streamMessage) - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "type": "grouped_light", - "owner": { - "rid": self.getV2Room()["id"] if self.type == "Room" else self.getV2Zone()["id"], - "rtype": "room" if self.type == "Room" else "zone" - } - }], - "id": str(uuid.uuid4()), - "type": "update" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "type": "grouped_light", + "owner": { + "rid": self.getV2Room()["id"] if self.type == "Room" else self.getV2Zone()["id"], + "rtype": "room" if self.type == "Room" else "zone" + } + }], + "id": str(uuid.uuid4()), + "type": "update" + } streamMessage["id_v1"] = "/groups/" + self.id_v1 streamMessage["data"][0].update(v2State) eventstream.append(streamMessage) @@ -1192,9 +1188,12 @@ def getV1Api(self): result["recycle"] = False if self.id_v1 == "0": result["presence"] = { - "state": {"presence": None, "presence_all": None, "lastupdated": "none"}} - result["lightlevel"] = {"state": {"dark": None, "dark_all": None, "daylight": None, "daylight_any": None, - "lightlevel": None, "lightlevel_min": None, "lightlevel_max": None, "lastupdated": "none"}} + "state": {"presence": None, "presence_all": None, "lastupdated": "none"} + } + result["lightlevel"] = { + "state": {"dark": None, "dark_all": None, "daylight": None, "daylight_any": None, + "lightlevel": None, "lightlevel_min": None, "lightlevel_max": None, "lastupdated": "none"} + } else: result["class"] = self.icon_class result["action"] = self.action @@ -1205,8 +1204,7 @@ def getV2Room(self): for light in self.lights: if light(): result["children"].append({ - "rid": str(uuid.uuid5( - uuid.NAMESPACE_URL, light().id_v2 + 'device')), + "rid": str(uuid.uuid5(uuid.NAMESPACE_URL, light().id_v2 + 'device')), "rtype": "device" }) @@ -1292,8 +1290,10 @@ def getObjectPath(self): return {"resource": "groups", "id": self.id_v1} def save(self): - result = {"id_v2": self.id_v2, "name": self.name, "class": self.icon_class, - "lights": [], "action": self.action, "type": self.type} + result = { + "id_v2": self.id_v2, "name": self.name, "class": self.icon_class, + "lights": [], "action": self.action, "type": self.type + } for light in self.lights: if light(): result["lights"].append(light().id_v1) @@ -1324,20 +1324,23 @@ def __init__(self, data): if "group" in data: self.storelightstate() self.lights = self.group().lights - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [self.getV2Api()], - "id": str(uuid.uuid4()), - "type": "add" - } + + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [self.getV2Api()], + "id": str(uuid.uuid4()), + "type": "add" + } streamMessage["data"][0].update(self.getV2Api()) eventstream.append(streamMessage) def __del__(self): - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "type": "scene"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "type": "scene"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/scenes/" + self.id_v1 eventstream.append(streamMessage) logging.info(self.name + " scene was destroyed.") @@ -1374,8 +1377,7 @@ def activate(self, data): if transitiontime > 0: state["transitiontime"] = transitiontime if "recall" in data and "duration" in data["recall"]: - state["transitiontime"] = int( - data["recall"]["duration"] / 100) + state["transitiontime"] = int(data["recall"]["duration"] / 100) if light.protocol in ["native_multi", "mqtt"]: if light.protocol_cfg["ip"] not in queueState: @@ -1447,15 +1449,13 @@ def getV2Api(self): if "ct" in state: v2State["color_temperature"] = { "mirek": state["ct"]} - result["actions"].append( - { - "action": v2State, - "target": { - "rid": light.id_v2, - "rtype": "light", - }, + result["actions"].append({ + "action": v2State, + "target": { + "rid": light.id_v2, + "rtype": "light", } - ) + }) if self.type == "GroupScene": if self.group(): @@ -1465,8 +1465,7 @@ def getV2Api(self): } result["metadata"] = {} if self.image != None: - result["metadata"]["image"] = {"rid": self.image, - "rtype": "public_image"} + result["metadata"]["image"] = {"rid": self.image, "rtype": "public_image"} result["metadata"]["name"] = self.name result["id"] = self.id_v2 result["id_v1"] = "/scenes/" + self.id_v1 @@ -1589,7 +1588,6 @@ def update_attr(self, newdata): def save(self): return self.getV1Api() - class ResourceLink(): def __init__(self, data): self.name = data["name"] @@ -1636,8 +1634,7 @@ def save(self): class Schedule(): def __init__(self, data): - self.name = data["name"] if "name" in data else "schedule " + \ - data["id_v1"] + self.name = data["name"] if "name" in data else "schedule " + data["id_v1"] self.id_v1 = data["id_v1"] self.description = data["description"] if "description" in data else "none" self.command = data["command"] if "command" in data else {} @@ -1690,7 +1687,6 @@ def getObjectPath(self): def save(self): return self.getV1Api() - class Sensor(): def __init__(self, data): if data["modelid"] in sensorTypes: @@ -1723,8 +1719,7 @@ def __init__(self, data): self.modelid = data["modelid"] self.manufacturername = data["manufacturername"] if "manufacturername" in data else "Philips" self.protocol = data["protocol"] if "protocol" in data else "none" - self.protocol_cfg = data["protocol_cfg"] if "protocol_cfg" in data else { - } + self.protocol_cfg = data["protocol_cfg"] if "protocol_cfg" in data else {} self.type = data["type"] self.state = data["state"] dxstate = {} @@ -1735,21 +1730,23 @@ def __init__(self, data): self.recycle = data["recycle"] if "recycle" in data else False self.uniqueid = data["uniqueid"] if "uniqueid" in data else None if self.getDevice() != None: - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.id_v2, "type": "device"}], - "id": str(uuid.uuid4()), - "type": "add" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.id_v2, "type": "device"}], + "id": str(uuid.uuid4()), + "type": "add" + } streamMessage["data"][0].update(self.getDevice()) eventstream.append(streamMessage) def __del__(self): if self.modelid in ["SML001", "RWL022"]: - streamMessage = {"creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), - "data": [{"id": self.getDevice()["id"], "type": "device"}], - "id": str(uuid.uuid4()), - "type": "delete" - } + streamMessage = { + "creationtime": datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"), + "data": [{"id": self.getDevice()["id"], "type": "device"}], + "id": str(uuid.uuid4()), + "type": "delete" + } streamMessage["id_v1"] = "/sensors/" + self.id_v1 eventstream.append(streamMessage) logging.info(self.name + " sensor was destroyed.") @@ -1967,7 +1964,7 @@ def getZigBee(self): result["owner"] = { "rid": self.id_v2, "rtype": "device" - } + } result["type"] = "zigbee_connectivity" result["mac_address"] = self.uniqueid[:23] result["status"] = "connected" @@ -1978,17 +1975,17 @@ def getButtons(self): if self.modelid == "RWL022" or self.modelid == "RWL021" or self.modelid == "RWL020" or self.modelid == "RDM002" and self.type != "ZLLRelativeRotary": for button in range(4): result.append({ - "id": str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'button' + str(button + 1))), - "id_v1": "/sensors/" + self.id_v1, - "owner": { - "rid": self.id_v2, - "rtype": "device" - }, - "metadata": { - "control_id": button + 1 - }, - "type": "button" - }) + "id": str(uuid.uuid5(uuid.NAMESPACE_URL, self.id_v2 + 'button' + str(button + 1))), + "id_v1": "/sensors/" + self.id_v1, + "owner": { + "rid": self.id_v2, + "rtype": "device" + }, + "metadata": { + "control_id": button + 1 + }, + "type": "button" + }) return result def getRotary(self): diff --git a/BridgeEmulator/lights/light_types.py b/BridgeEmulator/lights/light_types.py index e3524b1f9..5f59507ea 100644 --- a/BridgeEmulator/lights/light_types.py +++ b/BridgeEmulator/lights/light_types.py @@ -1,122 +1,157 @@ # Define light defininitions for discovery features and adding device data to config lightTypes = {} +## Hue White and Color Ambiance A19 800 Lumen +lightTypes["LCA005"] = {"v1_static":{"type":"Extended color light", "swversion":"1.104.2", "swconfigid":"5419E9E3", "productid":"Philips-LCA005-1-A19ECLv7", "manufacturername":"Signify Netherlands B.V."}} +lightTypes["LCA005"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LCA005"]["v1_static"]["capabilities"] = {"certified":True, "control":{"colorgamut":[[0.6915,0.3083],[0.17,0.7],[0.1532,0.0475]], "colorgamuttype":"C", "ct":{"max":500, "min":153}, "maxlumen":800, "mindimlevel":1000}, "streaming":{"proxy":False, "renderer":True}} +lightTypes["LCA005"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "product_archetype":"sultan_bulb", "product_name":"Hue color lamp", "software_version":"1.104.2"} +lightTypes["LCA005"]["state"] = {"on":False, "bri":200, "hue":0, "sat":0, "xy":[0.0, 0.0], "ct":461, "alert":"none", "mode":"homeautomation", "effect":"none", "colormode":"ct", "reachable":True} +lightTypes["LCA005"]["config"] = {"archetype":"sultanbulb", "function":"mixed", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":True}} +lightTypes["LCA005"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} + ## Hue Color Bulb #1 -lightTypes["LCT001"] = {"v1_static": {"type":"Extended color light", "manufacturername": "Signify Netherlands B.V.", "swversion": "1.104.2"}} -lightTypes["LCT001"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LCT001"]["v1_static"]["capabilities"] = {"certified": True,"control": {"colorgamut": [[0.675,0.322],[0.409,0.518],[0.167,0.04]],"colorgamuttype": "B","ct": {"max": 500,"min": 153},"maxlumen": 600,"mindimlevel": 5000},"streaming": {"proxy": False,"renderer": True}} -lightTypes["LCT001"]["device"] = {"certified": True,"manufacturer_name": "Signify Netherlands B.V.","product_archetype": "sultan_bulb","product_name": "Hue color lamp","software_version": "1.104.2"} -lightTypes["LCT001"]["state"] = {"alert": "none", "bri":0, "colormode": "xy", "effect": "none","hue": 0, "mode": "homeautomation","on": False,"reachable": True, "sat": 0,"xy": [0.408,0.517]} -lightTypes["LCT001"]["config"] = {"archetype": "sultanbulb","direction": "omnidirectional","function": "mixed","startup": {"configured": True, "mode": "safety"}} -lightTypes["LCT001"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} +lightTypes["LCT001"] = {"v1_static":{"type":"Extended color light", "manufacturername":"Signify Netherlands B.V.", "swversion":"1.104.2"}} +lightTypes["LCT001"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LCT001"]["v1_static"]["capabilities"] = {"certified":True, "control":{"colorgamut":[[0.675,0.322],[0.409,0.518],[0.167,0.04]], "colorgamuttype":"B", "ct":{"max":500, "min":153}, "maxlumen":600, "mindimlevel":5000}, "streaming":{"proxy":False, "renderer":True}} +lightTypes["LCT001"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "product_archetype":"sultan_bulb", "product_name":"Hue color lamp", "software_version":"1.104.2"} +lightTypes["LCT001"]["state"] = {"alert":"none", "bri":0, "colormode":"xy", "effect":"none", "hue":0, "mode":"homeautomation", "on":False, "reachable":True, "sat":0, "xy":[0.408,0.517]} +lightTypes["LCT001"]["config"] = {"archetype":"sultanbulb", "direction":"omnidirectional", "function":"mixed", "startup":{"configured":True, "mode":"safety"}} +lightTypes["LCT001"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} ## Hue Color Bulb #2 -lightTypes["LCT015"] = {"v1_static": {"type": "Extended color light", "swversion":"1.104.2","swconfigid":"772B0E5E","productid":"Philips-LCT015-1-A19ECLv5","manufacturername": "Signify Netherlands B.V."}} -lightTypes["LCT015"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LCT015"]["v1_static"]["capabilities"] = {"certified": True,"control": {"colorgamut": [[0.6915,0.3083],[0.17,0.7],[0.1532,0.0475]],"colorgamuttype": "C","ct": {"max": 500,"min": 153},"maxlumen": 800,"mindimlevel": 1000},"streaming": {"proxy": False,"renderer": True}} -lightTypes["LCT015"]["device"] = {"certified": True,"manufacturer_name": "Signify Netherlands B.V.","product_archetype": "sultan_bulb","product_name": "Hue color lamp","software_version": "1.104.2"} -lightTypes["LCT015"]["state"] = {"on": False, "bri": 200, "hue": 0, "sat": 0, "xy": [0.0, 0.0], "ct": 461, "alert": "none", "mode": "homeautomation", "effect": "none", "colormode": "ct", "reachable": True} -lightTypes["LCT015"]["config"] = {"archetype": "sultanbulb", "function": "mixed", "direction": "omnidirectional","startup":{"mode":"safety","configured": True}} -lightTypes["LCT015"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} +lightTypes["LCT015"] = {"v1_static":{"type":"Extended color light", "swversion":"1.104.2", "swconfigid":"772B0E5E", "productid":"Philips-LCT015-1-A19ECLv5", "manufacturername":"Signify Netherlands B.V."}} +lightTypes["LCT015"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LCT015"]["v1_static"]["capabilities"] = {"certified":True, "control":{"colorgamut":[[0.6915,0.3083],[0.17,0.7],[0.1532,0.0475]], "colorgamuttype":"C", "ct":{"max":500, "min":153}, "maxlumen":800, "mindimlevel":1000}, "streaming":{"proxy":False, "renderer":True}} +lightTypes["LCT015"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "product_archetype":"sultan_bulb", "product_name":"Hue color lamp", "software_version":"1.104.2"} +lightTypes["LCT015"]["state"] = {"on":False, "bri":200, "hue":0, "sat":0, "xy":[0.0, 0.0], "ct":461, "alert":"none", "mode":"homeautomation", "effect":"none", "colormode":"ct", "reachable":True} +lightTypes["LCT015"]["config"] = {"archetype":"sultanbulb", "function":"mixed", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":True}} +lightTypes["LCT015"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} + +## Hue White and Color Ambiance GU10 w/BT +lightTypes["LCG002"] = {"v1_static":{"type":"Extended color light", "swversion":"1.104.2", "swconfigid":"D779D146", "productid":"Philips-LCG002-3-GU10ECLv2", "manufacturername":"Signify Netherlands B.V."}} +lightTypes["LCG002"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LCG002"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":200, "maxlumen":300, "colorgamuttype":"C", "colorgamut":[[0.6915,0.3083],[0.17,0.7],[0.1532,0.0475]], "ct":{"min":153, "max":500}}, "streaming":{"renderer":True, "proxy":True}} +lightTypes["LCG002"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "product_archetype":"spot_bulb", "product_name":"Hue White and Color Ambiance GU10 w/ BT", "software_version":"1.104.2"} +lightTypes["LCG002"]["state"] = {"on":False, "bri":200, "hue":0, "sat":0, "xy":[0.0, 0.0], "ct":461, "alert":"none", "mode":"homeautomation", "effect":"none", "colormode":"xy", "reachable":True} +lightTypes["LCG002"]["config"] = {"archetype":"spotbulb", "function":"mixed", "direction":"downwards", "startup":{"mode":"safety", "configured":True}} +lightTypes["LCG002"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} ## Hue Lightstrip Plus -lightTypes["LST002"] = {"v1_static": {"type": "Color light", "manufacturername": "Signify Netherlands B.V.", "swversion": "1.104.2", "productname":"Hue lightstrip plus","swconfigid":"59F2C3A3","productid":"Philips-LST002-1-LedStripsv3"}} -lightTypes["LST002"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LST002"]["v1_static"]["capabilities"] = {"certified":True,"control":{"mindimlevel":40,"maxlumen":1600,"colorgamuttype":"C","colorgamut":[[0.6915,0.3083],[0.17,0.7],[0.1532,0.0475]],"ct":{"min":153,"max":500}},"streaming":{"renderer":True,"proxy":True}} -lightTypes["LST002"]["device"] = {"certified": True, "manufacturer_name": "Signify Netherlands B.V.", "product_archetype": "hue_lightstrip", "product_name": "Hue lightstrip plus", "software_version": "1.104.2"} -lightTypes["LST002"]["state"] = {"on": False, "bri": 200, "hue": 0, "sat": 0, "xy": [0.0, 0.0], "ct": 461, "alert": "none", "mode": "homeautomation", "effect": "none", "colormode": "ct", "reachable": True} -lightTypes["LST002"]["config"] = {"archetype": "huelightstrip", "function": "mixed", "direction": "omnidirectional", "startup": {"mode": "safety", "configured": False}} -lightTypes["LST002"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} - -## Hue White and Color Ambiance A19 800 Lumen -lightTypes["LCA005"] = {"v1_static": {"type": "Extended color light", "swversion":"1.104.2","swconfigid":"5419E9E3","productid":"Philips-LCA005-1-A19ECLv7","manufacturername": "Signify Netherlands B.V."}} -lightTypes["LCA005"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LCA005"]["v1_static"]["capabilities"] = {"certified": True,"control": {"colorgamut": [[0.6915,0.3083],[0.17,0.7],[0.1532,0.0475]],"colorgamuttype": "C","ct": {"max": 500,"min": 153},"maxlumen": 800,"mindimlevel": 1000},"streaming": {"proxy": False,"renderer": True}} -lightTypes["LCA005"]["device"] = {"certified": True,"manufacturer_name": "Signify Netherlands B.V.","product_archetype": "sultan_bulb","product_name": "Hue color lamp","software_version": "1.104.2"} -lightTypes["LCA005"]["state"] = {"on": False, "bri": 200, "hue": 0, "sat": 0, "xy": [0.0, 0.0], "ct": 461, "alert": "none", "mode": "homeautomation", "effect": "none", "colormode": "ct", "reachable": True} -lightTypes["LCA005"]["config"] = {"archetype": "sultanbulb", "function": "mixed", "direction": "omnidirectional","startup":{"mode":"safety","configured": True}} -lightTypes["LCA005"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} +lightTypes["LST002"] = {"v1_static":{"type":"Color light", "manufacturername":"Signify Netherlands B.V.", "swversion":"1.104.2", "productname":"Hue lightstrip plus", "swconfigid":"59F2C3A3", "productid":"Philips-LST002-1-LedStripsv3"}} +lightTypes["LST002"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LST002"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":40, "maxlumen":1600, "colorgamuttype":"C", "colorgamut":[[0.6915,0.3083],[0.17,0.7],[0.1532,0.0475]], "ct":{"min":153, "max":500}}, "streaming":{"renderer":True, "proxy":True}} +lightTypes["LST002"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "product_archetype":"hue_lightstrip", "product_name":"Hue lightstrip plus", "software_version":"1.104.2"} +lightTypes["LST002"]["state"] = {"on":False, "bri":200, "hue":0, "sat":0, "xy":[0.0, 0.0], "ct":461, "alert":"none", "mode":"homeautomation", "effect":"none", "colormode":"ct", "reachable":True} +lightTypes["LST002"]["config"] = {"archetype":"huelightstrip", "function":"mixed", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":False}} +lightTypes["LST002"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} + +## Hue White Ambiance GU10 w/BT +lightTypes["LTG002"] = {"v1_static":{"type":"Color temperature light", "manufacturername":"Signify Netherlands B.V.", "productname":"Hue Runner spot", "swversion":"1.104.2", "swconfigid":"87D6EF03", "productid":"Philips-LTG002-3-GU10CTv2"}} +lightTypes["LTG002"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LTG002"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":200, "maxlumen":350, "ct":{"min":153, "max":454}}, "streaming":{"renderer":False, "proxy":False}} +lightTypes["LTG002"]["config"] = {"archetype":"spotbulb", "function":"functional", "direction":"downwards", "startup":{"mode":"safety", "configured":True}} +lightTypes["LTG002"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "model_id":"LTG002", "product_archetype":"spot_bulb", "product_name":"Hue White Ambiance GU10 w/BT", "software_version":"1.104.2"} +lightTypes["LTG002"]["state"] = {"on":False, "colormode":"ct", "alert":"select", "mode":"homeautomation", "reachable":True, "bri":127, "ct":369} +lightTypes["LTG002"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} ## Dimmable Hue Bulb -lightTypes["LWB010"] = {"v1_static": {"type": "Dimmable light", "swversion": "1.50.2_r30933", "manufacturername": "Signify Netherlands B.V.", "productid": "Philips-LWB010-1-A19DLv4"}} -lightTypes["LWB010"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LWB010"]["config"] = {"archetype": "classicbulb", "function": "mixed", "direction": "omnidirectional", "startup":{"mode":"safety","configured":True}} -lightTypes["LWB010"]["v1_static"]["capabilities"] = {"certified": True,"control": {"mindimlevel": 5000, "maxlumen": 806}, "streaming": {"renderer": False, "proxy": False}} -lightTypes["LWB010"]["device"] = {"certified": True, "manufacturer_name": "Signify Netherlands B.V.", "product_archetype": "classic_bulb", "product_name": "Color temperature light", "software_version": "1.104.2"} -lightTypes["LWB010"]["state"] = {"on": False, "bri": 254,"alert": "none", "mode": "homeautomation", "reachable": True} -lightTypes["LWB010"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} - -## Controlt Temp Hue Bulb -lightTypes["LTW001"] = {"v1_static": {"type": "Color temperature light", "manufacturername": "Signify Netherlands B.V.", "swversion": "1.104.2"}} -lightTypes["LTW001"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LTW001"]["v1_static"]["capabilities"] = {"certified": True,"control": {"mindimlevel": 1000,"maxlumen": 806,"ct": {"min": 153,"max": 454}},"streaming": {"renderer": False,"proxy": False}} -lightTypes["LTW001"]["config"] = {"archetype": "classicbulb","function": "functional","direction": "omnidirectional", "startup":{"mode":"safety","configured":True}} -lightTypes["LTW001"]["device"] = {"certified": True, "manufacturer_name": "Signify Netherlands B.V.", "product_archetype": "classic_bulb", "product_name": "Dimmable light", "software_version": "1.76.6"} -lightTypes["LTW001"]["state"] = {"on": False, "colormode": "ct", "alert": "none", "mode": "homeautomation", "reachable": True, "bri": 254, "ct": 230} -lightTypes["LTW001"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} +lightTypes["LWB010"] = {"v1_static":{"type":"Dimmable light", "manufacturername":"Signify Netherlands B.V.", "swversion":"1.50.2_r30933", "swconfigid":"322BB2EC", "productid":"Philips-LWB010-1-A19DLv4"}} +lightTypes["LWB010"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LWB010"]["config"] = {"archetype":"classicbulb", "function":"mixed", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":True}} +lightTypes["LWB010"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":5000, "maxlumen":806}, "streaming":{"renderer":False, "proxy":False}} +lightTypes["LWB010"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "product_archetype":"classic_bulb", "product_name":"Hue White B22", "software_version":"1.104.2"} +lightTypes["LWB010"]["state"] = {"on":False, "bri":254, "alert":"none", "mode":"homeautomation", "reachable":True} +lightTypes["LWB010"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} + +## Hue White GU10 +lightTypes["LWG001"] = {"v1_static":{"type":"Dimmable light", "manufacturername":"Signify Netherlands B.V.", "swversion":"1.46.13_r26312", "swconfigid":"ACCF4E76", "productid":"Philips-LWG001-1-GU10DLv1"}} +lightTypes["LWG001"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LWG001"]["config"] = {"archetype":"spotbulb", "function":"mixed", "direction":"downwards", "startup":{"mode":"safety", "configured":True}} +lightTypes["LWG001"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":5000, "maxlumen":400}, "streaming":{"renderer":False, "proxy":False}} +lightTypes["LWG001"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "product_archetype":"spot_bulb", "product_name":"Hue white spot", "software_version":"1.46.13_r26312"} +lightTypes["LWG001"]["state"] = {"on":False, "bri":254, "alert":"none", "mode":"homeautomation", "reachable":True} +lightTypes["LWG001"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} + +## Control Temp Hue Bulb +lightTypes["LTW001"] = {"v1_static":{"type":"Color temperature light", "manufacturername":"Signify Netherlands B.V.", "swversion":"1.104.2"}} +lightTypes["LTW001"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LTW001"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":1000, "maxlumen":806, "ct":{"min":153, "max":454}}, "streaming":{"renderer":False, "proxy":False}} +lightTypes["LTW001"]["config"] = {"archetype":"classicbulb", "function":"functional", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":True}} +lightTypes["LTW001"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "product_archetype":"classic_bulb", "product_name":"Dimmable light", "software_version":"1.76.6"} +lightTypes["LTW001"]["state"] = {"on":False, "colormode":"ct", "alert":"none", "mode":"homeautomation", "reachable":True, "bri":254, "ct":230} +lightTypes["LTW001"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} + +## Hue White Ambiance GU10 +lightTypes["LTW013"] = {"v1_static":{"type":"Color temperature light", "manufacturername":"Signify Netherlands B.V.", "productname":"Hue Ambiance spot", "swversion":"1.108.7", "swconfigid":"116B9B72", "productid":"Philips-LTW013-1-GU10CTv1"}} +lightTypes["LTW013"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LTW013"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":1000, "maxlumen":350, "ct":{"min":153, "max":454}}, "streaming":{"renderer":False, "proxy":False}} +lightTypes["LTW013"]["config"] = {"archetype":"spotbulb", "function":"functional", "direction":"downwards", "startup":{"mode":"safety", "configured":True}} +lightTypes["LTW013"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "model_id":"LTW013", "product_archetype":"spot_bulb", "product_name":"Hue White Ambiance GU10", "software_version":"1.108.7"} +lightTypes["LTW013"]["state"] = {"on":False, "colormode":"ct", "alert":"select", "mode":"homeautomation", "reachable":True, "bri":127, "ct":369} +lightTypes["LTW013"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} +lightTypes["LTW014"] = lightTypes["LTW013"] ## Hue Gradient TV Lightstrip -lightTypes["LCX002"] = {"v1_static": {"type": "Extended color light", "manufacturername": "Signify Netherlands B.V.", "productname": "Hue play gradient lightstrip","swversion": "1.104.2","swconfigid": "C74E5108","productid": "Philips-LCX002-1-LedStripPXv1"}} -lightTypes["LCX002"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-11-02T19:46:12"} -lightTypes["LCX002"]["v1_static"]["capabilities"] = {"certified": True,"control": {"mindimlevel": 100,"maxlumen": 1600,"colorgamuttype": "C","colorgamut": [[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]],"ct": {"min": 153,"max": 500}},"streaming": {"renderer": True,"proxy": True}} -lightTypes["LCX002"]["device"] = {"certified": True,"manufacturer_name": "Signify Netherlands B.V.","model_id": "LCX002","product_archetype": "hue_lightstrip_tv","product_name": "Hue play gradient lightstrip","software_version": "1.104.2"} -lightTypes["LCX002"]["state"] = {"on": False, "bri": 254,"hue": 8417,"sat": 140,"effect": "none","xy": [0.0,0.0],"ct": 366,"alert": "select","colormode": "ct","mode": "homeautomation","reachable": True, "gradient": {"points": []}} -lightTypes["LCX002"]["config"] = {"archetype": "huelightstriptv","function": "mixed","direction": "omnidirectional","startup": {"mode": "safety","configured": False}} -lightTypes["LCX002"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} +lightTypes["LCX002"] = {"v1_static":{"type":"Extended color light", "manufacturername":"Signify Netherlands B.V.", "productname":"Hue play gradient lightstrip", "swversion":"1.104.2", "swconfigid":"C74E5108", "productid":"Philips-LCX002-1-LedStripPXv1"}} +lightTypes["LCX002"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-11-02T19:46:12"} +lightTypes["LCX002"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":100, "maxlumen":1600, "colorgamuttype":"C", "colorgamut":[[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]], "ct":{"min":153, "max":500}}, "streaming":{"renderer":True, "proxy":True}} +lightTypes["LCX002"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "model_id":"LCX002", "product_archetype":"hue_lightstrip_tv", "product_name":"Hue play gradient lightstrip", "software_version":"1.104.2"} +lightTypes["LCX002"]["state"] = {"on":False, "bri":254, "hue":8417, "sat":140, "effect":"none", "xy":[0.0,0.0], "ct":366, "alert":"select", "colormode":"ct", "mode":"homeautomation", "reachable":True, "gradient":{"points":[]}} +lightTypes["LCX002"]["config"] = {"archetype":"huelightstriptv", "function":"mixed", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":False}} +lightTypes["LCX002"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} ## Hue Signe Gradient -lightTypes["915005987201"] = {"v1_static": {"type": "Extended color light", "manufacturername": "Signify Netherlands B.V.", "productname": "Signe gradient floor","swversion": "1.94.2","swconfigid": "DC0A18AF","productid": "4422-9482-0441_HG01_PSU03"}} -lightTypes["915005987201"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2022-01-13T22:54:51"} -lightTypes["915005987201"]["v1_static"]["capabilities"] = {"certified": True,"control": {"mindimlevel": 100,"maxlumen": 1600,"colorgamuttype": "C","colorgamut": [[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]],"ct": {"min": 153,"max": 500}},"streaming": {"renderer": True,"proxy": True}} -lightTypes["915005987201"]["device"] = {"certified": True,"hardware_platform_type": "100b-118","manufacturer_name": "Signify Netherlands B.V.","model_id": "915005987201","product_archetype": "hue_signe","product_name": "Signe gradient floor","software_version": "1.94.2"} -lightTypes["915005987201"]["state"] = {"on": False, "bri": 254,"hue": 8417,"sat": 140,"effect": "none","xy": [0.0,0.0],"ct": 366,"alert": "select","colormode": "ct","mode": "homeautomation","reachable": True, "gradient": {"points": []}} -lightTypes["915005987201"]["config"] = {"archetype": "huesigne","function": "decorative","direction": "horizontal","startup": {"mode": "safety","configured": False}} -lightTypes["915005987201"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} +lightTypes["915005987201"] = {"v1_static":{"type":"Extended color light", "manufacturername":"Signify Netherlands B.V.", "productname":"Signe gradient floor", "swversion":"1.94.2", "swconfigid":"DC0A18AF", "productid":"4422-9482-0441_HG01_PSU03"}} +lightTypes["915005987201"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2022-01-13T22:54:51"} +lightTypes["915005987201"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":100, "maxlumen":1600, "colorgamuttype":"C", "colorgamut":[[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]], "ct":{"min":153, "max":500}}, "streaming":{"renderer":True, "proxy":True}} +lightTypes["915005987201"]["device"] = {"certified":True, "hardware_platform_type":"100b-118", "manufacturer_name":"Signify Netherlands B.V.", "model_id":"915005987201", "product_archetype":"hue_signe", "product_name":"Signe gradient floor", "software_version":"1.94.2"} +lightTypes["915005987201"]["state"] = {"on":False, "bri":254, "hue":8417, "sat":140, "effect":"none", "xy":[0.0,0.0], "ct":366, "alert":"select", "colormode":"ct", "mode":"homeautomation", "reachable":True, "gradient":{"points":[]}} +lightTypes["915005987201"]["config"] = {"archetype":"huesigne", "function":"decorative", "direction":"horizontal", "startup":{"mode":"safety", "configured":False}} +lightTypes["915005987201"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} ## Hue Gradient Lightstrip -lightTypes["LCX004"] = {"v1_static": {"type": "Extended color light", "manufacturername": "Signify Netherlands B.V.", "productname": "Hue gradient lightstrip","swversion": "1.94.2","swconfigid": "DC0A18AF","productid": "4422-9482-0441_HG01_PSU03"}} -lightTypes["LCX004"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2022-01-13T22:54:51"} -lightTypes["LCX004"]["v1_static"]["capabilities"] = {"certified": True,"control": {"mindimlevel": 100,"maxlumen": 1600,"colorgamuttype": "C","colorgamut": [[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]],"ct": {"min": 153,"max": 500}},"streaming": {"renderer": True,"proxy": True}} -lightTypes["LCX004"]["device"] = {"certified": True,"hardware_platform_type": "100b-118","manufacturer_name": "Signify Netherlands B.V.","model_id": "LCX004","product_archetype": "hue_lightstrip","product_name": "Hue gradient lightstrip","software_version": "1.94.2"} -lightTypes["LCX004"]["state"] = {"on": False, "bri": 254,"hue": 8417,"sat": 140,"effect": "none","xy": [0.0,0.0],"ct": 366,"alert": "select","colormode": "ct","mode": "homeautomation","reachable": True, "gradient": {"points": []}} -lightTypes["LCX004"]["config"] = {"archetype": "huelightstrip", "function": "mixed", "direction": "omnidirectional","startup": {"mode": "safety","configured": False}} -lightTypes["LCX004"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} +lightTypes["LCX004"] = {"v1_static":{"type":"Extended color light", "manufacturername":"Signify Netherlands B.V.", "productname":"Hue gradient lightstrip", "swversion":"1.94.2", "swconfigid":"DC0A18AF", "productid":"4422-9482-0441_HG01_PSU03"}} +lightTypes["LCX004"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2022-01-13T22:54:51"} +lightTypes["LCX004"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":100, "maxlumen":1600, "colorgamuttype":"C", "colorgamut":[[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]], "ct":{"min":153, "max":500}}, "streaming":{"renderer":True, "proxy":True}} +lightTypes["LCX004"]["device"] = {"certified":True, "hardware_platform_type":"100b-118", "manufacturer_name":"Signify Netherlands B.V.", "model_id":"LCX004", "product_archetype":"hue_lightstrip", "product_name":"Hue gradient lightstrip", "software_version":"1.94.2"} +lightTypes["LCX004"]["state"] = {"on":False, "bri":254, "hue":8417, "sat":140, "effect":"none", "xy":[0.0,0.0], "ct":366, "alert":"select", "colormode":"ct", "mode":"homeautomation", "reachable":True, "gradient":{"points":[]}} +lightTypes["LCX004"]["config"] = {"archetype":"huelightstrip", "function":"mixed", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":False}} +lightTypes["LCX004"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} ## Hue Play Lightstrip -lightTypes["LCX006"] = {"v1_static": {"type": "Extended color light", "manufacturername": "Signify Netherlands B.V.", "productname": "Hue gradient lightstrip","swversion": "1.94.2","swconfigid": "DC0A18AF","productid": "4422-9482-0441_HG01_PSU03"}} -lightTypes["LCX006"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2022-01-13T22:54:51"} -lightTypes["LCX006"]["v1_static"]["capabilities"] = {"certified": True,"control": {"mindimlevel": 100,"maxlumen": 1600,"colorgamuttype": "C","colorgamut": [[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]],"ct": {"min": 153,"max": 500}},"streaming": {"renderer": True,"proxy": True}} -lightTypes["LCX006"]["device"] = {"certified": True,"hardware_platform_type": "100b-118","manufacturer_name": "Signify Netherlands B.V.","model_id": "LCX004","product_archetype": "hue_lightstrip","product_name": "Hue gradient lightstrip","software_version": "1.94.2"} -lightTypes["LCX006"]["state"] = {"on": False, "bri": 254,"hue": 8417,"sat": 140,"effect": "none","xy": [0.0,0.0],"ct": 366,"alert": "select","colormode": "ct","mode": "homeautomation","reachable": True, "gradient": {"points": []}} -lightTypes["LCX006"]["config"] = {"archetype": "huelightstrip", "function": "mixed", "direction": "omnidirectional","startup": {"mode": "safety","configured": False}} -lightTypes["LCX006"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]} - +lightTypes["LCX006"] = {"v1_static":{"type":"Extended color light", "manufacturername":"Signify Netherlands B.V.", "productname":"Hue gradient lightstrip", "swversion":"1.94.2", "swconfigid":"DC0A18AF", "productid":"4422-9482-0441_HG01_PSU03"}} +lightTypes["LCX006"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2022-01-13T22:54:51"} +lightTypes["LCX006"]["v1_static"]["capabilities"] = {"certified":True, "control":{"mindimlevel":100, "maxlumen":1600, "colorgamuttype":"C", "colorgamut":[[0.6915,0.3083],[0.1700,0.7000],[0.1532,0.0475]], "ct":{"min":153, "max":500}}, "streaming":{"renderer":True, "proxy":True}} +lightTypes["LCX006"]["device"] = {"certified":True, "hardware_platform_type":"100b-118", "manufacturer_name":"Signify Netherlands B.V.", "model_id":"LCX006", "product_archetype":"hue_lightstrip", "product_name":"Hue gradient lightstrip", "software_version":"1.94.2"} +lightTypes["LCX006"]["state"] = {"on":False, "bri":254, "hue":8417, "sat":140, "effect":"none", "xy":[0.0,0.0], "ct":366, "alert":"select", "colormode":"ct", "mode":"homeautomation", "reachable":True, "gradient":{"points":[]}} +lightTypes["LCX006"]["config"] = {"archetype":"huelightstrip", "function":"mixed", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":False}} +lightTypes["LCX006"]["dynamics"] = {"speed":0, "speed_valid":False, "status":"none", "status_values":["none", "dynamic_palette"]} ## Hue Plug -lightTypes["LOM001"] = {"v1_static": {"type": "On/Off plug-in unit","manufacturername": "Signify Netherlands B.V.","productname": "Hue Smart plug","swversion": "1.104.2","swconfigid": "A641B5AB","productid": "SmartPlug_OnOff_v01-00_01"}} -lightTypes["LOM001"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LOM001"]["v1_static"]["capabilities"] = {"certified": True,"control": {},"streaming": {"renderer": False,"proxy": False}} -lightTypes["LOM001"]["device"] = {"certified": True,"manufacturer_name": "Signify Netherlands B.V.", "model_id": "LOM001", "product_archetype": "plug","product_name": "Hue Smart plug","software_version": "1.104.2"} -lightTypes["LOM001"]["state"] = {"on": False,"alert": "select","mode": "homeautomation","reachable": True} -lightTypes["LOM001"]["config"] = {"archetype": "plug","function": "functional","direction": "omnidirectional","startup":{"mode": "safety","configured": True}} -lightTypes["LOM001"]["dynamics"] = {"status": "none", "status_values": ["none"]} - -lightTypes["LOM004"] = {"v1_static": {"type": "On/Off plug-in unit","manufacturername": "Signify Netherlands B.V.","productname": "Hue Smart plug","swversion": "1.104.2","swconfigid": "A641B5AB","productid": "SmartPlug_OnOff_v01-00_01"}} -lightTypes["LOM004"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LOM004"]["v1_static"]["capabilities"] = {"certified": True,"control": {},"streaming": {"renderer": False,"proxy": False}} -lightTypes["LOM004"]["device"] = {"certified": True,"manufacturer_name": "Signify Netherlands B.V.", "model_id": "LOM001", "product_archetype": "plug","product_name": "Hue Smart plug","software_version": "1.104.2"} -lightTypes["LOM004"]["state"] = {"on": False,"alert": "select","mode": "homeautomation","reachable": True} -lightTypes["LOM004"]["config"] = {"archetype": "plug","function": "functional","direction": "omnidirectional","startup":{"mode": "safety","configured": True}} -lightTypes["LOM004"]["dynamics"] = {"status": "none", "status_values": ["none"]} - -lightTypes["LOM010"] = {"v1_static": {"type": "On/Off plug-in unit","manufacturername": "Signify Netherlands B.V.","productname": "Hue Smart plug","swversion": "1.104.2","swconfigid": "A641B5AB","productid": "SmartPlug_OnOff_v01-00_01"}} -lightTypes["LOM010"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"} -lightTypes["LOM010"]["v1_static"]["capabilities"] = {"certified": True,"control": {},"streaming": {"renderer": False,"proxy": False}} -lightTypes["LOM010"]["device"] = {"certified": True,"manufacturer_name": "Signify Netherlands B.V.", "model_id": "LOM001", "product_archetype": "plug","product_name": "Hue Smart plug","software_version": "1.104.2"} -lightTypes["LOM010"]["state"] = {"on": False,"alert": "select","mode": "homeautomation","reachable": True} -lightTypes["LOM010"]["config"] = {"archetype": "plug","function": "functional","direction": "omnidirectional","startup":{"mode": "safety","configured": True}} -lightTypes["LOM010"]["dynamics"] = {"status": "none", "status_values": ["none"]} - +lightTypes["LOM001"] = {"v1_static":{"type":"On/Off plug-in unit", "manufacturername":"Signify Netherlands B.V.", "productname":"Hue Smart plug", "swversion":"1.104.2", "swconfigid":"A641B5AB", "productid":"SmartPlug_OnOff_v01-00_01"}} +lightTypes["LOM001"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LOM001"]["v1_static"]["capabilities"] = {"certified":True, "control":{}, "streaming":{"renderer":False, "proxy":False}} +lightTypes["LOM001"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "model_id":"LOM001", "product_archetype":"plug", "product_name":"Hue Smart plug", "software_version":"1.104.2"} +lightTypes["LOM001"]["state"] = {"on":False, "alert":"select", "mode":"homeautomation", "reachable":True} +lightTypes["LOM001"]["config"] = {"archetype":"plug", "function":"functional", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":True}} +lightTypes["LOM001"]["dynamics"] = {"status":"none", "status_values":["none"]} + +lightTypes["LOM004"] = {"v1_static":{"type":"On/Off plug-in unit", "manufacturername":"Signify Netherlands B.V.", "productname":"Hue Smart plug", "swversion":"1.104.2", "swconfigid":"A641B5AB", "productid":"SmartPlug_OnOff_v01-00_01"}} +lightTypes["LOM004"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LOM004"]["v1_static"]["capabilities"] = {"certified":True, "control":{}, "streaming":{"renderer":False, "proxy":False}} +lightTypes["LOM004"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "model_id":"LOM001", "product_archetype":"plug", "product_name":"Hue Smart plug", "software_version":"1.104.2"} +lightTypes["LOM004"]["state"] = {"on":False, "alert":"select", "mode":"homeautomation", "reachable":True} +lightTypes["LOM004"]["config"] = {"archetype":"plug", "function":"functional", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":True}} +lightTypes["LOM004"]["dynamics"] = {"status":"none", "status_values":["none"]} + +lightTypes["LOM010"] = {"v1_static":{"type":"On/Off plug-in unit", "manufacturername":"Signify Netherlands B.V.", "productname":"Hue Smart plug", "swversion":"1.104.2", "swconfigid":"A641B5AB", "productid":"SmartPlug_OnOff_v01-00_01"}} +lightTypes["LOM010"]["v1_static"]["swupdate"] = {"state":"noupdates", "lastinstall":"2020-12-09T19:13:52"} +lightTypes["LOM010"]["v1_static"]["capabilities"] = {"certified":True, "control":{}, "streaming":{"renderer":False, "proxy":False}} +lightTypes["LOM010"]["device"] = {"certified":True, "manufacturer_name":"Signify Netherlands B.V.", "model_id":"LOM001", "product_archetype":"plug", "product_name":"Hue Smart plug", "software_version":"1.104.2"} +lightTypes["LOM010"]["state"] = {"on":False, "alert":"select", "mode":"homeautomation", "reachable":True} +lightTypes["LOM010"]["config"] = {"archetype":"plug", "function":"functional", "direction":"omnidirectional", "startup":{"mode":"safety", "configured":True}} +lightTypes["LOM010"]["dynamics"] = {"status":"none", "status_values":["none"]} archetype = {"tableshade":"table_shade", "flexiblelamp":"flexible_lamp", @@ -154,4 +189,4 @@ "huecentris":"hue_centris", "huelightstriptv":"hue_lightstrip_tv", "huesigne":"hue_signe" - } +} diff --git a/BridgeEmulator/lights/protocols/hue.py b/BridgeEmulator/lights/protocols/hue.py index 26a381984..698e4c046 100644 --- a/BridgeEmulator/lights/protocols/hue.py +++ b/BridgeEmulator/lights/protocols/hue.py @@ -1,3 +1,4 @@ +from lights.light_types import lightTypes import json import logManager import requests @@ -5,7 +6,8 @@ logging = logManager.logger.get_logger(__name__) def set_light(light, data): - url = "http://" + light.protocol_cfg["ip"] + "/api/" + light.protocol_cfg["hueUser"] + "/lights/" + light.protocol_cfg["id"] + "/state" + protocol_cfg = light.protocol_cfg + url = "http://" + protocol_cfg["ip"] + "/api/" + protocol_cfg["hueUser"] + "/lights/" + protocol_cfg["id"] + "/state" payload = {} payload.update(data) color = {} @@ -22,30 +24,45 @@ def set_light(light, data): color["sat"] = payload["sat"] del(payload["sat"]) if len(payload) != 0: - requests.put(url, json=payload, timeout=3) + response = requests.put(url, json=payload, timeout=3) + logging.debug(response.text) if len(color) != 0: - requests.put(url, json=color, timeout=3) + response = requests.put(url, json=color, timeout=3) + logging.debug(response.text) def get_light_state(light): - state = requests.get("http://" + light.protocol_cfg["ip"] + "/api/" + light.protocol_cfg["hueUser"] + "/lights/" + light.protocol_cfg["id"], timeout=3) + protocol_cfg = light.protocol_cfg + state = requests.get("http://" + protocol_cfg["ip"] + "/api/" + protocol_cfg["hueUser"] + "/lights/" + protocol_cfg["id"], timeout=3) return state.json()["state"] def discover(detectedLights, credentials): if "hueUser" in credentials and len(credentials["hueUser"]) > 32: logging.debug("hue: invoked!") try: - response = requests.get("http://" + credentials["ip"] + "/api/" + credentials["hueUser"] + "/lights", timeout=3) + ip = credentials['ip'] + user = credentials['hueUser'] + response = requests.get("http://" + ip + "/api/" + user + "/lights", timeout=3) if response.status_code == 200: logging.debug(response.text) lights = json.loads(response.text) for id, light in lights.items(): - modelid = "LCT015" - if light["type"] == "Dimmable light": - modelid = "LWB010" - elif light["type"] == "Color temperature light": - modelid = "LTW001" - elif light["type"] == "On/Off plug-in unit": - modelid = "LOM001" - detectedLights.append({"protocol": "hue", "name": light["name"], "modelid": modelid, "protocol_cfg": {"ip": credentials["ip"], "hueUser": credentials["hueUser"], "modelid": light["modelid"], "id": id, "uniqueid": light["uniqueid"]}}) + if ('modelid' in light) and (light['modelid'] in lightTypes): + modelid = light['modelid'] + # elif ('productid' in light) : + # productid = light['productid'] --> Philips-LCG002-3-GU10ECLv2 + elif light['type'] == 'Extended color light': + modelid = 'LCG002' + elif light['type'] == 'Color temperature light': + modelid = 'LTW001' + elif light['type'] == 'Dimmable light': + modelid = 'LWB010' + elif light['type'] == 'On/Off plug-in unit': + modelid = 'LOM001' + else: + modelid = 'LCT001' + detectedLights.append({ + "protocol": "hue", "name": light["name"], "modelid": modelid, + "protocol_cfg": {"ip": ip, "hueUser": user, "modelid": light['modelid'], "id": id, "uniqueid": light["uniqueid"]} + }) except Exception as e: logging.info("Error connecting to Hue Bridge: %s", e)