travisghansen / hass-opnsense

OPNsense integration with Home Assistant
213 stars 28 forks source link

OPNsense 23.7.5 breaks addon #99

Closed leonardopc closed 1 month ago

leonardopc commented 1 year ago

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.

Girtab2 commented 1 year ago

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?

JimmyMPage commented 12 months ago

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 commented 12 months ago

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).

stmpl commented 11 months ago

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

issmirnov commented 10 months ago

@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!

janou-chouchou commented 7 months ago

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?

travisghansen commented 6 months ago

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?

Momro commented 6 months ago

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

issmirnov commented 6 months ago

@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

travisghansen commented 6 months ago

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

issmirnov commented 6 months ago

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

travisghansen commented 6 months ago

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

issmirnov commented 6 months ago

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 commented 6 months ago

@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.

travisghansen commented 6 months ago

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.

Anejey commented 5 months ago

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?

stevenallen05 commented 4 months ago

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
Snuffy2 commented 1 month ago

Please give v0.2.0 a try and open a new issue if this is still happening.

zenjr commented 1 month ago

Hey @Snuffy2 it's still an issue on 0.2.0: image

image

---- NEVERMIND ---- The user I created on opensense had the wrong permissions, it worked fine with the admin account.