home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.98k stars 30.17k forks source link

Bbox device_tracker requires authentication #106381

Closed eDexiam closed 2 weeks ago

eDexiam commented 9 months ago

The problem

This extension is querying the associated router, however the router responds with an HTTP 401 code with the following message: {"exception":{"domain":"v1/hosts","code":"401","errors":[{"name":"","reason":"Operation requires authentication"}]}}

The extension does not contain any configuration fields to add any credentials.

What version of Home Assistant Core has the issue?

core-2023.12.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Bbox

Link to integration documentation on our website

https://www.home-assistant.io/integrations/bbox/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.device_tracker
Source: components/device_tracker/legacy.py:298
Integration: Device tracker (documentation, issues)
First occurred: 4:21:49 PM (1 occurrences)
Last logged: 4:21:49 PM

Error setting up platform legacy bbox
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 298, in async_setup_legacy
    scanner = await hass.async_add_executor_job(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bbox/device_tracker.py", line 36, in get_scanner
    scanner = BboxDeviceScanner(config[DOMAIN])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bbox/device_tracker.py", line 55, in __init__
    self.success_init = self._update_info()
                        ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
    result = method(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bbox/device_tracker.py", line 83, in _update_info
    result = box.get_all_connected_devices()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pybbox/__init__.py", line 112, in get_all_connected_devices
    resp = api.execute_api_request()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pybbox/bboxApiCall.py", line 54, in execute_api_request
    raise Exception('Error {} with request {}'.format(
Exception: Error 401 with request http://192.168.1.254/api/v1/hosts

Additional information

No response

home-assistant[bot] commented 9 months ago

bbox documentation bbox source

clementduveau commented 9 months ago

The BBox calls need a cookie header, so we also need a logic to refresh it when expired.

Biscotte31 commented 7 months ago

Hey guys,

We are having issues with this official integration since 2022. Seems like it's not maintained anymore. However, earion68 built a custom one. I used it since 2022.

The main goal was to solve the "DH KEY TOO SMALL" issue, but it seems that he has embodied a fix concerning the password issue too. See here, and take the link provided in the comment from @earion68, on Aug 8, 2022 :).

Biscotte31 commented 7 months ago

I installed the custom_bbox again on a fresh install, and yes, it works like a charm. @earion68, really, thank you 😄 !

earion68 commented 7 months ago

My pleasure. Anyone who could help me in understanding what are the steps needed to merge this back in the official integration? I also want to mention that, though I have some Python skills, enough to mess with the integration and make it work, I am not the code owner and don't know much about the API.

eDexiam commented 6 months ago

My pleasure. Anyone who could help me in understanding what are the steps needed to merge this back in the official integration? I also want to mention that, though I have some Python skills, enough to mess with the integration and make it work, I am not the code owner and don't know much about the API.

Have you been able to test it yourself? I've managed to configure it and it only seems to work intermittently.

It sometimes works and sometimes doesn't, for seemingly no reason.

Logger: homeassistant.components.device_tracker
Source: components/device_tracker/legacy.py:301
integration: Device tracker (documentation, issues)
First occurred: 14:32:55 (1 occurrences)
Last logged: 14:32:55

Error setting up platform legacy custom_bbox
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 301, in async_setup_legacy
    scanner = await hass.async_add_executor_job(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/custom_bbox/device_tracker.py", line 39, in get_scanner
    scanner = BboxDeviceScanner(config[DOMAIN])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/custom_bbox/device_tracker.py", line 59, in __init__
    self.success_init = self._update_info()
                        ^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
    result = method(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/custom_bbox/device_tracker.py", line 87, in _update_info
    box.login(self.password)
  File "/config/custom_components/custom_bbox/pybbox.py", line 150, in login
    response = api.execute_api_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/custom_bbox/bboxApiCall.py", line 62, in execute_api_request
    raise Exception('Error {} with request {}'.format(
Exception: Error 400 with request https://mabbox.bytel.fr/api/v1/login

This is the log for the device tracker but the same 400 HTTP error gets thrown when using it as a sensor.

For the config I use, here it is:

Screenshot_20240312-144642~2

(I can't seem to copy and paste the config on a mobile device annoyingly enough)

issue-triage-workflows[bot] commented 3 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

eDexiam commented 3 months ago

AFAIK this is still an issue, I will try to debug the python code from @earion68's repo to see what could be causing the random exceptions.

issue-triage-workflows[bot] commented 3 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.