nikshriv / cync_lights

Home Assistant Integration for controlling Cync switches, plugs, and bulbs
149 stars 50 forks source link

Cync - IndexError: list index out of range #89

Open jeremyloman opened 5 months ago

jeremyloman commented 5 months ago

Hi all,

I'm getting the following error. I only have hard wired switches, some with groups. All with neutral except one switch without neutral. All switches work fine from the Cync app, but I have sporadic failures and success via HA. None of the Ambient light or Motion sensors appear to report correctly. I'd love for this to work, so any help would be appreciated.

This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:231 Integration: Cync Lights (documentation) First occurred: 1:51:48 AM (98 occurrences) Last logged: 3:54:10 AM

IndexError: list index out of range

Lioncat6 commented 2 months ago

The Ambient light/Motion sensors most likely have been updated to no longer send updates to the Cync servers (My guess it to reduce server load because sensors like that would update a lot).

As for the error, its an error in the _read_tcp_messages. I get the error as well, and it seems to not cause any issues. (cync_hub.py Line 231)

                    _LOGGER.error(str(type(e).__name__) + ": " + str(e))
                     data = data[packet_length+5:]

My guess is that it's occurring here

                            elif packet_length >= 25 and int(packet[13]) == 84:
                                #parse motion and ambient light sensor packet
                                deviceID = self.home_devices[home_id][int(packet[16])]
                                motion = int(packet[22]) > 0
                                ambient_light = int(packet[24]) > 0
                                if deviceID in self.cync_motion_sensors:
                                    self.cync_motion_sensors[deviceID].update_motion_sensor(motion)
                                if deviceID in self.cync_ambient_light_sensors:
                                    self.cync_ambient_light_sensors[deviceID].update_ambient_light_sensor(ambient_light)

which reads data from the cync server about these sensors as the device that should report it is there, but it doesn't as cync might have removed the functionality. It could just be an updated API, however

But that's just a theory (Not an game theory, unfortunately)

Lioncat6 commented 2 months ago

This in the readme: I have also included access to the built in motion sensors and ambient light sensors for 4-wire switches ONLY. Unfortunately, it appears that the 3-Wire (no neutral wire) motion and light sensors do not report state information to the Cync server, so motion and light sensors are not supported for this particular device type.

It would be reasonable to think that cync would update their other devices to also not send the data to the servers and instead opt to do it locally on the bluetooth mesh