From 55152478fbbf003311b315d0db6bba24f85f391c Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 24 Nov 2024 13:05:44 +0100 Subject: [PATCH] Add effect_v2 Update light effects to effects_v2. Add effects to mqtt. https://github.com/diyhue/diyHue/issues/1053 --- BridgeEmulator/HueObjects/Light.py | 3 +++ BridgeEmulator/configManager/configHandler.py | 4 ++-- BridgeEmulator/flaskUI/restful.py | 4 +++- BridgeEmulator/lights/protocols/mqtt.py | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/BridgeEmulator/HueObjects/Light.py b/BridgeEmulator/HueObjects/Light.py index 265d214f4..005d6534e 100644 --- a/BridgeEmulator/HueObjects/Light.py +++ b/BridgeEmulator/HueObjects/Light.py @@ -186,6 +186,9 @@ def setV1State(self, state, advertise=True): def setV2State(self, state): v1State = v2StateToV1(state) + if "effects_v2" in state and "action" in state["effects_v2"]: + v1State["effect"] = state["effects_v2"]["action"]["effect"] + self.effect = v1State["effect"] if "effects" in state: v1State["effect"] = state["effects"]["effect"] self.effect = v1State["effect"] diff --git a/BridgeEmulator/configManager/configHandler.py b/BridgeEmulator/configManager/configHandler.py index f49e64486..f13958742 100644 --- a/BridgeEmulator/configManager/configHandler.py +++ b/BridgeEmulator/configManager/configHandler.py @@ -346,9 +346,9 @@ def download_debug(self): debug["apiUsers"] = "privately" debug["Hue Essentials key"] = "privately" debug["users"] = "privately" - if debug["mqtt"]["enabled"]: + if debug["mqtt"]["enabled"] or "mqttPassword" in debug["mqtt"]: debug["mqtt"]["mqttPassword"] = "privately" - if debug["homeassistant"]["enabled"]: + if debug["homeassistant"]["enabled"] or "homeAssistantToken" in debug["homeassistant"]: debug["homeassistant"]["homeAssistantToken"] = "privately" if debug["hue"]: debug["hue"]["hueUser"] = "privately" diff --git a/BridgeEmulator/flaskUI/restful.py b/BridgeEmulator/flaskUI/restful.py index 9e277eee5..d37d39857 100644 --- a/BridgeEmulator/flaskUI/restful.py +++ b/BridgeEmulator/flaskUI/restful.py @@ -95,7 +95,9 @@ def post(self): else: logging.error("link button not pressed") logging.error("last_button_press " + str(last_button_press)) - logging.error("current time " + str(datetime.now().timestamp())) + logging.error("current_time " + str(datetime.now().timestamp())) + if last_button_press != datetime.now().timestamp(): + logging.error("last_button_press is not current_time, please check timezone setting") return [{"error": {"type": 101, "address": "/api/", "description": "link button not pressed"}}] else: logging.error("parameter, " + list(postDict.keys())[0] + ", not available") diff --git a/BridgeEmulator/lights/protocols/mqtt.py b/BridgeEmulator/lights/protocols/mqtt.py index 09c88ce45..05c32a3bf 100755 --- a/BridgeEmulator/lights/protocols/mqtt.py +++ b/BridgeEmulator/lights/protocols/mqtt.py @@ -44,6 +44,8 @@ def set_light(light, data): payload['alert'] = value if key == "transitiontime": payload['transition'] = value / 10 + if key == "effect": + payload["effect"] = value if colorFromHsv: color = hsv_to_rgb(data['hue'], data['sat'], light.state["bri"]) payload['color'] = { 'r': color[0], 'g': color[1], 'b': color[2] }