Skip to content

Commit

Permalink
Add XY light, Fix NoneType
Browse files Browse the repository at this point in the history
Add XY light(https://diyhue.discourse.group/t/hue-iris-llc010)
Fix unsupported operand type(s) for /: 'NoneType' and 'int'
  • Loading branch information
hendriksen-mark committed Oct 26, 2024
1 parent 4117a2a commit 58aa81c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 8 deletions.
4 changes: 2 additions & 2 deletions BridgeEmulator/HueObjects/Light.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def getV1Api(self):
result["state"] = {"on": self.state["on"]}
if "bri" in self.state and self.modelid not in ["LOM001", "LOM004", "LOM010"]:
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 self.modelid not in ["LOM001", "LOM004", "LOM010", "LTW001", "LLC010"]:
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"]:
Expand Down Expand Up @@ -291,7 +291,7 @@ def getV2Api(self):
"points_capable": self.protocol_cfg["points_capable"]}

# color lights only
if self.modelid in ["LST002", "LCT001", "LCT015", "LCX002", "915005987201", "LCX004", "LCX006", "LCA005"]:
if self.modelid in ["LST002", "LCT001", "LCT015", "LCX002", "915005987201", "LCX004", "LCX006", "LCA005", "LLC010"]:
colorgamut = lightTypes[self.modelid]["v1_static"]["capabilities"]["control"]["colorgamut"]
result["color"] = {
"gamut": {
Expand Down
2 changes: 1 addition & 1 deletion BridgeEmulator/HueObjects/Sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def getTemperature(self):
"temperature": {
"temperature_report":{
"changed": self.state["lastupdated"],
"temperature": self.state["temperature"]/100
"temperature": self.state["temperature"]/100 if type(self.state["temperature"]) == int else self.state["temperature"]
}
},
"owner": {
Expand Down
9 changes: 9 additions & 0 deletions BridgeEmulator/lights/light_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
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 Iris
lightTypes["LLC010"] = {"v1_static": {"type": "Color Gamut light", "manufacturername": "Signify Netherlands B.V.", "swversion": "1.104.2"}}
lightTypes["LLC010"]["v1_static"]["swupdate"] = {"state": "noupdates","lastinstall": "2020-12-09T19:13:52"}
lightTypes["LLC010"]["v1_static"]["capabilities"] = {"certified": True,"control": {"colorgamut": [[0.704,0.296],[0.215,0.711],[0.138,0.08]],"colorgamuttype": "A","maxlumen": 600,"mindimlevel": 5000},"streaming": {"renderer": False,"proxy": False}}
lightTypes["LLC010"]["config"] = {"archetype": "hueiris","function": "functional","direction": "omnidirectional", "startup":{"mode":"safety","configured":True}}
lightTypes["LLC010"]["device"] = {"certified": True, "manufacturer_name": "Signify Netherlands B.V.", "product_archetype": "hueiris", "product_name": "Dimmable light", "software_version": "1.76.6"}
lightTypes["LLC010"]["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["LLC010"]["dynamics"] = {"speed": 0, "speed_valid": False, "status": "none", "status_values": ["none", "dynamic_palette"]}

## 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"}
Expand Down
2 changes: 2 additions & 0 deletions BridgeEmulator/lights/protocols/deconz.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def discover(detectedLights, credentials):
modelid = "LTW001"
elif light["type"] == "On/Off plug-in unit":
modelid = "LOM001"
elif light["type"] == "Color light":
modelid = "LLC010"
detectedLights.append({"protocol": "deconz", "name": light["name"], "modelid": modelid, "protocol_cfg": {"ip": credentials["deconzHost"] + ":" + str(credentials["deconzPort"]), "deconzUser": credentials["deconzUser"], "modelid": light["modelid"], "deconzId": id, "uniqueid": light["uniqueid"]}})
except Exception as e:
logging.info("Error connecting to Deconz: %s", e)
2 changes: 2 additions & 0 deletions BridgeEmulator/lights/protocols/hue.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def discover(detectedLights, credentials):
modelid = "LTW001"
elif light["type"] == "On/Off plug-in unit":
modelid = "LOM001"
elif light["type"] == "Color light":
modelid = "LLC010"
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"]}})
except Exception as e:
logging.info("Error connecting to Hue Bridge: %s", e)
2 changes: 2 additions & 0 deletions BridgeEmulator/lights/protocols/yeelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def discover(detectedLights):
modelid = "LCT015"
elif light["capabilities"]["ct"]:
modelid = "LTW001"
elif light["capabilities"]["xy"]:
modelid = "LLC010"
detectedLights.append({"protocol": "yeelight", "name": light["capabilities"]["name"] if light["capabilities"]["name"] != '' else 'Yeelight ' + light["capabilities"]["id"], "modelid": modelid, "protocol_cfg": {"ip": light["ip"], "id": light["capabilities"]["id"], "backlight": False, "model": light["capabilities"]["model"]}})

return detectedLights
Expand Down
9 changes: 7 additions & 2 deletions BridgeEmulator/services/homeAssistantWS.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,19 @@ def discover(detectedLights):
supported_colourmodes = ha_state.get('attributes', {}).get('supported_color_modes', [])

model_id = None
if HS in supported_colourmodes or XY in supported_colourmodes or RGB in supported_colourmodes or RGBW in supported_colourmodes or RGBWW in supported_colourmodes:
if HS in supported_colourmodes or XY in supported_colourmodes or RGB in supported_colourmodes or RGBW in supported_colourmodes or RGBWW in supported_colourmodes and COLOR_TEMP in supported_colourmodes:
model_id = "LCT015"
elif COLOR_TEMP in supported_colourmodes:
model_id = "LTW001"
elif XY in supported_colourmodes:
model_id = "LLC010"
elif BRIGHTNESS in supported_colourmodes:
model_id = "LWB010"
else:
elif ONOFF in supported_colourmodes and not BRIGHTNESS in supported_colourmodes:
model_id = "LOM001"
else:
logging.info("unknown model id " + str(supported_colourmodes))
continue

protocol_cfg = {"entity_id": entity_id,
"ip": "none"}
Expand Down
8 changes: 5 additions & 3 deletions BridgeEmulator/services/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,16 @@ def on_autodiscovery_light(msg):

# Device capabilities
keys = data.keys()
light_color = "xy" in keys and data["xy"] == True
light_xy = "xy" in keys and data["xy"] == True
light_brightness = "brightness" in keys and data["brightness"] == True
light_ct = "color_temp" in keys and data["color_temp"] == True

modelid = None
if light_color and light_ct:
if light_xy and light_ct:
modelid = "LCT015"
elif light_color: # Every light as LCT001? Or also support other lights
elif light_xy and not light_ct:
modelid = "LLC010"
elif light_xy: # Every light as LCT001? Or also support other lights
modelid = "LCT001"
elif light_ct:
modelid = "LTW001"
Expand Down

0 comments on commit 58aa81c

Please sign in to comment.