diff --git a/BridgeEmulator/HueObjects/__init__.py b/BridgeEmulator/HueObjects/__init__.py index 7fc10c684..f487a47eb 100644 --- a/BridgeEmulator/HueObjects/__init__.py +++ b/BridgeEmulator/HueObjects/__init__.py @@ -1023,6 +1023,10 @@ def update_attr(self, newdata): 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" } @@ -1062,12 +1066,17 @@ def genStreamEvent(self, v2State): 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"}], + "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.update(v2State) + streamMessage["data"][0].update(v2State) eventstream.append(streamMessage) def getV1Api(self): diff --git a/BridgeEmulator/services/homeAssistantWS.py b/BridgeEmulator/services/homeAssistantWS.py index 391749263..427bbab5b 100644 --- a/BridgeEmulator/services/homeAssistantWS.py +++ b/BridgeEmulator/services/homeAssistantWS.py @@ -214,7 +214,7 @@ def _send(self, payload): def connect_if_required(): if homeassistant_ws_client is None or homeassistant_ws_client.client_terminated: create_websocket_client() - + return homeassistant_ws_client @@ -274,7 +274,7 @@ def discover(detectedLights): for entity_id in latest_states.keys(): ha_state = latest_states[entity_id] device_new = True - lightName = ha_state["attributes"]["friendly_name"] if ha_state["attributes"]["friendly_name"] is not None else entity_id + lightName = ha_state["attributes"]["friendly_name"] if "friendly_name" in ha_state["attributes"] else entity_id logging.info("HomeAssistant_ws: found light {}".format(lightName)) # From Home Assistant lights/__init.py__