Skip to content

Commit 9a783b2

Browse files
authored
HA switches (diyhue#1018)
1 parent 408652b commit 9a783b2

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

BridgeEmulator/services/homeAssistantWS.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,18 @@ def subscribe_for_updates(self):
109109
def change_light(self, light, data):
110110
service_data = {}
111111
service_data['entity_id'] = light.protocol_cfg['entity_id']
112-
113-
payload = {
114-
"type": "call_service",
115-
"domain": "light",
116-
"service_data": service_data
117-
}
118-
112+
if light.protocol_cfg['entity_id'].startswith("light."):
113+
payload = {
114+
"type": "call_service",
115+
"domain": "light",
116+
"service_data": service_data
117+
}
118+
elif light.protocol_cfg['entity_id'].startswith("switch."):
119+
payload = {
120+
"type": "call_service",
121+
"domain": "switch",
122+
"service_data": service_data
123+
}
119124
payload["service"] = "turn_on"
120125
if 'on' in data:
121126
if not data['on']:
@@ -183,7 +188,7 @@ def _should_include(self, ha_state):
183188
should_include = False
184189
diy_hue_flag = None
185190
entity_id = ha_state.get('entity_id', None)
186-
if entity_id.startswith("light."):
191+
if entity_id.startswith("light.") or entity_id.startswith("switch."):
187192
if 'attributes' in ha_state and 'diyhue' in ha_state['attributes']:
188193
diy_hue_flag = ha_state['attributes']['diyhue']
189194

0 commit comments

Comments
 (0)