gcobb321 / icloud3_v3

iCloud3 v3, Development Version - This Repo/Version is used for development and testing of new and updated features. It is not the official release of iCloud3 v3, .
MIT License
169 stars 13 forks source link

Unable to add device on first setup #326

Closed DerDon1302 closed 3 months ago

DerDon1302 commented 3 months ago

When setting up the integration after logging in to my iCloud account I get the unknown error message when trying to add my first device.

I had iCloud3 v3 installed previously. Yet I deleted everything related to iCloud3 v3 in .storage to set it up completely fresh.

This is the log I get relating to the error:

`Logger: aiohttp.server Quelle: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421 Erstmals aufgetreten: 20:24:04 (6 Vorkommnisse) Zuletzt protokolliert: 20:24:11

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/decorators.py", line 81, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/config/config_entries.py", line 285, in post return await super().post(request, flow_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/data_validator.py", line 74, in wrapper return await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/data_entry_flow.py", line 122, in post result = await self._flow_mgr.async_configure(flow_id, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 368, in async_configure result = await self._async_configure(flow_id, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 415, in _async_configure result = await self._async_handle_step( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 518, in _async_handle_step result: _FlowResultT = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/icloud3/config_flow.py", line 2678, in async_step_device_list return await self.async_step_add_device() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/icloud3/config_flow.py", line 2869, in async_step_add_device await self._build_update_device_selection_lists() File "/config/custom_components/icloud3/config_flow.py", line 3276, in _build_update_device_selection_lists await self._build_mobapp_entity_list() File "/config/custom_components/icloud3/config_flow.py", line 3458, in _build_mobapp_entity_list self.mobapp_list_text_by_entity_id.update(sort_dict_by_values(search_mobapp_devices)) ^^^^^^^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'search_mobapp_devices' where it is not associated with a value`

gcobb321 commented 3 months ago

This error was caused by setting up an iCloud3 devices without the mobile app being installed or being installed but without any devices assigned to it. I have fixed it in the module below.

Unzip _configflow.zip to the _customcomponents/icloud3 directory and restart HA.

config_flow.zip

DerDon1302 commented 3 months ago

Thanks a lot. This fixed the issue.