Packet parsing reliability improvements#145
Packet parsing reliability improvements#145Kinachi249 wants to merge 2 commits intonikshriv:mainfrom
Conversation
|
Thanks for the feedback! I did some additional research, and found that for the pipe packets (type 0x7), the inner frames (which have their boundary denoted by byte 0x7e) will have any actual usages of the byte 0x7e encoded to the bytes 0x7d5e instead, so the parser doesn't confuse the data 7e with the frame boundary 7e. It just so happened that my Cync packets had a length of exactly 126 bytes (0x7e), so the length byte had the serialization applied to it, which caused my offset to be one-off. I added some additional code to deserialize instances where this can happen, so that all packet lengths should be brought in line. I also adjusted the type 0x4 packet processing to stop processing if the remaining length is less than 4 bytes, as that is what the app seems to do in the decompiled code. |
|
I appreciate the info! I only have one configured "home" in my app, so I'll move some of my lights around today to a second home and do some investigating. I do know that if you open the Cync app, the Cync server disconnects the Home Assistant connection in favor of the app's connection (which the integration re-establishes after the 15 second wait). Hopefully that's not what is at play here though, I'll look into it some more. |
|
So I've spent a few hours trying to reproduce the list index out of range error, however I'm having a bit of a hard time. I created a second home in the Cync app with a couple of my bulbs and got them showing in HA. However, whenever I open the Cync app and change homes, I get the standard "Connection Reset" error in HA, meaning the Cync server remotely closed the HA connection. This can't really be avoided since it's the server that's severing the connection, all the integration can do is re-establish the connection again in 15 seconds. I am curious about the index out of range error though. Does it appear the instant you switch homes in the Cync app, or are there other actions performed in the app before it manifests? I use the iPhone app, so I also wonder if there's some sort of difference in how it handles other connections on the same account compared to Android. |
|
Interesting, good to know! Out of curiosity, have you either added a new device, removed a device, or moved a device between homes in the Cync app since setting up the integration? I was testing some more this afternoon, and I moved one of my bulbs back to my original home in the Cync app. Then when I rebooted HA, I started seeing the index out of range errors that you had. For me, it was happening because the integration doesn't automatically update devices and their locations/homes when they're modified in the Cync app, so it was still using the old mesh IDs it had saved before the Cync change was made. This caused the IDs to be wrong and it was trying to access an ID that no longer existed. When I went to the "integration entries" page for the integration, and clicked "Configure", it had me sign back in and it re-fetched the up to date device info. After that the error stopped appearing, so I wonder if it may help your case as well. Ideally it would update automatically, but I don't believe that would be caused by my change if that's the case. As for the leader, this is something I've noticed too. The integration will always just pick the first device within a home to "ping" as the leader, and if that device ends up being a bluetooth only device, it won't get a response. Would be another good feature for the integration, seeing which wi-fi device is the current designated "leader" of each mesh and only pinging that one. |
|
No, I haven't made any changes lately. I always reload the integration after making changes.
Perhaps a notification to reload the integration could be triggered if an invalid configuration is detected? Most users probably don't know that it's necessary after changing things. |
|
Right. Reload restarts the integration and Configure does a full reauthorization and download. As of 2025.7.1 the Configure option is now a gear.
Since commit d53f550 I haven't noticed any "list index out of range" errors except when I switch Homes in the Cync app. Since this bug is unchanged with your patch applied I think it's fair to conclude the problem lies elsewhere. So, it's understandable if you wish to move on and complete your thermostat support. I'll continue to research the problem because it's a bit of a show stopper. Every time the error occurs device states get out of sync and switches need to be manually toggled to get back in sync. Either that, or the integration needs to be restarted. |
|
Gotcha! I suppose I should rebase my HA branch from develop 😅 And no worries at all, I mainly ask so I know if I should look in the area of my code change or elsewhere in the code. I'm actually working on a reusable python library at the moment for Cync API controls, as I've been going through the decompiled Android app code and trying to make some code that's a bit less opinionated toward just lights and uses the more generic structures that the app uses. This'll be a case that I'll try and add to my code, though, so that multi-home setups hopefully won't run into this |












Hey there, I was planning on tackling thermostat integration for this component as I'd love to have my GE thermostat in HA.
I found some bugs in the component related to just the presence of a thermostat on my mesh. I thought I'd make a PR to address some of these before I start on any actual thermostat changes.
Thanks, and feel free to let me know if there are questions.