diff --git a/BridgeEmulator/HueObjects/Group.py b/BridgeEmulator/HueObjects/Group.py index 6e8b81cdc..731ab0d00 100644 --- a/BridgeEmulator/HueObjects/Group.py +++ b/BridgeEmulator/HueObjects/Group.py @@ -15,7 +15,7 @@ def __init__(self, data): self.id_v2 = data["id_v2"] if "id_v2" in data else genV2Uuid() if "owner" in data: self.owner = data["owner"] - self.icon_class = data["class"] if "class" in data else "Other" + self.icon_class = data["class"] if "class" in data else data["icon_class"] if "icon_class" in data else "Other" 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"} diff --git a/BridgeEmulator/flaskUI/restful.py b/BridgeEmulator/flaskUI/restful.py index 9276fa312..ef3d8250d 100644 --- a/BridgeEmulator/flaskUI/restful.py +++ b/BridgeEmulator/flaskUI/restful.py @@ -89,7 +89,7 @@ def post(self): response[0]["success"]["clientkey"] = client_key bridgeConfig["apiUsers"][username] = ApiUser.ApiUser(username, postDict["devicetype"], client_key) - logging.debug(response) + logging.info(response) configManager.bridgeConfig.save_config() return response else: @@ -173,6 +173,10 @@ def post(self, username, resource): elif postDict["type"] == "Room": v2Resource = "room" bridgeConfig[resource][new_object_id] = Group.Group(postDict) + elif postDict["type"] == "LightGroup": + postDict["type"] = "Zone" + v2Resource = "zone" + bridgeConfig[resource][new_object_id] = Group.Group(postDict) elif postDict["type"] == "Entertainment": v2Resource = "entertainment_configuration" bridgeConfig[resource][new_object_id] = EntertainmentConfiguration.EntertainmentConfiguration(postDict) diff --git a/BridgeEmulator/flaskUI/v2restapi.py b/BridgeEmulator/flaskUI/v2restapi.py index e58f86fea..f96cda833 100644 --- a/BridgeEmulator/flaskUI/v2restapi.py +++ b/BridgeEmulator/flaskUI/v2restapi.py @@ -576,6 +576,8 @@ def get(self, resource, resourceid): return {"errors": [], "data": [object.getV2Api()]} elif resource == "room": return {"errors": [], "data": [object.getV2Room()]} + elif resource == "zone": + return {"errors": [], "data": [object.getV2Zone()]} elif resource == "grouped_light": return {"errors": [], "data": [object.getV2GroupedLight()]} elif resource == "device": diff --git a/BridgeEmulator/functions/scripts.py b/BridgeEmulator/functions/scripts.py index a55dd8b59..0ea84aea4 100644 --- a/BridgeEmulator/functions/scripts.py +++ b/BridgeEmulator/functions/scripts.py @@ -18,10 +18,11 @@ def findScene(element): def findGroup(id_v2): for group, obj in bridgeConfig["groups"].items(): - if obj.getV2Room()["id"] == id_v2: - return obj - elif obj.getV2Zone()["id"] == id_v2: - return obj + if obj.type != "Entertainment": + if obj.getV2Room()["id"] == id_v2: + return obj + elif obj.getV2Zone()["id"] == id_v2: + return obj return False def triggerScript(behavior_instance): diff --git a/BridgeEmulator/services/entertainment.py b/BridgeEmulator/services/entertainment.py index 10367fb68..5ddae7e30 100644 --- a/BridgeEmulator/services/entertainment.py +++ b/BridgeEmulator/services/entertainment.py @@ -68,7 +68,7 @@ def entertainmentService(group, user): hueGroupLights = {} prev_frame_time = 0 new_frame_time = 0 - prev_frameID = 0 + non_UDP_update_counter = 0 for light in group.lights: lights_v1[int(light().id_v1)] = light() if light().protocol == "hue" and get_hue_entertainment_group(light(), group.name) != -1: # If the lights' Hue bridge has an entertainment group with the same name as this current group, we use it to sync the lights. @@ -103,6 +103,7 @@ def entertainmentService(group, user): p.stdout.read(1) # read one byte so the init function will correctly detect the frameBites try: while bridgeConfig["groups"][group.id_v1].stream["active"]: + new_frame_time = time.time() if not init: readByte = p.stdout.read(1) logging.debug(readByte) @@ -125,7 +126,6 @@ def entertainmentService(group, user): mqttLights = [] wledLights = {} non_UDP_lights = [] - non_UDP_update_counter = 0 if data[:9].decode('utf-8') == "HueStream": i = 0 apiVersion = 0 @@ -292,11 +292,9 @@ def entertainmentService(group, user): light.setV1State({"xy": light.state["xy"], "transitiontime": 3}) non_UDP_update_counter = non_UDP_update_counter + 1 if non_UDP_update_counter < len(non_UDP_lights)-1 else 0 - new_frame_time = time.time() if new_frame_time - prev_frame_time > 1: - fps = frameID - prev_frameID + fps = 1.0 / (time.time() - new_frame_time) prev_frame_time = new_frame_time - prev_frameID = frameID logging.info("Entertainment FPS: " + str(fps)) else: logging.info("HueStream was missing in the frame")