Skip to content

Error 401 on Get Sensor #4

Description

@mleglise

Request

Could we please get the device_id printed out as part of the "Failed to get sensor..." error message?

raise HTTPError(f"Failed to get sensor, status code: {str(response.status)}")

Problem Observed

Started by configuring LaCrosse View integration in Home Assistant. Input the username and password. Then it kept failing with error message: Failed to get sensor, status code: 401

Full error log from Home Assistant:

2022-12-18 17:49:23.416 ERROR (MainThread) [homeassistant.components.lacrosse_view] Unexpected error fetching LaCrosse View data: Failed to get sensor, status code: 401
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/lacrosse_view/coordinator.py", line 63, in _async_update_data
sensors = await self.api.get_sensors(
File "/usr/local/lib/python3.10/site-packages/lacrosse_view/__init__.py", line 242, in get_sensors
raise HTTPError(
lacrosse_view.HTTPError: Failed to get sensor, status code: 401
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/components/lacrosse_view/coordinator.py", line 70, in _async_update_data
raise ConfigEntryNotReady from error
homeassistant.exceptions.ConfigEntryNotReady: Failed to get sensor, status code: 401

Troubleshooting

Tracing down through the code, it looks like this library gets all the way through retrieving the location data, then starts trying to iterate through the device list. (Meaning all the authentication and API calls worked so far.)

for device in data.get("items"):

But then inside that loop, it hits a non-200 response code and errors out completely.

raise HTTPError(f"Failed to get sensor, status code: {str(response.status)}")

I know I have ~7 devices in my list, but other than scripting this out myself, there's no information at all about which device failed or succeeded. Could we please get the device_id printed out as part of the error message?

Bonus

Perhaps this logic could be improved so that 1 device failing doesn't stop the rest from returning data?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions