From 68e3e8eb56a70471c8ee4145a5e2ca6b22350fac Mon Sep 17 00:00:00 2001 From: Paalap <42343574+Paalap@users.noreply.github.com> Date: Thu, 27 Jun 2024 09:54:52 +0200 Subject: [PATCH 1/3] Option for strictly use of xy color I've experienced an issue with some third party devices on the hue bridge, as they would not work with rgb or hsv. A manual entry of strictusexy = true in the light's protocol config allows you to fix this issue. --- BridgeEmulator/lights/protocols/hue.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/BridgeEmulator/lights/protocols/hue.py b/BridgeEmulator/lights/protocols/hue.py index 26a381984..95487af79 100644 --- a/BridgeEmulator/lights/protocols/hue.py +++ b/BridgeEmulator/lights/protocols/hue.py @@ -9,6 +9,20 @@ def set_light(light, data): payload = {} payload.update(data) color = {} + if "strictusexy" in light.protocol_cfg and light.protocol_cfg["strictusexy"] and ("sat" in payload or "hue" in payload): + if "sat" in payload and "hue" in payload: + rgb = hsv_to_rgb(payload["hue"], payload["sat"], light.state["bri"]) + del(payload["sat"]) + del(payload["hue"]) + elif "hue" in payload: + rgb = hsv_to_rgb(payload["hue"], light.state["sat"], light.state["bri"]) + del(payload["hue"]) + elif "sat" in payload: + rgb = hsv_to_rgb(light.state["hue"], payload["sat"], light.state["bri"]) + del(payload["sat"]) + xy = convert_rgb_xy(rgb[0],rgb[1],rgb[2]) + color["colormode"] = 'xy' + color["xy"] = [xy[0], xy[1]] if "xy" in payload: color["xy"] = payload["xy"] del(payload["xy"]) From 591894f4a6e34c5e5907e76f0d2b6c7753d55548 Mon Sep 17 00:00:00 2001 From: Paalap <42343574+Paalap@users.noreply.github.com> Date: Sun, 30 Jun 2024 17:57:17 +0200 Subject: [PATCH 2/3] forgot to include functions.colors --- BridgeEmulator/lights/protocols/hue.py | 1 + 1 file changed, 1 insertion(+) diff --git a/BridgeEmulator/lights/protocols/hue.py b/BridgeEmulator/lights/protocols/hue.py index 95487af79..1760a98bc 100644 --- a/BridgeEmulator/lights/protocols/hue.py +++ b/BridgeEmulator/lights/protocols/hue.py @@ -1,6 +1,7 @@ import json import logManager import requests +from functions.colors import hsv_to_rgb, convert_rgb_xy logging = logManager.logger.get_logger(__name__) From f27fc3f8aa5d30f5e9e8d2653c5eefcffd17c434 Mon Sep 17 00:00:00 2001 From: Mark Hendriksen Date: Mon, 1 Jul 2024 09:40:04 +0200 Subject: [PATCH 3/3] Update hue.py --- BridgeEmulator/lights/protocols/hue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BridgeEmulator/lights/protocols/hue.py b/BridgeEmulator/lights/protocols/hue.py index 1760a98bc..8993d8793 100644 --- a/BridgeEmulator/lights/protocols/hue.py +++ b/BridgeEmulator/lights/protocols/hue.py @@ -61,6 +61,6 @@ def discover(detectedLights, credentials): 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"]}}) + 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"], "strictusexy": False}}) except Exception as e: logging.info("Error connecting to Hue Bridge: %s", e)