nikshriv / cync_lights

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

Error during setup : IndexError: list index out of range in system log #7

Closed jsmeyers closed 1 year ago

jsmeyers commented 1 year ago

image Attempting to setup with a new GE Cync Smart Plug https://www.gelighting.com/smart-home/plugs/outdoor?gclid=Cj0KCQjw6_CYBhDjARIsABnuSzo2rwIkIaVdTbrJ-BtDmQgnNc_GiV6bVDogCDYwCuybBQb8FpOdzRYaAslvEALw_wcB&gclsrc=aw.ds but keep getting errors and unable to retrieve the Cync configuration.

Seems to be a similar Index out of range issue as #5 but I can run the cync_data script below from you and the Device type looked updated. image

{ "data": [ { "musicShows": [], "bulbsArray": [ { "occupancyDeactivationPeriod": 0, "lightRingBrightness": 0, "displayName": "Outlet 1", "showOnHome": false, "loadSelection": 0, "lightRingColor": 0, "mac": "786DFFFFFFFF", "ambientLightEnable": false, "occupancySensitivity": 0, "firmwareVersion": "", "occupancyEnable": false, "followTheSun": false, "deviceType": 67, "fadeOff": 0, "wifiDisconnectIndicatorEnable": true, "switchID": 415207284, "wifiSsid": "IOT", "allowOTAUpdates": true, "deviceID": 111111113001001, "fadeOn": 0, "commissionedDate": "2022-09-09T00:25:15Z", "defaultBrightness": 0, "wifiMac": "786DFFFFFFFF", "lightRingMode": 0, "ambientLightSensitivity": 0, "simpleModeEnabled": false, "occupancyTimeoutPeriod": 0 }, { "occupancyDeactivationPeriod": 0, "lightRingBrightness": 0, "displayName": "Outlet 2", "showOnHome": false, "loadSelection": 0, "lightRingColor": 0, "mac": "786DFFFFFFFF", "ambientLightEnable": false, "occupancySensitivity": 0, "firmwareVersion": "", "occupancyEnable": false, "followTheSun": false, "deviceType": 67, "fadeOff": 0, "wifiDisconnectIndicatorEnable": true, "switchID": 415207284, "wifiSsid": "IOT", "allowOTAUpdates": true, "deviceID": 111111113002001, "fadeOn": 0, "commissionedDate": "2022-09-09T00:25:15Z", "defaultBrightness": 0, "wifiMac": "786DFFFFFFFF", "lightRingMode": 0, "ambientLightSensitivity": 0, "simpleModeEnabled": false, "occupancyTimeoutPeriod": 0 }, { "occupancyDeactivationPeriod": 0, "lightRingBrightness": 0, "displayName": "Front Outdoor Plug", "showOnHome": false, "loadSelection": 0, "lightRingColor": 0, "mac": "786DFFFFFFFF", "ambientLightEnable": false, "occupancySensitivity": 0, "firmwareVersion": "1.2.232", "occupancyEnable": false, "followTheSun": false, "deviceType": 67, "fadeOff": 0, "wifiDisconnectIndicatorEnable": true, "switchID": 415207284, "wifiSsid": "IOT", "allowOTAUpdates": true, "deviceID": 111111113001, "fadeOn": 0, "commissionedDate": "2022-09-09T00:25:15Z", "defaultBrightness": 0, "wifiMac": "786DFFFFFFFF", "lightRingMode": 0, "ambientLightSensitivity": 0, "simpleModeEnabled": false, "occupancyTimeoutPeriod": 0 } ], "lightShows": [], "admin": { "emailAddress": "myemail@gmail.com", "lastUseDate": "2022-09-08T20:23:46.721Z", "userID": 111111113, "username": "jsmeyers", "createDate": "2022-09-08T20:23:46.721Z" }, "lastUseDate": "2022-09-08T20:23:46.725Z", "groupsArray": [ { "sensorSchedules": [], "displayName": "front Yard", "groupID": 32768, "showOnHome": false, "isSubgroup": false, "deviceIDArray": [ 1001, 2001 ] } ], "version": "1.0", "system": { "app": { "build": "14192", "bundleID": "com.ge.cbyge1", "name": "Cync", "version": "6.8.2" }, "ltk": "827860A1F330A1ECC68A8FB061DC687A", "timeInfo": { "sunrise": "7:00:00 PM", "sunset": "7:03:58 PM", "timeZone": "America/New_York" }, "platform": { "os": "iOS", "machine": "N/A", "model": "iPhone", "localizedModel": "iPhone", "version": "15.6.1" } }, "standaloneDevicesArray": [], "sceneArray": [], "schedules": [], "createDate": "2022-09-08T20:23:46.725Z" } ] }

