Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudiConnect setup fails #91

Open
PeteRager opened this issue Nov 28, 2024 · 3 comments
Open

AudiConnect setup fails #91

PeteRager opened this issue Nov 28, 2024 · 3 comments

Comments

@PeteRager
Copy link

PeteRager commented Nov 28, 2024

Describe the bug
When configuring the integration in HA 2024.11.3 an unknown error is reported.

Diagnostics file
Integration cannot be configured, diagnostic file not available

Expected behavior
Integration to be configured

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
This is the error that is logged.

2024-11-28 09:34:39.732 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 477, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 567, in _handle
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/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 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 86, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 414, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 517, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/audiconnect/config_flow.py", line 81, in async_step_user
    await api.async_login()
  File "/usr/local/lib/python3.12/site-packages/audiconnectpy/api.py", line 65, in async_login
    await self.async_fetch_data(vinlist=vinlist)
  File "/usr/local/lib/python3.12/site-packages/audiconnectpy/api.py", line 92, in async_fetch_data
    await vehicle.async_update()
  File "/usr/local/lib/python3.12/site-packages/audiconnectpy/vehicle.py", line 109, in async_update
    self.last_access = vehicle_model.access.access_status.car_captured_timestamp
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'access_status'

There appears to be better protection in audiconnectpy=2.5.50 on this section of code; but that version has a dependency conflict with pydantic in HA.

@cyr-ius
Copy link
Owner

cyr-ius commented Nov 29, 2024

Use versions lower than 2.5.
Pydantics versions are being prepared for future HA releases

@PeteRager
Copy link
Author

Thanks for pushing the api updates into 2.4.78

I've been debugging this today. The root of my issue (and the API crash) - is that I have two vehicles in my audi connect account. One of the vehicles is my old audi which never reported any data into audi connect - hence most of the vehicle_model attributes are none include the "access" object. There is a similar issue in the integration when accessing the "position" object.

I have the issues fixed locally and will package into a PR for the API and a PR for the integration.

@PeteRager
Copy link
Author

PeteRager commented Dec 7, 2024

trying to figure out the branching scheme on audiconnectpy., as master is 2.5.x

anyways the change I made locally on 2.4.78 is in vehicle.py

    async def async_update(self) -> None:
        """Update data vehicle."""

        # Selective status
        try:
            data = await self.async_get_selectivestatus()
            data = remove_value(data)
            vehicle_model = Model.from_dict(data)
        except (AttributeError, AudiException, InvalidFieldValue) as error:
            raise AudiException(error) from error
        else:
            for attr in vehicle_model.to_dict():
                obj = getattr(vehicle_model, attr, None)
                setattr(self, attr, obj)

            # Make sure this attribute has a value.
            if vehicle_model.access:
                self.last_access = vehicle_model.access.access_status.car_captured_timestamp
``

and then in the integration device_tracker.py avoid having an error if no position object.

@property
def latitude(self):
    """Return latitude value of the device."""
    if hasattr(self.vehicle, "position"):
        return self.vehicle.position.latitude
    return None

@property
def longitude(self):
    """Return longitude value of the device."""
    if hasattr(self.vehicle, "position"):
        return self.vehicle.position.longitude
    return None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants