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

[Bug]: Unable to create connection to OPNSense firewall. #346

Open
JasonJanelle opened this issue Dec 25, 2024 · 12 comments
Open

[Bug]: Unable to create connection to OPNSense firewall. #346

JasonJanelle opened this issue Dec 25, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@JasonJanelle
Copy link

What happened?

I had this working in the past but something in the updates broke it. I have the plugin installed on OPNSense, a user with admin rights and an API key generated. I can curl the firewall from my home assistant terminal. When I try to create the connection in the UI, it spins for about 10 seconds and the reports this error:

Unable to get MAC addresses from OPNsense to use as Device Unique ID

The logs do not display more information than that.

hass-opnsense Version

2024.09.0

OPNsense Firmware

24.1.7_4

Home Assistant Version

14.1

Relevant logs

2024-12-24 18:58:22.677 ERROR (MainThread) [custom_components.opnsense.config_flow] Missing Device Unique ID Error. MissingDeviceUniqueID: 
2024-12-24 19:14:13.053 ERROR (MainThread) [custom_components.opnsense.config_flow] Missing Device Unique ID Error. MissingDeviceUniqueID: 
2024-12-24 19:15:19.562 ERROR (MainThread) [custom_components.opnsense.config_flow] Missing Device Unique ID Error. MissingDeviceUniqueID:

Additional Details

I have a self signed cert but do uncheck the verify SSL box. I use https://<ip.addr>.

@JasonJanelle JasonJanelle added the bug Something isn't working label Dec 25, 2024
@Snuffy2
Copy link
Collaborator

Snuffy2 commented Dec 27, 2024

Can you please ensure you are running the latest version of hass-opnsense. 2024.09.0 is not a valid version (nor is 14.1). We've made some fixes to this issue so I want to ensure you're on v0.3.12.

If v0.3.12 isn't working, please enable debug logging, try to setup hass-opnsense again and please post the debug logs.

@neffen37
Copy link

hello I have the same problem however my version of the plugin is up to date here are the logs which appear in HA

Enregistreur: custom_components.opnsense.coordinator
Source: helpers/update_coordinator.py:379
intégration: OPNsense (documentation, problèmes)
S'est produit pour la première fois: 17:56:05 (4 occurrences)
Dernier enregistrement: 17:57:11