nikshriv commented 1 year ago

Did you copy and paste your configuration from cync_data.py or did you edit it? Your configuration looks very different than mine. If this is a direct copy, I will have to create a separate function to obtain the type of configuration information in your account. These Cync configurations vary a lot and I have tried to accommodate all the variations, but this is the first time I have seen a configuration that is missing whole blocks of information when compared with mine.

nikshriv commented 1 year ago

I made a couple of changes to cync_data.py to provide more information. Can you rerun this program and post your results?

jsmeyers commented 1 year ago

I ran into an issue with your updated script @nikshriv and needed to change the following line: rooms.append({'device':device, 'device_info':device_info})

It was kicking a syntax error without the brackets{} if this is incorrect and my python is having a bad day let me know.

data from script

{ "data": [ { "device": { "subscribe_date": "2022-09-08T19:25:15.395Z", "is_active": true, "role": 0, "last_login": "2022-09-08T19:26:46.489Z", "firmware_mod": "1", "active_code": "546285e78e65418d9808dd17c99fc2f7", "active_date": "2022-09-08T19:24:46.358Z", "groups": "", "mcu_version": 28, "firmware_version": 12232, "source": 1, "mac": "786DEB659E3A", "mcu_mod": "1", "product_id": "1607d2bc854400011607d2bc85442201", "access_key": 777, "name": "786DEB659E3A", "authorize_code": "1e07d4c126efa631", "id": 415207284, "is_online": true, "sn": "786DEB659E3A" }, "device_info": { "error": { "msg": "device property not exists", "code": 4041009 } } }, { "device": { "subscribe_date": "2022-09-08T19:23:46.693Z", "is_active": true, "role": 0, "last_login": "", "active_code": "a38d79ca9588666ccd8290585840505d", "active_date": "2022-09-08T19:23:46.691Z", "groups": "", "mcu_version": 0, "firmware_version": 0, "source": 5, "mac": "998563A2E3BF", "product_id": "1607d2ad150cb2001607d2ad150cb201", "access_key": 848812, "name": "Holden", "authorize_code": "1e07d4c6350f2421", "id": 969024973, "is_online": false }, "device_info": { "musicShows": [], "bulbsArray": [ { "occupancyDeactivationPeriod": 0, "lightRingBrightness": 0, "displayName": "Outlet 1", "showOnHome": false, "loadSelection": 0, "lightRingColor": 0, "mac": "786DEB65A6CB", "ambientLightEnable": false, "occupancySensitivity": 0, "firmwareVersion": "", "occupancyEnable": false, "followTheSun": false, "deviceType": 67, "fadeOff": 0, "wifiDisconnectIndicatorEnable": true, "switchID": 415207284, "wifiSsid": "IOT", "allowOTAUpdates": true, "deviceID": 969024973001001, "fadeOn": 0, "commissionedDate": "2022-09-09T00:25:15Z", "defaultBrightness": 0, "wifiMac": "786DEB659E3A", "lightRingMode": 0, "ambientLightSensitivity": 0, "simpleModeEnabled": false, "occupancyTimeoutPeriod": 0 }, { "occupancyDeactivationPeriod": 0, "lightRingBrightness": 0, "displayName": "Outlet 2", "showOnHome": false, "loadSelection": 0, "lightRingColor": 0, "mac": "786DEB65A6CB", "ambientLightEnable": false, "occupancySensitivity": 0, "firmwareVersion": "", "occupancyEnable": false, "followTheSun": false, "deviceType": 67, "fadeOff": 0, "wifiDisconnectIndicatorEnable": true, "switchID": 415207284, "wifiSsid": "IOT", "allowOTAUpdates": true, "deviceID": 969024973002001, "fadeOn": 0, "commissionedDate": "2022-09-09T00:25:15Z", "defaultBrightness": 0, "wifiMac": "786DEB659E3A", "lightRingMode": 0, "ambientLightSensitivity": 0, "simpleModeEnabled": false, "occupancyTimeoutPeriod": 0 }, { "occupancyDeactivationPeriod": 0, "lightRingBrightness": 0, "displayName": "Front Outdoor Plug", "showOnHome": false, "loadSelection": 0, "lightRingColor": 0, "mac": "786DEB65A6CB", "ambientLightEnable": false, "occupancySensitivity": 0, "firmwareVersion": "1.2.232", "occupancyEnable": false, "followTheSun": false, "deviceType": 67, "fadeOff": 0, "wifiDisconnectIndicatorEnable": true, "switchID": 415207284, "wifiSsid": "IOT", "allowOTAUpdates": true, "deviceID": 969024973001, "fadeOn": 0, "commissionedDate": "2022-09-09T00:25:15Z", "defaultBrightness": 0, "wifiMac": "786DEB659E3A", "lightRingMode": 0, "ambientLightSensitivity": 0, "simpleModeEnabled": false, "occupancyTimeoutPeriod": 0 } ], "lightShows": [], "admin": { "emailAddress": "smyemail@gmail.com", "lastUseDate": "2022-09-08T20:23:46.721Z", "userID": 969027313, "username": "jsmeyers", "createDate": "2022-09-08T20:23:46.721Z" }, "lastUseDate": "2022-09-08T20:23:46.725Z", "groupsArray": [ { "sensorSchedules": [], "displayName": "front", "groupID": 32768, "showOnHome": false, "isSubgroup": false, "deviceIDArray": [ 1001, 2001 ] } ], "version": "1.0", "system": { "app": { "build": "14192", "bundleID": "com.ge.cbyge1", "name": "Cync", "version": "6.8.2" }, "ltk": "827860A1F330A1ECC68A8FB061DC687A", "timeInfo": { "sunrise": "7:00:00 PM", "sunset": "7:03:58 PM", "timeZone": "America/New_York" }, "platform": { "os": "iOS", "machine": "N/A", "model": "iPhone", "localizedModel": "iPhone", "version": "15.6.1" } }, "standaloneDevicesArray": [], "sceneArray": [], "schedules": [], "createDate": "2022-09-08T20:23:46.725Z" } } ] }

