Skip to content

Commit

Permalink
HA switches (#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paalap authored May 28, 2024
1 parent 408652b commit 9a783b2
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions BridgeEmulator/services/homeAssistantWS.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,18 @@ def subscribe_for_updates(self):
def change_light(self, light, data):
service_data = {}
service_data['entity_id'] = light.protocol_cfg['entity_id']

payload = {
"type": "call_service",
"domain": "light",
"service_data": service_data
}

if light.protocol_cfg['entity_id'].startswith("light."):
payload = {
"type": "call_service",
"domain": "light",
"service_data": service_data
}
elif light.protocol_cfg['entity_id'].startswith("switch."):
payload = {
"type": "call_service",
"domain": "switch",
"service_data": service_data
}
payload["service"] = "turn_on"
if 'on' in data:
if not data['on']:
Expand Down Expand Up @@ -183,7 +188,7 @@ def _should_include(self, ha_state):
should_include = False
diy_hue_flag = None
entity_id = ha_state.get('entity_id', None)
if entity_id.startswith("light."):
if entity_id.startswith("light.") or entity_id.startswith("switch."):
if 'attributes' in ha_state and 'diyhue' in ha_state['attributes']:
diy_hue_flag = ha_state['attributes']['diyhue']

Expand Down

0 comments on commit 9a783b2

Please sign in to comment.