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.16k stars 29.83k forks source link

Luci Integration Doesn't Connect to IPV6 Only Host #122353

Open dougransom opened 1 month ago

dougransom commented 1 month ago

The problem

The device router.local hosting luci has an IPV6 address, no ipv4 address. Works ok hard coding the ipv4 address.

What version of Home Assistant Core has the issue?

core-2024.7.3

What was the last working version of Home Assistant Core?

core-2024.7.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

openwrt-luci

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

device_tracker:
  - platform: luci
    host: router.local
    username: root
    password: PASSWORD
    ssl: true
    verify_ssl: false
    new_device_defaults:
      track_new_devices: true

Anything in the logs that might be useful for us?

Log details (ERROR)
Logger: homeassistant.components.device_tracker
Source: components/device_tracker/legacy.py:335
integration: Device tracker (documentation, issues)
First occurred: 7:41:33 PM (1 occurrences)
Last logged: 7:41:33 PM

Error setting up platform legacy luci
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 404, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1060, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 363, in connect
    self.sock = conn = self._new_conn()
                       ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f638bf09d30>: Failed to establish a new connection: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 801, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 594, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='router.local', port=443): Max retries exceeded with url: /cgi-bin/luci/rpc/auth (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f638bf09d30>: Failed to establish a new connection: [Errno 22] Invalid argument'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/legacy.py", line 335, 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 "/usr/src/homeassistant/homeassistant/components/luci/device_tracker.py", line 44, in get_scanner
    scanner = LuciDeviceScanner(config[DOMAIN])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/luci/device_tracker.py", line 55, in __init__
    self.router = OpenWrtRpc(
                  ^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/openwrt_luci_rpc/__init__.py", line 34, in __init__
    self.router = OpenWrtLuciRPC(
                  ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/openwrt_luci_rpc/openwrt_luci_rpc.py", line 61, in __init__
    self._refresh_token()
  File "/usr/local/lib/python3.12/site-packages/openwrt_luci_rpc/openwrt_luci_rpc.py", line 69, in _refresh_token
    self.token = self._call_json_rpc(auth_url, 'login',
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/openwrt_luci_rpc/openwrt_luci_rpc.py", line 215, in _call_json_rpc
    res = self.session.post(url,
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 700, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='router.local', port=443): Max retries exceeded with url: /cgi-bin/luci/rpc/auth (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f638bf09d30>: Failed to establish a new connection: [Errno 22] Invalid argument'))

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @mzdrale, mind taking a look at this issue as it has been labeled with an integration (luci) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `luci` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign luci` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


luci documentation luci source (message by IssueLinks)