nikshriv commented 1 year ago

Sorry, rookie mistake. It’s fixed

jsmeyers commented 1 year ago

Sorry, rookie mistake. It’s fixed

I did also run the file and attached to prior post

nikshriv commented 1 year ago

This issue should be fixed. You'll need to redownload. Let me know if it works for you.

nikshriv commented 1 year ago

After fixing the config flow file, I realized that the state of your plugs will not be reported properly because my assumption has been that the mesh index number of these switches is a one byte number, but based on your configuration information, it is clear that they use 2 bytes. I'm not sure if this is reported as big or little endian, so I can't make a change to the code until I figure this out. Have you had any trouble with the state of your devices not updating appropriately?

jsmeyers commented 1 year ago

I deleted my config and rerun your updated code and it displayed a single device and two entities one for the room and one for the single device but they do not function correctly and I wonder as I was receiving a duplicate device message in my logs at one point. They reflect the state if both outlets are in the same position if both on or off but changing the state in HA doesn't impact them. I think since this is a dual outlet each using the same MAC address the generated device ID using that maybe causing an issue.

nikshriv commented 1 year ago

Made some new changes with how state updates are handled and the device id (which no longer depends on the wifi MAC address) in HA which should take care of your new issues. Give it a try and let me know if it works.

jsmeyers commented 1 year ago

