travisghansen / hass-pfsense

pfSense integration with Home Assistant
189 stars 27 forks source link

pfSense 22.05 fails after configuration in HA 2022.8 #95

Open aaburger85 opened 2 years ago

aaburger85 commented 2 years ago

Attempting to integrate a new home assistant install with my pfSense firewall that was upgraded to 22.05 is failing with the following captured below. I am no programmer so the level of detail provided here is about all I can provide without specific requests.

image image image

Logger: custom_components.pfsense
Source: custom_components/pfsense/pypfsense/__init__.py:97
Integration: pfSense ([documentation](https://github.com/travisghansen/hass-pfsense), [issues](https://github.com/travisghansen/hass-pfsense/issues))
First occurred: 12:01:32 PM (6 occurrences)
Last logged: 12:04:08 PM
Unexpected error fetching pfsense pfSense 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 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/pfsense/__init__.py", line 96, in async_update_data
    await hass.async_add_executor_job(lambda: data.update())
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/pfsense/__init__.py", line 96, in <lambda>
    await hass.async_add_executor_job(lambda: data.update())
  File "/config/custom_components/pfsense/__init__.py", line 333, in update
    self._state["telemetry"] = self._get_telemetry()
  File "/config/custom_components/pfsense/__init__.py", line 229, in inner
    response = func(*args, **kwargs)
  File "/config/custom_components/pfsense/__init__.py", line 260, in _get_telemetry
    return self._client.get_telemetry()
  File "/config/custom_components/pfsense/pypfsense/__init__.py", line 1104, in get_telemetry
    data = self._exec_php(script)
  File "/config/custom_components/pfsense/pypfsense/__init__.py", line 63, in inner
    response = func(*args, **kwargs)
  File "/config/custom_components/pfsense/pypfsense/__init__.py", line 97, in _exec_php
    response = json.loads(response["real"])
  File "/usr/local/lib/python3.10/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 commented 2 years ago

It was working previous to the upgrade and then after the upgrade it is now failing? Or it has simply never worked?

aaburger85 commented 2 years ago

it was working on my other HA install prior to me upgrading to pfSense 22.05. This is effectively net new in that I created a new HA install, upgraded to 22.05 on pfSense, and then had the integration fail after configuration.

travisghansen commented 2 years ago

OK, are you sure something didn't change with the credentials? You may look into the pfsense webserver logs for any pointers as to why it doesn't like the request/user as well..

aaburger85 commented 2 years ago

It isnt failing the credentials from what i can see. These are the only logs:

image

travisghansen commented 2 years ago

The failure is relatively low-level from what I can tell. If you can hack the code here: https://github.com/travisghansen/hass-pfsense/blob/main/custom_components/pfsense/pypfsense/__init__.py#L51 and set the value to True and then restart hass you should see the raw data. That may give us an indication of what's going on..

aaburger85 commented 2 years ago

Ok will try that out here shortly!

aaburger85 commented 2 years ago

Would i see the error logging in the Core Logs? I dont see a difference after setting the value and restarting:

image

image

This error originated from a custom integration.

Logger: custom_components.pfsense
Source: custom_components/pfsense/pypfsense/__init__.py:97
Integration: pfSense (documentation, issues)
First occurred: 9:48:30 AM (3 occurrences)
Last logged: 9:48:57 AM

Unexpected error fetching ww-pfsense pfSense 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 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 164, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/pfsense/__init__.py", line 96, in async_update_data
    await hass.async_add_executor_job(lambda: data.update())
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/pfsense/__init__.py", line 96, in <lambda>
    await hass.async_add_executor_job(lambda: data.update())
  File "/config/custom_components/pfsense/__init__.py", line 333, in update
    self._state["telemetry"] = self._get_telemetry()
  File "/config/custom_components/pfsense/__init__.py", line 229, in inner
    response = func(*args, **kwargs)
  File "/config/custom_components/pfsense/__init__.py", line 260, in _get_telemetry
    return self._client.get_telemetry()
  File "/config/custom_components/pfsense/pypfsense/__init__.py", line 1104, in get_telemetry
    data = self._exec_php(script)
  File "/config/custom_components/pfsense/pypfsense/__init__.py", line 63, in inner
    response = func(*args, **kwargs)
  File "/config/custom_components/pfsense/pypfsense/__init__.py", line 97, in _exec_php
    response = json.loads(response["real"])
  File "/usr/local/lib/python3.10/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

image

travisghansen commented 2 years ago

It would be in the raw logs for hass. Not sure where to find those in hassos :(

aaburger85 commented 2 years ago

I think you just have to edit, configuration.yaml with:

logger:
  logs:
    custom_components.pfsense: debug

However, even with the debug level set, and setting verbose = True on the script im not getting any more context out of the logs.

travisghansen commented 2 years ago

Yeah, that does not use the logger but just pumps the logs to stdout/stderr of hass.

travisghansen commented 1 year ago

Is this still an issue?