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

Unknown error while adding a device. #184

Closed AlexMC closed 1 year ago

AlexMC commented 1 year ago

Hi,

While trying to add a device, I get an unknown error, and the device is not created. This is what I find in the logs:

This error originated from a custom integration.

Logger: aiohttp.server
Source: custom_components/icloud3/config_flow.py:3141
Integration: iCloud3 v3 (documentation, issues)
First occurred: 19:32:36 (2 occurrences)
Last logged: 19:36:55

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, 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 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 242, 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 296, in async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 392, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/icloud3/config_flow.py", line 2560, in async_step_update_device
    self._create_device_tracker_and_sensor_entities(ui_devicename, self.conf_device_selected)
  File "/config/custom_components/icloud3/config_flow.py", line 3141, in _create_device_tracker_and_sensor_entities
    Gb.async_add_entities_device_tracker(NewDeviceTrackers, True)
TypeError: 'NoneType' object is not callable
gcobb321 commented 1 year ago

The Gb.async_add_entities_device_tracker field the error refers to is passed into iCloud3 by HA when it first starts.

  1. Turn on Debug logging - Configuration Settings > Page 2 > Format Parameters - Log Level = Debug Auto Restart or Debug
  2. Restart HA
  3. Add the device again and see if you still get the error.

If you do, send the config/icloud3-0.log and home-assistant.log files to geekstergary@gmail.com so I can see how iCloud3 started.

  1. Is this a new install? Did you convert from v2.4.7?
  2. What version are you running? Version of HA?
  3. was this the first device? Or do you already have some configured?
  4. Did you go to the Configurate Settings screen from the gear on the Event Log screen or from Devices z& Services?
AlexMC commented 1 year ago

Hi @gcobb321, thanks for the fast reply and the awesome work on iCloud3!

Today, after I got in, changed to debug, and restarted, the two devices that had errored out yesterday just appeared and were working fine! I tried adding a third device, and it went through without any issues... seems like it was just a random fluke...

Would it still be beneficial if I dig deeper and send through something?

gcobb321 commented 1 year ago

Glad a restart cleared up the problem. Since it appears to be working, the logs won’t be necessary

maiki97 commented 1 year ago

Hello, I have exactly the same problem. And I followed everything according to this youtube video. https://www.youtube.com/watch?v=Gm8NRMy0YHw At minute 14:10 I got stuck because it always brings this error "Unknown error". I tried to clear my browser cache. I switched to Debug Log Internal Tracking Monitors on page 2. All unfortunately no success... Please help me urgently as I would love to track my Iphone....

Best regards from Bavaria!

maiki97 commented 1 year ago

@gcobb321

maiki97 commented 1 year ago

home-assistant_icloud3_2023-09-04T15-55-14.743Z.log

gcobb321 commented 1 year ago

Edit the 2 files below and add the following code:

Gb.hass = hass

icloud3/device_tracker.py — line 65 Icloud3/sensor.py —- line 75

restart HA

gcobb321 commented 1 year ago

@maiki97 Make sure you are using the latest version Prerelease pr1.3. It is available on HACS (beta versions need to be enabled). Search for iCloud3. It’s also available on the iCloud3 Development site linked to in the video.

I did not know about the video. Thanks for pointing it out.

This should fix the following error. I think this is caused by starting the iCloud3 Configure Settings before HA has finished loading.

File "/config/custom_components/icloud3/config_flow.py", line 3417, in _set_header_msg
    self.errors['base'] = self.header_msg
    ~~~~~~~~~~~^^^^^^^^
TypeError: 'str' object does not support item assignment

Edit the file _/icloud3/configflow.py . Change line 2289 to read:

self.errors = {'base': 'no_add_entities_device_tracker_fct'}

maiki97 commented 1 year ago

Hello, thank you for the quick reply! I really hope that you can help me further. I have followed everything as described in your steps. Unfortunately no success... the GB.hass=hass was already in it and also the prerelease vers. 1.3 is already installed. In config_flow.py I have replaced the self errors line with yours. Now I get but one more error message when I press add devices....

maiki97 commented 1 year ago

home-assistant_icloud3_2023-09-05T05-44-03.882Z.log

maiki97 commented 1 year ago

image although I have already restarted Home Assistant 4 times...

maiki97 commented 1 year ago

@gcobb321

gcobb321 commented 1 year ago

@maiki97 I think I have fixed the problem with the error message and not being able to add the first device.

Download config_flow_pr1.4.py here.

Save it to the /icloud3 directory as _configflow.py and restart HA

maiki97 commented 1 year ago

Thanks for everything already! I was able to add my Iphone, my Airpods and my Applewatch and it all shows up. Awesome! Now I just do not know how I can integrate the Iphone from my girlfriend, because it does not appear in Family Sharing list. Do I have to log in to Data sources with the icloud email of my girlfriend ? Best regards! @gcobb321

gcobb321 commented 1 year ago

@maiki97 Unfortunately, Apple discontinued tracking devices that are not on the Family Sharing list last May. Up until then, thr Find-my-Friends would provide that information. All IHG code is still in iCloud3 so I hope to find a method to do that after v3 goes live and Steelers down.

So right now, the only way is to add her to your list.

maiki97 commented 1 year ago

Okay no problem I tried it with the email address of my girlfriend and was able to track her IPhone there and add it to Home assistant. So far everything should work. Thanks again for everything!