nikshriv / cync_lights

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

"Failed to set up" After Initial Config #37

Closed shaydin closed 1 year ago

shaydin commented 1 year ago

After completing the installation for HACS and this plugin, the integration is immediately red and states Failed to set up. I've tried reauthorizing, restarting the container, and removing/reinstalling the integration with no change.

Logs: ogger: homeassistant.config_entries Source: custom_components/cync_lights/cync_hub.py:354 Integration: Cync Lights (documentation) First occurred: 3:49:04 PM (1 occurrences) Last logged: 3:49:04 PM

Error setting up entry cync_lights_redacted@email.com for cync_lights Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/cync_lights/init.py", line 16, in async_setup_entry hub = CyncHub(entry.data, entry.options, remove_options_update_listener) File "/config/custom_components/cync_lights/cync_hub.py", line 56, in init [room.initialize() for room in self.cync_rooms.values() if not room.is_subgroup] File "/config/custom_components/cync_lights/cync_hub.py", line 56, in [room.initialize() for room in self.cync_rooms.values() if not room.is_subgroup] File "/config/custom_components/cync_lights/cync_hub.py", line 354, in initialize self.groups_support_brightness = [room_id for room_id in self.subgroups if self.hub.cync_rooms[room_id].support_brightness] File "/config/custom_components/cync_lights/cync_hub.py", line 354, in self.groups_support_brightness = [room_id for room_id in self.subgroups if self.hub.cync_rooms[room_id].support_brightness] KeyError: '1567423064-32770'

nikshriv commented 1 year ago

It would be helpful if you could run my cync_data.py python script (on your laptop, not your Home Assistant instance). Then run parse_cync_data.py. Post cync_data.json and parseed_cync_data.json and I will take a look. Both scripts are available at github.com/nikshriv/cync_data

shaydin commented 1 year ago

Not sure what you mean by running the script on a laptop. I have a home server running a Ubuntu VM, which is running HA in a docker container. Do you want me to run the script on the VM, from within the container, or on a computer that's just on my home network and not associated with running the HA container?

nikshriv commented 1 year ago

Run it with python on any computer with the command "python cync_data.py". Python is free to download and install. Does not need to be your server. If you get errors, it will probably be due uninstalled dependencies. The command "pip install x" will install dependency "x". There are three dependencies, aiohttp, asyncio, and json.

The script will ask you to log in to your cync account, download your configuration, and then I will be able to inspect it for problems. It would be preferable to leave the file untouched, but if you have sensitive information that in the file that you don't wany to make public, redact it.

You can just run cync_data.py. No need to run "parse_cync_data.py". I can run that one myself if you post your result from "cync_data.py"

shaydin commented 1 year ago

Perfect, thanks. I'm familiar with Python, I just wasn't sure if the script was going to need to reference data from the HA plugin/environment, or if it was just going to need network access. I'll get this to you ASAP, appreciate the help.

shaydin commented 1 year ago

parsed_cync_data.zip Parsed file attached as a zip since GH apparently doesn't allow json or 7z files.

nikshriv commented 1 year ago

Would you mind also posting the cync_data.json file?

shaydin commented 1 year ago

cync_data.zip Linked

nikshriv commented 1 year ago

Thanks for your posting your file. Helped me figure out what the bug was, and it's fixed now. Try the latest update and let me know if it works for you.

shaydin commented 1 year ago

Thanks! I finally got a minute to reauth and it does add the integration now. However, even though it sees all the lights, it does not get their statuses or control them. I tried adding several Cync devices and groups to buttons and they label fine and I don't see any obvious errors, but they do not turn the lights or light groups on or off.

shaydin commented 1 year ago

Forgot to add any log errors, apologies.

This error originated from a custom integration.

Logger: custom_components.cync_lights.cync_hub Source: custom_components/cync_lights/cync_hub.py:66 Integration: Cync Lights (documentation) First occurred: February 3, 2023 at 8:11:49 AM (1 occurrences) Last logged: February 3, 2023 at 8:11:49 AM

ShuttingDown:


This error originated from a custom integration.

Logger: homeassistant.config_entries Source: custom_components/cync_lights/cync_hub.py:74 Integration: Cync Lights (documentation) First occurred: February 3, 2023 at 8:11:49 AM (1 occurrences) Last logged: February 3, 2023 at 8:11:49 AM

Error unloading entry cync_lights_bubbletavern@gmail.com for cync_lights Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 533, in async_unload result = await component.async_unload_entry(hass, self) File "/config/custom_components/cync_lights/init.py", line 33, in async_unload_entry hub.disconnect() File "/config/custom_components/cync_lights/cync_hub.py", line 74, in disconnect self.loop.call_soon_threadsafe(self.send_request,state_request) AttributeError: 'NoneType' object has no attribute 'call_soon_threadsafe'


This error originated from a custom integration.

Logger: homeassistant.config_entries Source: custom_components/cync_lights/cync_hub.py:364 Integration: Cync Lights (documentation) First occurred: February 3, 2023 at 8:10:58 AM (1 occurrences) Last logged: February 3, 2023 at 8:10:58 AM

Error setting up entry cync_lights_bubbletavern@gmail.com for cync_lights Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/cync_lights/init.py", line 16, in async_setup_entry hub = CyncHub(entry.data, entry.options, remove_options_update_listener) File "/config/custom_components/cync_lights/cync_hub.py", line 57, in init [room.initialize() for room in self.cync_rooms.values() if not room.is_subgroup] File "/config/custom_components/cync_lights/cync_hub.py", line 57, in [room.initialize() for room in self.cync_rooms.values() if not room.is_subgroup] File "/config/custom_components/cync_lights/cync_hub.py", line 364, in initialize self.groups_support_brightness = [room_id for room_id in self.subgroups if self.hub.cync_rooms[room_id].support_brightness] File "/config/custom_components/cync_lights/cync_hub.py", line 364, in self.groups_support_brightness = [room_id for room_id in self.subgroups if self.hub.cync_rooms[room_id].support_brightness] KeyError: '1567423064-32770'

nikshriv commented 1 year ago

Did you delete your previous installation of the integration and then start fresh? You probably need to do that because your old configuration contains an unused switch_id, and that is where the integration appears to be failing.

shaydin commented 1 year ago

I forgot that step somehow. Everything now seems to be working. Thank you so much for your help and for this awesome integration!