Open jritsema opened 1 month ago
Hi,
Yes, we import just the lights because we can emulate them in Hue lights, but other entities (like switches) we don't have a common Hue device in witch these can be emulated. Probably we can emulate the binary switches in Hue plugs....
Hi, its possible by adjusting/editing services/homeAssistantWS.py
Original
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 } payload["service"] = "turn_on" if 'on' in data: if not data['on']: payload["service"] = "turn_off"
my version
def change_light(self, light, data): service_data = {} service_data['entity_id'] = light.protocol_cfg['entity_id'] 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']: payload["service"] = "turn_off"
And also from
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."):
to
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.") or entity_id.startswith("switch."):
This is working fine for me
To make it easier: https://github.com/Paalap/diyHue-1/blob/master/BridgeEmulator/services/homeAssistantWS.py
Hi,
Please create a pull request to master branch with your changes to be more easy to follow.
Wow, this is great! Thank you for the extremely fast turnaround 👍
Just to confirm, I can see that this code change brings switches into diyHue, but has someone verified that diyHue is enable to successfully turn them on/off?
Also, btw, in case it helps others. I got this working using the HASS "Switch as X" Helper, but with this change, I'll be able to remove all of that configuration 🎉
Feature does not already exist?
I searched and did not find an existing feature request
Summarize feature
Hello. Thank you for this very useful project! When trying to import all of my lights from Home Assistant, I noticed that it only seems to import devices of type
"light"
and devices of type"switch"
are not imported, even though I have setdiyhue: include
on them in mycustomize.yaml
. Is this intentional behavior? If so, are there any workarounds?