nikshriv / cync_lights

Home Assistant Integration for controlling Cync switches, plugs, and bulbs
160 stars 53 forks source link

Identify Device Unaviable/Powered Off as "Off" #23

Open kevomaco opened 1 year ago

kevomaco commented 1 year ago

My devices work correctly with the integration (thanks!), however my automations aren't working because I would like to trigger something when the device is turned on at the switch, meaning from powered off to powered on. Looking at the History in Home Assistant, it appears that powering off the devices doesn't switch them to the "off" state in Home Assistant. Turning them off in the Cync app does.

I'm wondering if it's possible to either have a powered off device marked as "off" in HA, or if there's some other way to detect going from powered off/unavailable to powered on for this automation to work.

nikshriv commented 1 year ago

I'm not sure what you're requesting. The switches work just like any other switch in HA. Power state is reported as "off" when lights are off and "on" when lights are on. I have a couple of automations based on the power state of these devices and they work without issue. Can you give me more detail about what's going on? I would check to see if there is some other error causing your automation to fail.

kevomaco commented 1 year ago

I think a misunderstanding of some details of Home Assistant cased me to word this poorly. I'd like to see the Cync bulbs register the "unavailable" state in HA, which they don't seem to currently do.

I have a set of Direct Connect bulbs connected to dumb switches. I don't have any Cync switches due to living in an apartment. When I use the dumb switches to turn off the bulbs, the Cync app registers them as "unavailable", but the state in HA stays the way it was, i.e. "on". Then, when I turn on the bulbs at the switch, any "when device turns on" automation fails, because the state is still "on". I used the developer tools to check the state, and there are other devices that register an "unavailable" state, so I'm wondering if it's possible to grab the "unavailable" state from the Cync app and have it show up in HA.

kevomaco commented 1 year ago

I'm seeing the "LostConnection" error in my log.

nikshriv commented 1 year ago

Got it. Yes, connection status is a bit complicated. I haven't completely worked that out. I am able to detect whether devices are connected by WiFi and responding to commands from the Cync server, but there is no obvious way to detect if the power to the device has been lost (such as when turning off the "dumb" switch that controls your bulbs). When these devices are not responsive to Cync server commands, the commands are routed to another WiFi connected device that is part of the same bluetooth mesh so that commands still go through, so even if a bulb can't be reached by WiFi, it is still "available" via bluetooth mesh.

One possibility would be for the integration to create sensors for each WiFi capable device that indicate whether or not the devices are reachable by WiFi. You could use the sensor for your automation. However, you may get some false negatives. Unfortunately, these Cync devices are pretty quirky.

kevomaco commented 1 year ago

These are direct connect bulbs, is there still a Bluetooth mesh?

I see that the Cync app registers them as unavailable. Is that status not in the packets/data you're receiving?

I tried forking the repo and installing it to the packet data to the log, but I kept getting the LostConnection error, both with the forked and original repo.

zackwithak13 commented 9 months ago

@kevomaco Did you ever figure out how to make this work?

kevomaco commented 7 months ago

@zackwithak13 No, I haven't discovered anything new.