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

Unable to do initial configuration #9

Closed
riddley opened this issue Nov 21, 2021 · 9 comments
Closed

Unable to do initial configuration #9

riddley opened this issue Nov 21, 2021 · 9 comments

Comments

@riddley
Copy link

riddley commented Nov 21, 2021

Super excited for this integration!

I followed most of the instructions in the README. My OPNSense version 21.7.5 doesn't have System -> Advanced so I wasn't able to set Max Processes despite looking around for it.

Also my tunables are under System > Settings > Tunables rather than System -> Advanced -> System Tunables and I had to manually add net.link.ether.inet.max_age, which I set to 300.

I added your repo to HACS and installed it, restarted HA, refreshed my browser and I see the integration in the Configuration > Integrations but when I add it, I get "Retrying setup: the JSON object must be str, bytes or bytearray, not bool" but I am able to see my devices in the Device Tracker Options, so some aspect of it is working.

I double-checked the permissions/ownership/content of the PHP files and they seem fine.

My Home Assistant is version 2021.11.4.

Please let me know if I can help or provide more information!

Lastly here's the stack trace from the logs:

This error originated from a custom integration.

Logger: custom_components.opnsense
Source: custom_components/opnsense/pyopnsense/init.py:91
Integration: OPNsense (documentation, issues)
First occurred: 2:01:19 PM (108 occurrences)
Last logged: 2:20:53 PM

Unexpected error fetching Router OPNsense state data: the JSON object must be str, bytes or bytearray, not bool
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/opnsense/__init__.py", line 95, in async_update_data
    await hass.async_add_executor_job(lambda: data.update())
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/opnsense/__init__.py", line 95, in <lambda>
    await hass.async_add_executor_job(lambda: data.update())
  File "/config/custom_components/opnsense/__init__.py", line 249, in update
    self._state["telemetry"] = self._get_telemetry()
  File "/config/custom_components/opnsense/__init__.py", line 225, in _get_telemetry
    return self._client.get_telemetry()
  File "/config/custom_components/opnsense/pyopnsense/__init__.py", line 720, in get_telemetry
    data = self._exec_php(script)
  File "/config/custom_components/opnsense/pyopnsense/__init__.py", line 59, in inner
    response = func(*args, **kwargs)
  File "/config/custom_components/opnsense/pyopnsense/__init__.py", line 91, in _exec_php
    response = json.loads(response["real"])
  File "/usr/local/lib/python3.9/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not bool

@travisghansen
Copy link
Owner

Welcome! Yeah not sure entirely where this thing will go, but we'll run with it for a little bit and see what happens.

A couple of the parts of the README haven't really been tweaked to move over from pfSense to OPNsense so I wouldn't worry about those minor configuration issues you missed. I would also revert the changes to the tunable (it's not really necessary with how the integration works).

OK, so to the issue at hand, it may be a little difficult to debug this but if you are willing to dig in the easiest thing to do will be to hack this line here: https://github.com/travisghansen/hass-opnsense/blob/main/custom_components/opnsense/pyopnsense/__init__.py#L47

Beware it will log your OPNsense creds, but will provide some valuable data. Try to enable it and then send over the cleansed output so we can try to see what is causing the data to return incorrectly (I'm guessing it will take even more than this however).

@riddley
Copy link
Author

riddley commented Nov 21, 2021

I set verbose to True and restarted HA, but I don't see any change in the logs. It's re-logged the same stack trace as above a few times. I'm looking in /config/logs (URL) is there a better place to look? I'm available for screen-share over Jitsi or Discord if that's easier.

@travisghansen
Copy link
Owner

Sure ping me on discord and we can get something setup..

@riddley
Copy link
Author

riddley commented Nov 21, 2021

How do I find you? I just joined the Home Assistant server. I joined the Lobby Hangout voice channel.

@alexdelprete
Copy link
Contributor

alexdelprete commented Nov 21, 2021

What account are you using to authenticate with OPNsense, is it an admin one? If not, did you double-check it has System - HA node sync privilege?

The errors you have are right after you add the integration or after you configure it? It's not clear based on your first post.

Everything's working fine here, with same HA/OPNsense versions...

@travisghansen
Copy link
Owner

We discovered the issue leading to this actually. It was a division by 0 error due to having no swap. Fixed in commit e4a892e

@alexdelprete
Copy link
Contributor

alexdelprete commented Nov 22, 2021

That's why you need more testers, everybody has its specific setup...glad it was fixed.

Travis, could you put a debug switch in the addon configuration so users can turn it on without hacking files?

@travisghansen
Copy link
Owner

It’s likely to cause more problems than help. The critical thing to view is the errors on the opnsense dashboard actually as they tell is exactly what is erroring out.

@travisghansen
Copy link
Owner

We’ll keep an eye on it though and see where the needs go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants