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
73.98k stars 31.03k forks source link

OPNsense integration not being loaded due to error #97522

Open Goeste opened 1 year ago

Goeste commented 1 year ago

The problem

Hi,

I had the OPNsense integration up and running fine, but i guess after an update of OPNsense the integration is not working anymore. Everytime HassOS boots up it detects a mis-configuration/error of OPNsense.

I def. need this integration running for presence detection in my case... Secret and Key have been checked multiple times.

Any help or bump t the right direction is very much appreciated!

Best, goeste

What version of Home Assistant Core has the issue?

core-2023.7.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

OPNsense

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

opnsense:
  url: https://192.168.2.2/api
  api_secret: !secret OPNsS
  api_key: !secret OPNsK
  verify_ssl: false
  tracker_interfaces: LAN

Anything in the logs that might be useful for us?

Logger: homeassistant.setup
Source: components/opnsense/__init__.py:55
First occurred: 09:37:26 (1 occurrences)
Last logged: 09:37:26

Error during setup of component opnsense
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 714, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 403, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1053, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 363, in connect
    self.sock = conn = self._new_conn()
                       ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 179, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7fcbcf036710>, 'Connection to 192.168.2.2 timed out. (connect timeout=20)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 798, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='192.168.2.2', port=443): Max retries exceeded with url: /api/diagnostics/interface/getArp (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7fcbcf036710>, 'Connection to 192.168.2.2 timed out. (connect timeout=20)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 288, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  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/opnsense/__init__.py", line 55, in setup
    interfaces_client.get_arp()
  File "/usr/local/lib/python3.11/site-packages/pyopnsense/diagnostics.py", line 55, in get_arp
    return self._get("diagnostics/interface/getArp")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyopnsense/client.py", line 55, in _get
    response = requests.get(
               ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 725, in send
    history = [resp for resp in gen]
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 725, in <listcomp>
    history = [resp for resp in gen]
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 266, in resolve_redirects
    resp = self.send(
           ^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 507, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='192.168.2.2', port=443): Max retries exceeded with url: /api/diagnostics/interface/getArp (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7fcbcf036710>, 'Connection to 192.168.2.2 timed out. (connect timeout=20)'))

Additional information

No response

home-assistant[bot] commented 1 year ago

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

Code owner commands Code owners of `opnsense` 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 opnsense` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


opnsense documentation opnsense source (message by IssueLinks)

mib1185 commented 1 year ago

just interpreting the error message: you OPNsense do not answer the api requests Connection to 192.168.2.2 timed out. (connect timeout=20). maybe you need to check if there is an incoming firewall rule or administrativ setting missing or changed during update in the OPNsense

davlaw commented 1 year ago

Any outcome on this issue, just starting to look at its intergration and am faced with same..??

mcothern commented 1 year ago

@davlaw I just tried to set it up from scratch and having the same issues too.

pacmac commented 1 year ago

same here

issue-triage-workflows[bot] commented 9 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.

tphs commented 9 months ago

Still not working :-(

bobloadmire commented 7 months ago

I have a fresh install of opensense, no added plugins or anything, getting the same error. Anything We can do to help narrow this down?

kokokodak commented 5 months ago

Hi, you can make sure that you are able to ping (and eventually connect with curl or such) from the Home Assistant machine to the OPNSense machine. You can use the "Advanced SSH & Web Terminal" add-on to get a terminal on HA.

ehcloninger commented 4 months ago

Still happening with core 24.7.3 I have an API key/secret that I can curl from the HA terminal.

curl -k -u "abcd1234":"wxyz9876" https://192.168.2.1/api/core/firmware/status

Returns a valid response, e.g.

{
    "product": {
        "product_abi": "24.1",
        "product_arch": "amd64",
        "product_name": "OPNsense",
        "product_nickname": "Savvy Shark"
    },
    "status": "none"
}

HA logs show similar to what @Goeste is reporting

2024-07-23 10:32:00.027 ERROR (MainThread) [homeassistant.setup] Error during setup of component opnsense
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 404, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  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/opnsense/__init__.py", line 56, in setup
    interfaces_client.get_arp()
  File "/usr/local/lib/python3.12/site-packages/pyopnsense/diagnostics.py", line 55, in get_arp
    return self._get("diagnostics/interface/getArp")
  File "/usr/local/lib/python3.12/site-packages/pyopnsense/client.py", line 61, in _get
    return self._process_response(response, raw)
  File "/usr/local/lib/python3.12/site-packages/pyopnsense/client.py", line 47, in _process_response
    return response.text if raw else json.loads(response.text)
  File "/usr/local/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Goblinmine commented 1 month ago

It worked for me on core 24.10.2

@ehcloninger I had the same error. The URL setting is a little weird because it needs the /api in the end. So make sure your URL setting looks like this:

url: https://192.168.0.1/api

ehcloninger commented 1 month ago

url: https://192.168.0.1/api

@Goblinmine Thank you for that detail. That did solve the reported problem. HA can poll the opnsense instance, but now getting a different issue.

That's the way it goes with these kinds of projects, discovery is half the fun! :-)

fermulator commented 1 month ago

(issue can be closed)