hass-opnsense icon indicating copy to clipboard operation
hass-opnsense copied to clipboard

OPNsense 23.7.5 breaks addon

Open leonardopc opened this issue 1 year ago • 17 comments

I have been using this addon for a while now, it is great (thanks). But today I upgraded opnsense to 23.7.5 and it no longer works. Trying to reconfigure the addon in home assistant (2023.9.3) gives me this error: grafik There are otherwise no errors in home assistant. I have redownloaded the addon and recreated the api keys but that does not solved the problem.

leonardopc avatar Oct 03 '23 13:10 leonardopc

Similar error, but while configuring it for the first time, might be related: custom_components/opnsense/pyopnsense/init.py:100 Unexpected get_system_info error err=TypeError("string indices must be integers, not 'str'"), type(err)=<class 'TypeError'>

custom_components/opnsense/config_flow.py:148

Unexpected err=TypeError("string indices must be integers, not 'str'"), type(err)=<class 'TypeError'>

@leonardopc What do your logs say?

Girtab2 avatar Oct 13 '23 20:10 Girtab2

I am also experiencing this problem.

The integration still shows sensors related to the router's condition/performance, but my device trackers all show "Unavailable" and I am unable to configure more.

I have these two errors in my logs and I do not recall them being present before.

2023-10-19 09:06:00.311 ERROR (SyncWorker_19) [custom_components.opnsense] failed to retrieve arp table err=TimeoutError('The read operation timed out'), type(err)=<class 'TimeoutError'>```

JimmyMPage avatar Oct 19 '23 14:10 JimmyMPage

I am also experiencing this problem.

The integration still shows sensors related to the router's condition/performance, but my device trackers all show "Unavailable" and I am unable to configure more.

I have these two errors in my logs and I do not recall them being present before.

2023-10-19 09:06:00.311 ERROR (SyncWorker_19) [custom_components.opnsense] failed to retrieve arp table err=TimeoutError('The read operation timed out'), type(err)=<class 'TimeoutError'>```

OK. I figured out my issue, I do not think it is the same as the previous two posters. I had deleted my DNS servers from my OPNSense configuration during a previous router troubleshooting session...forgot about it...and fixed it. This solved the problem I was experiencing with the HASS integration (as well as other issues I was seeing which led me to believe the integration was not at fault).

JimmyMPage avatar Oct 19 '23 14:10 JimmyMPage

Same for me, but while configuring it for the first time:

Source: custom_components/opnsense/config_flow.py:148 Unexpected err=TypeError("string indices must be integers, not 'str'"), type(err)=<class 'TypeError'> OPNsense: 23.7.8 HA: 2023.11.2

stmpl avatar Nov 16 '23 19:11 stmpl

@travisghansen are there any logs we could provide, or beta versions we could test?

My logs are the same as @stmpl

12:36:22 – (ERROR) OPNsense (custom integration)
Unexpected err=TypeError("string indices must be integers, not 'str'"), type(err)=<class 'TypeError'>
12:36:22 – (ERROR) OPNsense (custom integration)
Unexpected get_system_info error err=TypeError("string indices must be integers, not 'str'"), type(err)=<class 'TypeError'>

HA: 2023.11.1 OPNsense: OPNsense 23.7.9-amd64, FreeBSD 13.2-RELEASE-p5, OpenSSL 1.1.1w

Thank you for a great plugin!

issmirnov avatar Dec 04 '23 19:12 issmirnov

Same Error with HA grafik

integration shows Error: grafik

Logfile: 2024-03-06 18:20:28.995 ERROR (SyncWorker_24) [custom_components.opnsense.pyopnsense] Unexpected get_system_info error err=TypeError("string indices must be integers, not 'str'"), type(err)=<class 'TypeError'> 2024-03-06 18:20:28.997 ERROR (MainThread) [custom_components.opnsense.config_flow] Unexpected err=TypeError("string indices must be integers, not 'str'"), type(err)=<class 'TypeError'> Any idea, how to fix this?

janou-chouchou avatar Mar 06 '24 17:03 janou-chouchou

Thanks for the patience getting back to you. All of these are when attempting to configure the integration initially? You cannot even get it to load initially?

travisghansen avatar Mar 20 '24 04:03 travisghansen

Come to say it works for me in 24.1.3 of OPNsense with Home Asisstant 2024.3.1

Momro avatar Mar 20 '24 10:03 Momro

@travisghansen correct, steps to repro are:

  1. Add repo in HACS, install
  2. Click on "Add Integration" on the integrations page
  3. Enter host url, apio key, secret, and name.
  4. Observe error "Unexpected Error" and the string indices must be integers, not 'str'" error in the logs.

OPNSense: OPNsense 24.1.4-amd64 Home Assistant: 2024.3.1 hass-opnsense: v0.1.21

issmirnov avatar Mar 23 '24 00:03 issmirnov

Hmm ok. That's pretty strange. The setup phase has very little interaction with the api :(

travisghansen avatar Mar 23 '24 03:03 travisghansen

How could I help debug? Are there any other logs that would be helpful, or is there some way to increase verbose output?

issmirnov avatar Mar 23 '24 15:03 issmirnov

Are there any logs on the opnsense side that provide some better info about what the error might be?

travisghansen avatar Mar 23 '24 17:03 travisghansen

image

This error originated from a custom integration.

Logger: custom_components.opnsense.config_flow
Source: custom_components/opnsense/config_flow.py:149
integration: OPNsense (documentation, issues)
First occurred: 20:13:13 (1 occurrences)
Last logged: 20:13:13

Unexpected err=TypeError("string indices must be integers, not 'str'"), type(err)=<class 'TypeError'>

FWIW, If I try to enable the "verify ssl" flag, I get a correct error that the cert is self signed, so the connection to the server seems to be going through: image

issmirnov avatar Mar 25 '24 04:03 issmirnov

@travisghansen I did some light digging, and traced this down to the client.get_system_info call. I can't really follow what you're doing with the pythonic php execution, but my guess is that the response at https://github.com/travisghansen/hass-opnsense/blob/main/custom_components/opnsense/pyopnsense/init.py#L268 is throwing the type error, perhaps coming from the json encode at https://github.com/travisghansen/hass-opnsense/blob/main/custom_components/opnsense/pyopnsense/init.py#L127

I can confirm that the address is getting dialed and the authentication is valid (tested via curl), so I'm guessing the object coming back from the php side of things isn't rendering into the dictionary the code expects.

issmirnov avatar Mar 26 '24 03:03 issmirnov

Right, the question is why is that method failing? It's the most basic bits of code and should not be things that would be brittle :(

If you're comfortable doing some python dev you can clone this repo locally, setup a venv and manually use the xmlrpc client. Doing so would help us see the output better to determine what's blowing up.

travisghansen avatar Mar 26 '24 04:03 travisghansen

Still a problem. Screenshot 2024-05-01 163136

Latest HAOS/OPNsense, freshly generated api keys. It used to work before I updated OPNsense to ver. 24

Is there any update to this?

Anejey avatar May 01 '24 14:05 Anejey

I just encountered the same issue after trying this plugin for the first time. I forked, added a stacktrace log, and found that there was an error being reported by my OPNSense about the os-homeassistant-maxit install failing due to a versioning issue.

These steps fixed the issue for me:

  1. Update to OPNsense 24.1.8
  2. SSH'ed back in to OPNsense and re-ran pkg install os-homeassistant-maxit

stevenallen05 avatar Jun 09 '24 01:06 stevenallen05