travisghansen / hass-opnsense

OPNsense integration with Home Assistant
193 stars 25 forks source link

When ZeroTier disabled, Interface shows as missing and HASS Integration fails to load #127

Closed j0hnby closed 6 months ago

j0hnby commented 6 months ago

I have ZeroTier half set up - so I have it installed, but disabled, and an interface assigned to the disabled ZT instance - which means the interface assignment is showing as missing in OPN

This caused an error with the HASS integration.

HASS Log xmlrpc.client.ProtocolError: <ProtocolError for :@router.local/xmlrpc.php: 500 Internal Server Error> 2024-02-13 06:17:08.342 ERROR (SyncWorker_13) [custom_components.opnsense.pyopnsense] Unexpected get_telemetry error err=<ProtocolError for :@router.local/xmlrpc.php: 500 Internal Server Error>, type(err)=<class 'xmlrpc.client.ProtocolError'> 2024-02-13 06:17:08.346 ERROR (MainThread) [custom_components.opnsense] Unexpected error fetching router.local OPNsense state data: <ProtocolError for :@router.local/xmlrpc.php: 500 Internal Server Error> Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 269, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/init.py", line 97, in async_update_data await hass.async_add_executor_job(lambda: data.update()) 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/opnsense/init.py", line 97, in await hass.async_add_executor_job(lambda: data.update()) ^^^^^^^^^^^^^ File "/config/custom_components/opnsense/init.py", line 316, in update self._state["telemetry"] = self._get_telemetry() ^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/init.py", line 225, in inner response = func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/init.py", line 249, in _get_telemetry return self._client.get_telemetry() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/pyopnsense/init.py", line 101, in inner raise err File "/config/custom_components/opnsense/pyopnsense/init.py", line 98, in inner return func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/pyopnsense/init.py", line 1037, in get_telemetry data = self._exec_php(script) ^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/pyopnsense/init.py", line 88, in inner response = func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/pyopnsense/init.py", line 131, in _exec_php response = self._get_proxy().opnsense.exec_php(script) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/xmlrpc/client.py", line 1122, in call return self.send(self.name, args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/xmlrpc/client.py", line 1461, in request response = self.transport.request( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/xmlrpc/client.py", line 1166, in request return self.single_request(host, handler, request_body, verbose) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/xmlrpc/client.py", line 1196, in single_request raise ProtocolError(

OPN Report [13-Feb-2024 06:13:30 Europe/London] PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /usr/local/etc/inc/xmlrpc/hass.inc(12) : eval()'d code:26 Stack trace:

0 /usr/local/etc/inc/xmlrpc/hass.inc(12) : eval()'d code(60): interfaces_api()

1 /usr/local/etc/inc/xmlrpc/hass.inc(12): eval()

2 /usr/local/opnsense/contrib/IXR/IXR_Library.php(446): exec_php_xmlrpc('\nini_set('displ...')

3 /usr/local/opnsense/contrib/IXR/IXR_Library.php(384): IXR_Server->call('opnsense.exec_p...', '\nini_set('displ...')

4 /usr/local/opnsense/contrib/IXR/IXR_Library.php(357): IXR_Server->serve('<?xml version='...')

5 /usr/local/etc/inc/xmlrpc.inc(67): IXR_Server->__construct(Array)

6 /usr/local/www/xmlrpc.php(104): XMLRPCServer->start()

7 {main}

thrown in /usr/local/etc/inc/xmlrpc/hass.inc(12) : eval()'d code on line 26

Debug Log Message Error | opnsense | /usr/local/sbin/pluginctl: The command `/usr/local/sbin/ifinfo 'zt'' failed to execute

I "fixed" it by enabling ZT to run - which made the interface have an assignment - and no more error.

Not sure if this is something to be fixed - but might help people in future at least.

alexdelprete commented 6 months ago

are you on 24.1 or 24.1.1?

travisghansen commented 6 months ago

I just pushed v0.1.18, give it a try and see if that's fixed.

Qhilm commented 6 months ago

Issue was still present for me on v0.1.18, I had a wireguard interface which was disabled in Wireguard config (something I tested long ago and didn't work the way I wanted), leading to a missing wg1 device under assignments. I deleted the interface assigned to device wg1 and the issue went away.

travisghansen commented 6 months ago

Try v0.1.20.

buenni86 commented 6 months ago

Sorry didn't have time to test until now. The new version fixed my problem with the disabled wireguard instance. @travisghansen thanks

j0hnby commented 6 months ago

0.1.20 works for me too - thanks very much!