Still a nogo during setup

Log Details (ERROR) This error originated from a custom integration. Logger: aiohttp.server Source: custom_components/cync_lights/config_flow.py:140 Integration: Cync Lights (documentation) First occurred: 6:16:49 PM (1 occurrences) Last logged: 6:16:49 PM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 178, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper result = await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 280, in async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/cync_lights/config_flow.py", line 113, in async_step_two_factor_code return await self.async_step_select_switches() File "/config/custom_components/cync_lights/config_flow.py", line 140, in async_step_select_switches ): cv.multi_select({switch_id : f'{sw_info["name"]} ({self.data["data"]["cync_config"]["rooms"][sw_info["room"]]["name"]}:{sw_info["home_name"]})' for switch_id,sw_info in self.data["data"]["cync_config"]["devices"].items() if sw_info['ONOFF']}), File "/config/custom_components/cync_lights/config_flow.py", line 140, in ): cv.multi_select({switch_id : f'{sw_info["name"]} ({self.data["data"]["cync_config"]["rooms"][sw_info["room"]]["name"]}:{sw_info["home_name"]})' for switch_id,sw_info in self.data["data"]["cync_config"]["devices"].items() if sw_info['ONOFF']}), KeyError: 'room' image

nikshriv commented 1 year ago

You were able to get through the setup yesterday, weren't you? Did you make any changes to your configuration on the Cync app since then? Strange that it worked yesterday but didn't today. The error occurs at a line I didn't change.

nikshriv commented 1 year ago

Still a nogo during setup

Log Details (ERROR) This error originated from a custom integration. Logger: aiohttp.server Source: custom_components/cync_lights/config_flow.py:140 Integration: Cync Lights (documentation) First occurred: 6:16:49 PM (1 occurrences) Last logged: 6:16:49 PM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 178, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper result = await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 280, in async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/cync_lights/config_flow.py", line 113, in async_step_two_factor_code return await self.async_step_select_switches() File "/config/custom_components/cync_lights/config_flow.py", line 140, in async_step_select_switches ): cv.multi_select({switch_id : f'{sw_info["name"]} ({self.data["data"]["cync_config"]["rooms"][sw_info["room"]]["name"]}:{sw_info["home_name"]})' for switch_id,sw_info in self.data["data"]["cync_config"]["devices"].items() if sw_info['ONOFF']}), File "/config/custom_components/cync_lights/config_flow.py", line 140, in ): cv.multi_select({switch_id : f'{sw_info["name"]} ({self.data["data"]["cync_config"]["rooms"][sw_info["room"]]["name"]}:{sw_info["home_name"]})' for switch_id,sw_info in self.data["data"]["cync_config"]["devices"].items() if sw_info['ONOFF']}), KeyError: 'room' image

Alright, made some additional changes. Give it a try...like I said, these Cync configurations seem to have a lot of quirks. Will get it figured out sooner or later

jsmeyers commented 1 year ago

Now everything loads and devices show but a change in state in home assistant is not reflected in device and only temporary

nikshriv commented 1 year ago

Now everything loads and devices show but a change in state in home assistant is not reflected in device and only temporary

What entities were created? If you control the plugs manually or from the Cync app, does the state change in HA?

nikshriv commented 1 year ago

These plugs must be 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. 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 those results publicly.

nikshriv commented 1 year ago

Now everything loads and devices show but a change in state in home assistant is not reflected in device and only temporary

Made another change to how the mesh address is calculated based on decompiled code from the android app. Hopefully this will get your plugs up and running properly. As usual, you will need to delete your previous installation and reinstall. Let me know if it works.

jsmeyers commented 1 year ago

Thanks