nikshriv / cync_lights

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

Can't Update Devices, but Read works #9

Closed halfskye closed 1 year ago

halfskye commented 1 year ago

I can't seem to get my devices or entities to update (changing on/off state, color, brightness, etc on the dashboard), but when I modify the devices (via wireless switches, wireless remotes, and CYNC app) the devices reflect the changed state on the dashboard.

When I try to change on/off state, the toggle control toggles back to its original state a moment later. When I attempt to change brightness or color, the new setting remains in the UI but it doesn't modify the device itself. These UI settings revert back to their actual current state when I close the device pop-up and reopen it again.

For reference, I've got quite a few CYNC light bulbs (direct connect I believe), a few plugs, several wireless dimmable light switches, and several wireless dimmable light remotes all throughout my house. I figured the switches and remotes would work as the prerequisite Wi-Fi switch, but maybe it's only for the wired switches?

Thank you so very much for creating this integration by the way. This is my first foray into Home Assistant. I'm just about ready to chuck my CYNC devices in the garbage because of their general unresponsiveness. buggy-ness, etc. I'm hoping this integration can save my sanity.

nikshriv commented 1 year ago

Try running the script at GitHub.com/nikshriv/cync_data and post the result in this thread. The script can be run on any computer with Python, not on your Home Assistant instance.

I am having trouble supporting the plug devices at the moment and have been working on this in issue #7.

It's possible that the direct connect bulbs and plugs are using a slightly different protocol than my switches.