Unexpected error fetching opnsense state data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 379, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/opnsense/coordinator.py", line 144, in _async_update_data
self._state.update(await self._get_states(categories))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/opnsense/coordinator.py", line 53, in _get_states
state[cat.get("state_key")] = await method()
^^^^^^^^^^^^^^
File "/config/custom_components/opnsense/pyopnsense/init.py", line 2121, in get_certificates
"valid_from": datetime.fromtimestamp(
~~~~~~~~~~~~~~~~~~~~~~^
self._try_to_int(cert.get("valid_from", None)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tz=datetime.now().astimezone().tzinfo,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
),
^
TypeError: 'NoneType' object cannot be interpreted as an integer

@Snuffy2
Copy link
Collaborator

Snuffy2 commented Dec 28, 2024

@neffen37 I don't know if you're having the same issue as @JasonJanelle or not. However, I believe #351 will fix the error you're seeing. For clarification, what Time Zone are you in, both name and offset.

@NickOllivier
Copy link

Hey @Snuffy2, I'm having the same problems as @JasonJanelle. Below is some more detail for you.

OPNsense version: 24.7.11_2
Home assistant version: Core 2024.12.5, Supervisor 2024.12.0, Operating System 14.1

I enabled the debugger for the opnsense extension and found the following.

[custom_components.opnsense.pyopnsense] [get] Response 200: OK
[custom_components.opnsense.pyopnsense] [get] url: https://example.router.fqdn/api/diagnostics/system/systemInformation
[custom_components.opnsense.pyopnsense] [get] Response 200: OK
[custom_components.opnsense.config_flow] [config_flow] system_info: {'name': 'example.router.fqdn'}
[custom_components.opnsense.pyopnsense] [get] url: https://example.router.fqdn/api/interfaces/overview/export
[custom_components.opnsense.pyopnsense] [get] Response 200: OK
[custom_components.opnsense.pyopnsense] [get_device_unique_id] device_unique_id: None
[custom_components.opnsense.config_flow] [config_flow] Device Unique ID: None

Checking that API endpoint using postman, it just comes back with an open and close square bracket with no further information.

@Snuffy2
Copy link
Collaborator

Snuffy2 commented Dec 30, 2024

@NickOllivier, there are 2 queries in your screenshot. To clarify, the one that is returning as [] is: https://example.router.fqdn/api/interfaces/overview/export correct?

Does your OPNsense user have Administrator privileges?

2024-12-30_13-30-07 393

@JasonJanelle
Copy link
Author

JasonJanelle commented Dec 30, 2024 via email

@NickOllivier
Copy link

@NickOllivier, there are 2 queries in your screenshot. To clarify, the one that is returning as [] is: https://example.router.fqdn/api/interfaces/overview/export correct?

Does your OPNsense user have Administrator privileges?

2024-12-30_13-30-07 393

Correct. I was running the interfaces overview export query.

I tested under both the built in root account as well as the secondary administrator level account I had for api requests.

The only other thing that has happened with my opnsense is I've had to restore from backup recently due to a failed disk. I did read the instruction on the plugin page about a full reinstall if there were hardware changes but I suspect this is not a plugin fault.

@NickOllivier
Copy link

NickOllivier commented Dec 30, 2024

@NickOllivier https://github.com/NickOllivier how did you enable the
debugger? I would like to replicate these logs.

@Snuffy2, I'll get you the versions in the same format as Nick did when I
get home tonight.

On Sun, Dec 29, 2024 at 5:57 PM Nick Ollivier @.***>
wrote:

Hey @Snuffy2 https://github.com/Snuffy2, I'm having the same problems
as @JasonJanelle https://github.com/JasonJanelle. Below is some more
detail for you.

OPNsense version: 24.7.11_2
Home assistant version: Core 2024.12.5, Supervisor 2024.12.0, Operating
System 14.1

I enabled the debugger for the opnsense extension and found the following.

[custom_components.opnsense.pyopnsense] [get] Response 200: OK
[custom_components.opnsense.pyopnsense] [get] url:
https://example.router.fqdn/api/diagnostics/system/systemInformation
[custom_components.opnsense.pyopnsense] [get] Response 200: OK
[custom_components.opnsense.config_flow] [config_flow] system_info:
{'name': 'example.router.fqdn'}
[custom_components.opnsense.pyopnsense] [get] url:
https://example.router.fqdn/api/interfaces/overview/export
[custom_components.opnsense.pyopnsense] [get] Response 200: OK
[custom_components.opnsense.pyopnsense] [get_device_unique_id]
device_unique_id: None
[custom_components.opnsense.config_flow] [config_flow] Device Unique ID:
None

Checking that API endpoint using postman, it just comes back with an open
and close square bracket with no further information.


Reply to this email directly, view it on GitHub
#346 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AACYP5OU7MATVNPIOE7GKTL2ICLAJAVCNFSM6AAAAABUFNLZEGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRUHEZDEMRYGU
.
You are receiving this because you were mentioned.Message ID:
@.***>

@JasonJanelle

@Snuffy2 mentioned how to do it, but at the bottom of this link there is a configuration line you can paste into the main configuration.yaml for HA to enable.

https://github.com/travisghansen/hass-opnsense/blob/main/CONTRIBUTING.md

@Snuffy2
Copy link
Collaborator

Snuffy2 commented Dec 31, 2024

@NickOllivier No, as you noted, the plugin shouldn't affect this query. Can you please confirm what version of hass-opnsense you are running? I want to make sure you're not on an older version, but since you're seeing the same thing with Postman, that also is not likely the cause of this.

I'm just not clear why the query: https://example.router.fqdn/api/interfaces/overview/export isn't returning anything. It should give a very long list of all of the physical and virtual interfaces.

What response do you get in Postman with these queries? You can attach the files or email them to me at [email protected]
https://example.router.fqdn/api/interfaces/overview/interfacesInfo
https://example.router.fqdn/api/interfaces/overview/interfacesInfo/details
https://example.router.fqdn/api/diagnostics/interface/getInterfaceStatistics
https://example.router.fqdn/api/diagnostics/interface/getInterfaceConfig

@JasonJanelle
Copy link
Author

Home Assistant Versions:
Core 2024.12.5
Supervisor 2024.12.0
Operating System 14.1

hass-opnsense is on v0.3.13 now

Logs:

2024-12-31 00:32:34.770 DEBUG (MainThread) [custom_components.opnsense.config_flow] [config_flow] user_input: {'url': 'https://10.10.10.1', 'verify_ssl': False, 'username': 'REDACTED', 'name': 'brickhouse'}
2024-12-31 00:32:34.771 DEBUG (MainThread) [custom_components.opnsense.config_flow] [config_flow] Cleaned URL: https://10.10.10.1
2024-12-31 00:32:34.771 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [get] url: https://10.10.10.1/api/core/firmware/status
2024-12-31 00:32:35.329 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [get] Response 200: OK
2024-12-31 00:32:35.330 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [get_host_firmware_version] firmware: 24.1.7_4
2024-12-31 00:32:35.330 DEBUG (MainThread) [custom_components.opnsense.config_flow] [config_flow] Firmware Version: 24.1.7_4
2024-12-31 00:32:35.331 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [get] url: https://10.10.10.1/api/core/firmware/info
2024-12-31 00:32:46.088 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [get] Response 200: OK
2024-12-31 00:32:46.108 INFO (MainThread) [custom_components.opnsense.pyopnsense] Using legacy get_system_info method for OPNsense < 24.7
2024-12-31 00:32:46.211 DEBUG (MainThread) [custom_components.opnsense.config_flow] [config_flow] system_info: {'name': 'brickhouse.localdomain'}
2024-12-31 00:32:46.211 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [get] url: https://10.10.10.1/api/interfaces/overview/export
2024-12-31 00:32:46.626 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [get] Response 200: OK
2024-12-31 00:32:46.626 DEBUG (MainThread) [custom_components.opnsense.pyopnsense] [get_device_unique_id] device_unique_id: None
2024-12-31 00:32:46.626 DEBUG (MainThread) [custom_components.opnsense.config_flow] [config_flow] Device Unique ID: None
2024-12-31 00:32:46.627 ERROR (MainThread) [custom_components.opnsense.config_flow] Missing Device Unique ID Error. MissingDeviceUniqueID:

@JasonJanelle
Copy link
Author

I upgraded my opnsense system from 24.1 to 24.7 and the problem has resolved. I got the idea after seeing this line in the logs:

2024-12-31 00:32:46.108 INFO (MainThread) [custom_components.opnsense.pyopnsense] Using legacy get_system_info method for OPNsense < 24.7

I suspect it has something to do with how 24.1 is responding to the legacy get_system_info. My problem is solved but I'm leaving open for @NickOllivier.

@NickOllivier
Copy link

@Snuffy2 Apologies for the delay - I'm about to email through the outputs you requested from the API. Something to note, the very last link (getInterfaceConfig) returned a 200 with no content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants