nikshriv / cync_lights

Home Assistant Integration for controlling Cync switches, plugs, and bulbs
164 stars 57 forks source link

Issue with Reauthorizing #54

Open pagedeskbill3 opened 1 year ago

pagedeskbill3 commented 1 year ago

Hello! I commend you on a wonderful job here. I do have a quick question and am having an issue with Cync. Some of my lights will not respond within HA. So, in the process of authorizing, after putting in the 2FA code in I will receive an unknown error. I looked in the logs and I am receiving this error:

Logger: aiohttp.server Source: custom_components/cync_lights/config_flow.py:266 Integration: Cync Lights (documentation) First occurred: March 8, 2023 at 5:01:42 PM (4 occurrences) Last logged: 4:07:38 PM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, 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 67, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 94, 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 80, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 241, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, 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 271, 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 241, in async_step_two_factor_code return await self.async_step_select_switches() File "/config/custom_components/cync_lights/config_flow.py", line 266, in async_step_select_switches description = {"suggested_value" : [room for room in self.entry.options["subgroups"] if room in self.entry.data["cync_config"]["rooms"].keys()]}, KeyError: 'subgroups'

druid1302 commented 1 year ago

Same issue here. With basically the same log.

JoeG923 commented 1 year ago

Same issue here too.

cbrooker commented 1 year ago

Same issue for me

nikshriv commented 1 year ago

Can you clarify what you mean by "reauthorizing"? Did you delete the integration first, reinstall, and then reauthorize or did you use the "configure" button to reauthorize?

pagedeskbill3 commented 1 year ago

Hello! I used the configure button to reauthorize. I was hesitant to reinstall if it caused issues with the other devices which are still working correctly. Thank you!

nikshriv commented 1 year ago

Yes, that makes sense. I had to make a couple of baking changes to handle subgroups some time ago. If you have updated to the most recent version but didn't alter your configuration, the integration would continue to work.

All you need to do to fix it is to delete your current configuration and add it again (re-login like you're installing for the first time). I think that should fix it.

pagedeskbill3 commented 1 year ago

Maybe I am confused, however, how would you remove the configuration? Are you saying to delete the integration and add it again?

pagedeskbill3 commented 1 year ago

And just for clarification, I just removed the integration and installed again and the same error is occurring.

nikshriv commented 1 year ago

If you can run the two scripts in my cync_data repository and post your results, that would be helpful. Try that first. The parse_cync_data script will tell us if there is a problem with you Cync configuration data that is making the integration fail. Post the results of both scripts, and you might want to react any sensitive information first.

I think it's possible that your old config entry didn't get deleted when you upgraded to the latest version of the integration. You might have to install the version of the integration you had when you created that config entry to be able to delete it. Once the old entry is cleared out of your system, I think it will install properly.