The way I have figured out the protocol so far involves doing a packet capture from the android app (can't do this on iOS). If you are using the android app, perhaps you can do a packet capture and send me the result. The app I used is called PCAPdroid. You can set it to capture packets while changing the state of your devices from the Cync app and save the results as a file. Then send the pcap file to me privately. Don't post that publicly.

christopherharper77 commented 1 year ago

I am also having this problem. Do you still need a packet capture?

nikshriv commented 1 year ago

They would be great. Do you have direct connect bulbs? If you can do a packet capture while operating your bulbs from the Cync app that would be very helpful. So a mix of turning on/off, changing brightness, rgb color, and color temp on rooms and on individual bulbs that would help a lot. Also, if you can let me know the order in which you perform those actions, it would make it easier to parse. Also, run my cync_data.py script so I can refer to the configuration.

nikshriv commented 1 year ago

New update should fix these issues. Please let me know if it works

halfskye commented 1 year ago

Novice here so apologies in advance if I flubbed something, but after the update and restart (cleared browser cache too), all the CYNC devices are now grayed out and no longer interactable in Overview.

Apologies for not supplying an Android capture myself (new town, new first baby here). Will try to get one out by this weekend.

nikshriv commented 1 year ago

My guess is that you didn’t delete your prior installation and reinstall after the update. The integration changed a fair amount and probably broke your old installation. Try deleting it and reinstall.

halfskye commented 1 year ago

Digging just a tad more, it seems it's reporting the devices are no longer associated with my Cync account. Trying to reauthorize through the "Reload Cync Configuration" pop-up leads to a "Unknown error occurred" message.

Will try to keep poking around a bit here.

halfskye commented 1 year ago

Ah, just saw your last comment. Will try to do that.

rubicon commented 1 year ago

I just discovered that I had one wired On/Off Switch (No Neutral Required) work, and the other two did not. The one that worked had firmware v1.5.590, and the two that did not have v1.5.613. The Cync app then updated the one that worked to v1.5.613, and it no longer worked.

I don’t know if the change logs (if you can access them) might give you insight into what changed. But the bios update seems to be the reason for the issue.

halfskye commented 1 year ago

Got my CYNC devices hooked back up but I'm unfortunately still unable to turn them on/off, change RGB, or color temperature. The Office room where I'm testing has "Full Color Direct Connect Smart Bulb (BR30 Floodlight)" devices and they are on firmware 1.0.313, for reference.

Will try to get a capture out by this weekend.

nikshriv commented 1 year ago

That's strange. I assume the switches work while using the app? I don't think the firmware update should have caused the integration to fail unless they changed something very fundamental which i doubt.

If you're still logged into the app, that might be the reason for the switches not working. The Cync server seems to only allow one connection at a time, so it kicks off the HA integration when you log into the app. The integration attempts to reconnect every 15 seconds, so once you log out, it should reconnect.

You might try deleting your installation and reinstalling. There have been some changes that may have broken your current installation.

rubicon commented 1 year ago

That's strange. I assume the switches work while using the app? I don't think the firmware update should have caused the integration to fail unless they changed something very fundamental which i doubt.

I still think it may be firmware as the one switch worked until the firmware was updated.

If you're still logged into the app, that might be the reason for the switches not working. The Cync server seems to only allow one connection at a time, so it kicks off the HA integration when you log into the app. The integration attempts to reconnect every 15 seconds, so once you log out, it should reconnect.

I made sure I was out of the app, but it didn't change the behavior.

You might try deleting your installation and reinstalling. There have been some changes that may have broken your current installation.

I have deleted it, but it has not changed the behavior.

Appreciate you working on this!

nikshriv commented 1 year ago

That's strange. I assume the switches work while using the app? I don't think the firmware update should have caused the integration to fail unless they changed something very fundamental which i doubt.

I still think it may be firmware as the one switch worked until the firmware was updated.

If you're still logged into the app, that might be the reason for the switches not working. The Cync server seems to only allow one connection at a time, so it kicks off the HA integration when you log into the app. The integration attempts to reconnect every 15 seconds, so once you log out, it should reconnect.

I made sure I was out of the app, but it didn't change the behavior.

You might try deleting your installation and reinstalling. There have been some changes that may have broken your current installation.

I have deleted it, but it has not changed the behavior.

Appreciate you working on this!

I agree, it's possible that the firmware update caused the problem. Unfortunately, I have no way to find out what is going wrong as I don't have any of the 3-wire switches on which to test. Have you looked for errors in the system log? If you have any, post them.

nikshriv commented 1 year ago

Got my CYNC devices hooked back up but I'm unfortunately still unable to turn them on/off, change RGB, or color temperature. The Office room where I'm testing has "Full Color Direct Connect Smart Bulb (BR30 Floodlight)" devices and they are on firmware 1.0.313, for reference.

Will try to get a capture out by this weekend.

I recently purchased that exact bulb and plan to add it to my system this weekend. I'll see if it works with my system and will let you know if I run into to the same problem as you.

halfskye commented 1 year ago

Haven't had a chance to packet capture just yet but saw there was an update so I installed it and re-setup my configuration. Same behaviors as before, but I wanted to share that I peeked into the HA Core log and am seeing a regularly logged error having to go with index out of range:

This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:38 Integration: Cync Lights (documentation) First occurred: 1:13:15 PM (755 occurrences) Last logged: 1:53:07 PM

list index out of range index out of range

Also wanted to share that during the configuration setup, I noticed that beyond the Room and Device dropdowns, there's a section for Motion Detectors which for me was empty, but I do currently have a couple of Motion Detectors. Wasn't sure if they could maybe be interfering in some way when enumerating devices or something. Just for reference though, the Motion Detectors are unique in that when configuring their settings you have to "wake" them by holding a button on the device before you can do anything like change their schedule, detection settings, etc. Maybe that required "wake" step is why they're not showing up during the initial HA configuration? Anyway, just wanted to share references and info.

halfskye commented 1 year ago

Oh, and just for completeness when considering the potential of different device types causing issues with enumeration or anything else, I just installed a CYNC Outdoor Camera a few days ago too.

nikshriv commented 1 year ago

Haven't had a chance to packet capture just yet but saw there was an update so I installed it and re-setup my configuration. Same behaviors as before, but I wanted to share that I peeked into the HA Core log and am seeing a regularly logged error having to go with index out of range:

This error originated from a custom integration. Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:38 Integration: Cync Lights (documentation) First occurred: 1:13:15 PM (755 occurrences) Last logged: 1:53:07 PM list index out of range index out of range

Also wanted to share that during the configuration setup, I noticed that beyond the Room and Device dropdowns, there's a section for Motion Detectors which for me was empty, but I do currently have a couple of Motion Detectors. Wasn't sure if they could maybe be interfering in some way when enumerating devices or something. Just for reference though, the Motion Detectors are unique in that when configuring their settings you have to "wake" them by holding a button on the device before you can do anything like change their schedule, detection settings, etc. Maybe that required "wake" step is why they're not showing up during the initial HA configuration? Anyway, just wanted to share references and info.

I think I have the same bulb type as you, and mine works perfectly with the integration. However, there appears to be an older generation of bulbs that doesn't work as expected and requires a slightly different command set than all of the other cync bulbs that I have tested. I have been working on this issue with another user but have not figured it out yet. Still working on it, but any information you can provide could be very helpful in figuring this out.

It would be useful if you could run my cync_data.py script. Packet capture would also be very helpful. If you can do both, that would be even better, but the packet capture is tricky. I had to download an old apk from June, 2021 and run that instead of the current app because they are now using tls to encrypt the packets in the most recent versions. Once you run cync_data, post your results and blank out user information so as not to expose that info.

If this all sounds like too much, one way we could try to figure this out would be to have you set up your bulbs in a dummy account and let me do the packet capture and cync_data remotely. You would have to share the username and password to the dummy account with me to do it this way (I know that sounds invasive, so if you don't feel comfortable with that, no worries)

Finally, I am not able to support wireless motion sensors. I have 3 of those devices as well, but they do not send any packets to the Cync server, so they are undetectable through the Cync server method that this integration uses. That's why they are not listed in your drop down menu.

The errors you're seeing in your log are probably related to your motion sensors since they are not supported, but the error messages are more intended to help me with debugging and probably do not indicate a real problem.

halfskye commented 1 year ago

Praying I didn't accidentally include any personal info (***ed out some data), but here's the resulting json data blob from running cync_data.py. As you can see, "I have over invested by a lot" lol. Seeing some of the data here is vindicating as it includes since deleted schedules and configurations which I suspected were still lingering as some devices exhibit old behaviors. Probably not a hot take, but my overall experience with CYNC has been pretty aggravating - more specifically with schedules, but also just with general responsiveness and the integration with Google Assistant is pretty poor.

cbyge_rooms.txt

nikshriv commented 1 year ago

That's strange. I assume the switches work while using the app? I don't think the firmware update should have caused the integration to fail unless they changed something very fundamental which i doubt.

I still think it may be firmware as the one switch worked until the firmware was updated.

If you're still logged into the app, that might be the reason for the switches not working. The Cync server seems to only allow one connection at a time, so it kicks off the HA integration when you log into the app. The integration attempts to reconnect every 15 seconds, so once you log out, it should reconnect.

I made sure I was out of the app, but it didn't change the behavior.

You might try deleting your installation and reinstalling. There have been some changes that may have broken your current installation.

I have deleted it, but it has not changed the behavior.

Appreciate you working on this!

Did my latest update fix your issue with the On/Off switches?

rubicon commented 1 year ago

Did my latest update fix your issue with the On/Off switches?

It did not. I'm noticing the yellow light is turned on on the switches. I think that means they aren't on the LAN, but Alexa is able to control them so that wouldn't make sense.

thedeats14 commented 1 year ago

New version didn’t work for me either. If you need more data for troubleshooting let me know what you need.

nikshriv commented 1 year ago

Just updated again. This update includes checking to make sure that devices are WiFi connected before sending commands. Also, commands are sent to more than one WiFi connected device at a time in case the connection is not reliable. Finally, I check to see if the command was received and resend the command if no change in state occurs.

I had a number of bulbs that did not respond to commands even though the bulbs appeared to be connected to WiFi. These bulbs also didn't respond to commands from the Cync app. After this update, my bulbs all respond to commands as expected (from my integration, but not the Cync app).

@rubicon, I'm not sure what the yellow light on your switches means as none of my devices have a yellow light. But if you're correct and the yellow light means they are not connected to your LAN, that is the likely reason why they do not work with the integration. If you have any other Wifi connected Cync devices in your home, the switches may respond to commands through those devices with the new update.

rubicon commented 1 year ago

Well, I was hoping it would work. The light showed they were not on the WiFi but using Bluetooth through another switch.

I reconnected them to WiFi and removed and reinstalled the integration, and no luck. I also have them set up via Node-Red going through Alexa. That works. The Cync app works, but no go on the integration. I now notice that the state of the lights is no longer working. I could see what they were set to, just not control them. Now they show off regardless of whether the actual light is on.

So just to give you the final status. I have 3 of these On/Off No Neutral switches. The cync app is showing me that one is connected to wifi and the other two are connected to the wifi connected switch through Bluetooth. None of them are reacting to the integration.

Thanks for working on this so hard.

nikshriv commented 1 year ago

Out of curiosity, try turning off Bluetooth on your phone and then log into the Cync app and try to operate your switches. My theory is that your devices are still not truly communicating with the Cync server over Wi-Fi and that your ability to control the devices with the app and Alexa is because they are connecting to the Bluetooth mesh. I had this problem with a few Cync bulbs. In the app, they appear to be Wi-Fi connected, but no communication with the Cync cloud server actually takes place for some reason. The integration connects to other bulbs in my network over Wi-Fi and controls those "pseudo-connected" devices over Bluetooth. But if none of your devices are functioning over Wi-Fi properly, you won't be able to control them with the phone app if your phone's Bluetooth is turned off. Give that a try and let me know what happens.

rubicon commented 1 year ago

I tried that. That was when I saw they were all Bluetooth connected via the one WiFi connected device.

thedeats14 commented 1 year ago

I disabled Bluetooth on my phone and could still control the switches. Something interesting is that in the logs for the switches I can see entries for sensors and the light turning off (when I control it through Cync), but I never seen an entry for the light turning on.

I have On/Off, Dimmers, and Motion switches all with neutral wires.

rubicon commented 1 year ago

@nikshriv, I may have some good news. I uninstalled the integration again and reinstalled it. I used my primary account user id this time, instead of a +user gmail name. And now it seems to allow me full control and updates as the status changes. Only thing I'm noticing now is that the room entry does not stay on when I turn it on. It does turn on the individual switches in the room, but it then goes back to showing it is off and there is no way to turn off the lights via the room switch. But I can turn them off via the individual switches. Which is just fine with me!

So I think when my switches did the firmware update, they no longer could connect to the wifi; thus, the yellow light showed. I then reattached the units to the wifi, and we still weren't working. Finally, I changed the integration's user id to the primary account ID, and it works. Hope this makes sense.

So the only thing outstanding I see is the room switch does not maintain its position, and therefore I don't know the status and can't turn the lights off unless I go to the individual switches. That is a low priority for me as I use HA groups for the rooms anyways. Thanks so much for doing this. The Alexa-in-the-middle approach was too flakey.

thedeats14 commented 1 year ago

Uninstalled, reinstalled, and linked to my main account seems to have worked for me too.

thanks!

nikshriv commented 1 year ago

Interesting...I wasn't even aware you could have a secondary account. I suppose I should update the instructions to ensure proper login with the primary account.

rubicon commented 1 year ago

Interesting...I wasn't even aware you could have a secondary account. I suppose I should update the instructions to ensure proper login with the primary account.

Yeah, if you look in the Settings area of the Cync app, you will see a Users option. You can add additional user accounts there. I thought I was clever by creating a Home Assistant ID using the gmails + email account option. It seems I wasn't so clever. 😁

Thanks again; this is great, and I appreciate the hard work and communication. Definitely update the instructions.

thedeats14 commented 1 year ago

You can setup guest accounts that can control devices but not configure or update them. May be something with how they integrated that.

rubicon commented 1 year ago

@nikshriv Is there any way to buy you a beer/coffee? You've earned it.

nikshriv commented 1 year ago

Just glad to hear it’s working for you!