pfSense integration with Home Assistant

Overview

hass-pfsense

Join pfSense with home-assistant!

hass-pfsense uses the built-in xmlrpc service of pfSense for all interactions. No special plugins or software needs to be installed to use the integration.

Initial development was done againt pfSense 2.5.2 and home-assistant 2021.10.

configuration

Configuration is managed entirely from the UI using config_flow semantics.

pfSense

  • System -> Advanced -> Max Processes - set it 5 or more.
  • If using a non admin user account ensure the user has the System - HA node sync privilege. Note that this privilege effectively gives the user complete access to the system via the xmlrpc feature.

config

  • URL - put the full URL to your pfSense installation (ie: http://pfSense.localdomain:8080)
  • Allow Insecure TLS - trust self-signed certs
  • username - the username to use for authentication (ie: admin)
  • password - the password to use for authentication
  • Firewall Name - a custom name to be used for entity naming (default: use the pfSense hostname)

options

  • Scan Interval (seconds) - scan interval to use for state polling (default: 30)
  • Enable Device Tracker - turn on the device tracker integration using pfSense arp table (default: false)
  • Device Tracker Scan Interval (seconds) - scan interval to use for arp updates (default: 60)

entities

Many entities are created by hass-pfsense for stats etc.

binary_sensor

  • carp status (enabled/disabled)

device_tracker

ScannerEntity entries are created for the pfSense arp table. Disabled by default.

Note that by default FreeBSD/pfSense use a max age of 20 minutes for arp entries (sysctl net.link.ether.inet.max_age). You may lower that using System -> Advanced -> System Tunables if desired.

sensor

  • system details (name, version, temp, boottime, etc)
  • pfstate details (used, max, etc)
  • cpu details (average load, frequency, etc)
  • mbuf details
  • memory details
  • filesystem usage
  • interface details (status, stats, pps, kbs (time samples are based on the Scan Interval (seconds) config option)), many are disabled by default so review disabled entities if you want more sensors
  • gateways details (status, delay, stddev, loss)
  • carp interface status

switch

All of the switches below are disabled by default.

  • filter rules - enable/disable rules
  • nat port forward rules - enable/disable rules
  • nat outbound rules - enable/disable rules
  • services - start/stop services
Comments
  • Issue: Everything goes unavailable

    Issue: Everything goes unavailable

    Home Assistant version: 2021.11.1 (Home Assistant Operating System) Component version: Latest

    Several times a minute, all entities from the pfsense component go unavailable. It seems like this is only happening when I use one of the switches to turn on/off a firewall rule but I can't be certain Logbook shows this (note: it shows the same for all entities)

    LAN: firewall_rule turned on
    6:58:45 PM - 4 minutes ago
    LAN: firewall_rule became unavailable
    6:58:07 PM - 5 minutes ago
    LAN: firewall_rule turned on
    6:57:27 PM - 5 minutes ago
    LAN: firewall_rule turned off
    6:55:59 PM - 7 minutes ago
    LAN: firewall_rule became unavailable
    6:55:55 PM - 7 minutes ago
    LAN: firewall_rule turned off
    6:55:15 PM - 8 minutes ago
    LAN: firewall_rule became unavailable
    6:55:11 PM - 8 minutes ago
    LAN: firewall_rule turned on
    6:49:51 PM - 13 minutes ago
    LAN: firewall_rule became unavailable
    6:49:47 PM - 13 minutes ago
    LAN: firewall_rule turned on
    6:43:52 PM - 19 minutes ago
    LAN: firewall_rule became unavailable
    6:43:17 PM - 20 minutes ago
    LAN: firewall_rule turned on
    6:35:43 PM - 27 minutes ago
    LAN: firewall_rule became unavailable
    6:35:03 PM - 28 minutes ago
    

    For troubleshooting this issue, I have:

    • Increased System -> Advanced -> Max Processes to as high as 30 but it didn't seem to have any effect.
    • Confirmed firewall rules allow this traffic
    • Restarted Home Assistant
    • Restarted the router
    • Ensured the user I created had the 'System - HA node sync' permission and then tried with full admin permissions
    • Increased scan interval to 60 seconds
    • Ran continual ping tests, see results below (left is my PC, right is from the HA host image

    Debug logs:

     18:38:14 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.329 seconds (success: True)
    2021-11-07 18:38:50 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.925 seconds (success: True)
    2021-11-07 18:39:26 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 6.019 seconds (success: True)
    2021-11-07 18:40:02 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 6.439 seconds (success: True)
    2021-11-07 18:40:37 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.122 seconds (success: True)
    2021-11-07 18:41:12 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.169 seconds (success: True)
    2021-11-07 18:41:47 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.410 seconds (success: True)
    2021-11-07 18:42:24 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 7.120 seconds (success: True)
    2021-11-07 18:43:00 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 6.950 seconds (success: True)
    2021-11-07 18:43:09 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139741298965040] The read operation timed out
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
        await hass.services.async_call(
      File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
        task.result()
      File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
        await handler.job.target(service_call)
      File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
        await self.hass.helpers.service.entity_service_call(
      File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 667, in entity_service_call
        future.result()  # pop exception if have
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 863, in async_request_call
        await coro
      File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 704, in _handle_entity_call
        await result
      File "/config/custom_components/pfsense/switch.py", line 250, in async_turn_off
        await self.hass.async_add_executor_job(client.disable_filter_rule_by_tracker, tracker)
      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/pfsense/pypfsense/__init__.py", line 163, in disable_filter_rule_by_tracker
        self._restore_config_section("filter", config["filter"])
      File "/config/custom_components/pfsense/pypfsense/__init__.py", line 53, in inner
        response = func(*args, **kwargs)
      File "/config/custom_components/pfsense/pypfsense/__init__.py", line 70, in _restore_config_section
        response = self._get_proxy().pfsense.restore_config_section(params, 60)
      File "/usr/local/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
        return self.__send(self.__name, args)
      File "/usr/local/lib/python3.9/xmlrpc/client.py", line 1458, in __request
        response = self.__transport.request(
      File "/usr/local/lib/python3.9/xmlrpc/client.py", line 1160, in request
        return self.single_request(host, handler, request_body, verbose)
      File "/usr/local/lib/python3.9/xmlrpc/client.py", line 1173, in single_request
        resp = http_conn.getresponse()
      File "/usr/local/lib/python3.9/http/client.py", line 1371, in getresponse
        response.begin()
      File "/usr/local/lib/python3.9/http/client.py", line 319, in begin
        version, status, reason = self._read_status()
      File "/usr/local/lib/python3.9/http/client.py", line 280, in _read_status
        line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
      File "/usr/local/lib/python3.9/socket.py", line 704, in readinto
        return self._sock.recv_into(b)
      File "/usr/local/lib/python3.9/ssl.py", line 1241, in recv_into
        return self.read(nbytes, buffer)
      File "/usr/local/lib/python3.9/ssl.py", line 1099, in read
        return self._sslobj.read(len, buffer)
    socket.timeout: The read operation timed out
    2021-11-07 18:43:17 ERROR (MainThread) [custom_components.pfsense] Timeout fetching pfSense state data
    2021-11-07 18:43:17 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 10.002 seconds (success: False)
    2021-11-07 18:43:18 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall switch.turn_off (c:f479d0c743a0c126144d6fbd1237eb01): entity_id=['switch.router_filter_rule_1604272216_ha_lan_routevpn']>
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/core.py", line 1511, in catch_exceptions
        await coro_or_task
      File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
        await handler.job.target(service_call)
      File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
        await self.hass.helpers.service.entity_service_call(
      File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 667, in entity_service_call
        future.result()  # pop exception if have
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 863, in async_request_call
        await coro
      File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 704, in _handle_entity_call
        await result
      File "/config/custom_components/pfsense/switch.py", line 251, in async_turn_off
        await self.coordinator.async_refresh()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_refresh
        await self._async_refresh(log_failures=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _async_write_ha_state
        if (icon := (entry and entry.icon) or self.icon) is not None:
      File "/config/custom_components/pfsense/sensor.py", line 427, in icon
        if property == "status" and self.native_value != "online":
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:43:52 INFO (MainThread) [custom_components.pfsense] Fetching pfSense state data recovered
    2021-11-07 18:43:52 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.462 seconds (success: True)
    2021-11-07 18:43:52 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:44:27 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.113 seconds (success: True)
    2021-11-07 18:44:27 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:45:02 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.220 seconds (success: True)
    2021-11-07 18:45:02 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:45:37 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.209 seconds (success: True)
    2021-11-07 18:45:37 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:46:12 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.075 seconds (success: True)
    2021-11-07 18:46:12 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:46:47 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.436 seconds (success: True)
    2021-11-07 18:46:47 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:47:22 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.095 seconds (success: True)
    2021-11-07 18:47:22 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:47:57 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.081 seconds (success: True)
    2021-11-07 18:47:57 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:48:32 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.276 seconds (success: True)
    2021-11-07 18:48:32 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    2021-11-07 18:49:07 DEBUG (MainThread) [custom_components.pfsense] Finished fetching pfSense state data in 5.105 seconds (success: True)
    2021-11-07 18:49:07 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval
        await self._async_refresh(log_failures=True, scheduled=True)
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh
        update_callback()
      File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
        self.async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state
        self._async_write_ha_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state
        state = self._stringify_state()
      File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state
        if (state := self.state) is None:
      File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 273, in state
        value = self.native_value
      File "/config/custom_components/pfsense/sensor.py", line 437, in native_value
        value = gateway[property]
    TypeError: 'NoneType' object is not subscriptable
    
    opened by JOHLC 100
  • No configuation options

    No configuation options

    I just installed this component (custom repository via HACS) and when I search the integrations list, it does not show. I can see it in the custom_components folder, so I believe I connected the repository and installed it correctly.

    How to I activate this integration?

    opened by withanhdammit 18
  • error after update

    error after update

    After today's update to 0.5.1 at HA restart:

    2022-07-06 20:26:23 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.pfsense.update
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/loader.py", line 618, in get_platform
        cache[full_name] = self._import_platform(platform_name)
      File "/usr/src/homeassistant/homeassistant/loader.py", line 635, in _import_platform
        return importlib.import_module(f"{self.pkg_path}.{platform_name}")
      File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
      File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 850, in exec_module
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "/config/custom_components/pfsense/update.py", line 93, in <module>
        class PfSenseFirmwareUpdatesAvailableUpdate(PfSenseUpdate):
      File "/config/custom_components/pfsense/update.py", line 107, in PfSenseFirmwareUpdatesAvailableUpdate
        def installed_version(self) -> str | None:
    TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
    2022-07-06 20:26:23 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform pfsense.update: Platform not found (Exception importing custom_components.pfsense.update).
    2022-07-06
    
    opened by nagyrobi 15
  • missing function openvpn_get_active_servers

    missing function openvpn_get_active_servers

    On latest update TAG 3.1 i get an error on the pfsense related to missing function openvpn_get_active_servers

    Crash report begins.  Anonymous machine information:
    
    amd64
    12.2-STABLE
    FreeBSD 12.2-STABLE 1b709158e581(RELENG_2_5_0) pfSense
    
    Crash report details:
    
    PHP Errors:
    [25-Dec-2021 10:40:02 Europe/Luxembourg] PHP Fatal error:  Uncaught Error: Call to undefined function openvpn_get_active_servers() in /usr/local/www/xmlrpc.php(145) : eval()'d code:54
    Stack trace:
    #0 /usr/local/www/xmlrpc.php(145): eval()
    #1 /usr/local/share/pear/XML/RPC2/Server/CallHandler/Instance.php(141): pfsense_xmlrpc_server->exec_php('\nini_set('displ...')
    #2 /usr/local/share/pear/XML/RPC2/Backend/Php/Server.php(135): XML_RPC2_Server_Callhandler_Instance->__call('pfsense.exec_ph...', Array)
    #3 /usr/local/share/pear/XML/RPC2/Backend/Php/Server.php(99): XML_RPC2_Backend_Php_Server->getResponse()
    #4 /usr/local/www/xmlrpc.php(883): XML_RPC2_Backend_Php_Server->handleCall()
    #5 {main}
      thrown in /usr/local/www/xmlrpc.php(145) : eval()'d code on line 54
    
    
    
    No FreeBSD crash data found.
    
    opened by orcema 15
  • Read timeout

    Read timeout

    I seem to be getting a similar read timeout with the 2022.8 update (worked before that).

    2022-08-13 18:32:10.680 ERROR (MainThread) [custom_components.pfsense] Unexpected error fetching Tonoli pfSense state data: The read operation timed out 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 await hass.async_add_executor_job(lambda: data.update()) File "/config/custom_components/pfsense/init.py", line 339, in update self._state["dhcp_leases"] = self._get_dhcp_leases() File "/config/custom_components/pfsense/init.py", line 229, in inner response = func(*args, **kwargs) File "/config/custom_components/pfsense/init.py", line 288, in _get_dhcp_leases return self._client.get_dhcp_leases() File "/config/custom_components/pfsense/pypfsense/init.py", line 665, in get_dhcp_leases response = 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 96, in _exec_php response = self._get_proxy().pfsense.exec_php(script) File "/usr/local/lib/python3.10/xmlrpc/client.py", line 1122, in call return self.__send(self.__name, args) File "/usr/local/lib/python3.10/xmlrpc/client.py", line 1464, in __request response = self.__transport.request( File "/usr/local/lib/python3.10/xmlrpc/client.py", line 1166, in request return self.single_request(host, handler, request_body, verbose) File "/usr/local/lib/python3.10/xmlrpc/client.py", line 1179, in single_request resp = http_conn.getresponse() File "/usr/local/lib/python3.10/http/client.py", line 1374, in getresponse response.begin() File "/usr/local/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/local/lib/python3.10/http/client.py", line 279, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/local/lib/python3.10/socket.py", line 705, in readinto return self._sock.recv_into(b) File "/usr/local/lib/python3.10/ssl.py", line 1274, in recv_into return self.read(nbytes, buffer) File "/usr/local/lib/python3.10/ssl.py", line 1130, in read return self._sslobj.read(len, buffer) TimeoutError: The read operation timed out

    opened by ricktonoli 14
  • Return date as datetime instead of string

    Return date as datetime instead of string

    In 2021.12.0 HomeAssistant expects datetime class sensors to return date/time objects instead of a string. You can wait to merge this until the day HA is released if you want but I added a minimum version in hacs.json because this would break things on older versions

    opened by raman325 14
  • Errors in pfSense

    Errors in pfSense

    Hi,

    Great integration and was looking forward to this. Now tested 0.1.0, 0.2.0 and 0.3.0 versions.

    I pretty quick get problems with my pfSense, it gets unresponsive and cannot log in using the web interface. Trying to log on gives me "502 Bad Gateway, nginx". Often this can be solved by using SSH and select option “16. Restart PHP-FFM”. But I am in the same situation after a while.

    Any ideas?

    //AseKarlsson

    opened by AseKarlsson 14
  • Feature Request: Ability to change DHCP assigned DNS servers

    Feature Request: Ability to change DHCP assigned DNS servers

    At times, this would be very useful if I could change the DNS server for DHCP clients based on when my regular DNS server is down which I like to use exclusively in certain cases. Could this be added? Thanks.

    opened by Iceman248 12
  • Add services to flush or kill entries from state table

    Add services to flush or kill entries from state table

    The way pfsense works, enabled firewall block rules are not applied to existing connections in the state table. Integration allows for firewall rules to be enabled or disabled, but a service is needed to clear the entire state table or kill specific state table entries after firewall block rules are enabled. Otherwise newly enabled firewall rule may not have the desired effect


    My use case for reference

    I need to remotely toggle a firewall rule to block streaming access to a specific camera subnet. Enabling the firewall rule from the integration works for new connections, but existing connections are not affected and existing connections in the state table must be flushed or killed before the enabled firewall rule will take effect.

    Options are: kill the existing connections or reset the entire state table to close all connections. Closing all connections on the firewall has some nasty side effects to innocent network clients, but flushing the state table may be necessary after making substantial changes to the firewall and/or NAT rules. Since I know the scope of my firewall rule ahead of time, I can use pfctl -k 0.0.0.0/0 -k camera_subnet to kill close only connections to the camera subnet, as opposed to the nuclear option of flushing the entire state table, after enabling the blocking rule to assure all connections are blocked

    opened by markfrancisonly 11
  • No Issues, just feedback.

    No Issues, just feedback.

    First, wow... This is great! I always hoped for a pfSense integration, but after not finding an API, gave up. I never knew about the XMLRPC stuff. So, Thanks!

    1. Is CPU utilization available? (Instead of just load).

    2. Could there be an option to make the integration read-only during config flow? I realize the switches are disabled by default, but they could easily be enabled by a bad actor if my publicly reachable HA instance was breached somehow. If the switches were never created during config flow, the pw would be required to make changes to the integration.

    Fortunately, my firewall rules are all "allow" type, so a bad actor could only make things more restrictive by turning them off. But, I'm sure not all people are configured that way. Just a thought, perhaps being paranoid.

    1. Is there access to any of the data from installed packages?

    Thanks again!

    opened by elmigbot 11
  • Integration not showing up after installing

    Integration not showing up after installing

    Hi,

    I installed the Hass-Pfsense integration in HACS. But after restarting the server I don't see the integration anywhere. In the readme it says 'Configuration is managed entirely from the UI using config_flow semantics.' so i expected the integration under configuration->Integrations. Also when i try to add in manually it can't find it in the list.

    I checked the log of Home assistant and the only event with a reference to pfSense is this: 2021-10-21 16:31:12 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration pfsense which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

    opened by rvanarkel 10
  • DeviceTracker don't use a static device name

    DeviceTracker don't use a static device name

    Hello, When you would add new devicetracker , if an older device is not online: this one is renamed with macaddress or same times deleted

    Could you use a static name (dhcplease) for identify devices?

    opened by PiranhaBgl 0
  • this add-on keeps becoming unavailable

    this add-on keeps becoming unavailable

    i gave this add-on the admin login account to be sure i have all the rights. however, the add on and devices it tracks keep becoming unavailable. any idea why?

    image

    image

    opened by tung256 3
  • Compatibility with PfSense 2.7.0 alpha

    Compatibility with PfSense 2.7.0 alpha

    I've recently updated from PfSense 2.6.0 to the devel snapshot 2.7.0.a.20221206.0600.

    I started receiving error notifications in the Pfsense web interface every 30 seconds with the message below.

    PHP ERROR: Type: 1, File: /etc/inc/util.inc, Line: 220, Message: Uncaught TypeError: flock(): supplied resource is not a valid stream resource in /etc/inc/util.inc:220
    Stack trace:
    #0 /etc/inc/util.inc(220): flock(Resource id #11, 3)
    #1 /usr/local/www/xmlrpc.php(990): unlock(Resource id #11)
    #2 {main}
      thrown
    

    Once I disabled the hass-pfsense integration in home assistant, I stopped receiving these errors. I suspect there is a compatibility issue with the new version of pfsense, that might require some changes to this hass-Pfsense plugin.

    To try and assist debugging this, please see below extracts from the Pfsense files in the stack trace (with a few lines of context preceding the trouble lines):

    /etc/inc/util.inc (lines 217-220):

    /* unlock configuration file */
    function unlock($cfglckkey = 0) {
    	if (!is_null($cfglckkey)) {
    		@flock($cfglckkey, LOCK_UN);
    

    /usr/local/www/xmlrpc.php (Lines 976-990):

    
    $xmlrpclockkey = lock('xmlrpc', LOCK_EX);
    
    XML_RPC2_Backend::setBackend('php');
    $HTTP_RAW_POST_DATA = file_get_contents('php://input');
    
    $options = array(
    	'prefix' => 'pfsense.',
    	'encoding' => 'utf-8',
    	'autoDocument' => false,
    );
    
    $server = XML_RPC2_Server::create(new pfsense_xmlrpc_server(), $options);
    $server->handleCall();
    
    unlock($xmlrpclockkey);
    
    opened by woodsb02 2
  • Feature Request - Cert Expiration sensor

    Feature Request - Cert Expiration sensor

    Hello,

    Checking in to see if is possible to capture the Certificate Expiration that is being created by the ACME service: https://<fpsense_url>/system_certmanager.php "Certificates" Tab

    image

    opened by DeFlanko 1
  • Feature request - DNS Resolver service status

    Feature request - DNS Resolver service status

    Hi. Im DNS Resolver is often crashing (probably not enough RAM) and i need to manually restart it. I would love to give other housemembers ability to restart it (or at least check its status) from within HA, without risking to give them access to the whole router. Would it be possible to implement this in the integration?

    opened by Dinth 0
Owner
Travis Glenn Hansen
Travis Glenn Hansen
Public HTTPS access to Home Assistant with Dataplicity service

Custom component for public HTTPS access to Home Assistant with Dataplicity service. Should work on any Linux PC or ARM, not only Raspberry as Dataplicity service said. Don't work on Windows.

Alex X 70 Oct 3, 2022
A lightweight python script that can monitor the T-Mobile Home Internet Nokia 5G Gateway for band and connectivity and reboot as needed.

tmo-monitor A lightweight Python 3 script that can monitor the T-Mobile Home Internet Nokia 5G Gateway for band and connectivity and reboot as needed.

null 61 Dec 17, 2022
A Python library to ease the integration with the Beem Africa (SMS, AIRTIME, OTP, 2WAY-SMS, BPAY, USSD)

python-client A Python library to easy the integration with the Beem Africa SMS Gateway Features to be Implemented Airtime OTP SMS Two way SMS USSD Bp

Beem Africa 24 Oct 29, 2022
TradingView Interactive Brokers Integration using Webhooks

TradingView Interactive Brokers Integration using Webhooks

null 84 Dec 19, 2022
Fully Automated YouTube Channel ▶️with Added Extra Features.

Fully Automated Youtube Channel ▒█▀▀█ █▀▀█ ▀▀█▀▀ ▀▀█▀▀ █░░█ █▀▀▄ █▀▀ █▀▀█ ▒█▀▀▄ █░░█ ░░█░░ ░▒█░░ █░░█ █▀▀▄ █▀▀ █▄▄▀ ▒█▄▄█ ▀▀▀▀ ░░▀░░ ░▒█░░ ░▀▀▀ ▀▀▀░

sam-sepiol 249 Jan 2, 2023
Universal Xiaomi MIoT integration for Home Assistant

Xiaomi MIoT Raw 简体中文 | English MIoT 协议是小米智能家居从 2018 年起推行的智能设备通信协议规范,此后凡是可接入米家的设备均通过此协议进行通信。此插件按照 MIoT 协议规范与设备通信,实现对设备的状态读取及控制。

null 1.9k Jan 2, 2023
Home Assistant custom integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, officially maintained by the Tuya Developer Team.

Tuya Home Assistant Integration Home Assistant custom integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, officially mainta

Tuya 704 Jan 3, 2023
Replacement for the default Dark Sky Home Assistant integration using Pirate Weather

Pirate Weather Integrations This integration is designed to replace the default Dark Sky integration in Home Assistant with a slightly modified, but f

Alexander Rey 129 Jan 6, 2023
Home Assistant custom integration for e-distribución

e-Distribución is an energy distribution company that covers most of South Spain area. If you live in this area, you probably are able to register into their website to get some information about your power demand, energy consumption, or even cycle billing (in terms of consumptions).

VMG 17 Sep 7, 2022
Home Assistant custom integration for Yi cameras: yi-hack-MStar, yi-hack-Allwinner and yi-hack-Allwinner-v2

yi-hack Home Assistant integration Overview yi-hack Home Assistant is a custom integration for Yi cameras (or Sonoff camera) with one of the following

roleo 131 Jan 3, 2023
Dahua Camera and Doorbell Home Assistant Integration

Home Assistant Dahua Integration The Dahua Home Assistant integration allows you to integrate your Dahua cameras and doorbells in Home Assistant. It's

Ronnie 216 Dec 26, 2022
Home Assistant integration for spanish electrical data providers (e.g., datadis)

homeassistant-edata Esta integración para Home Assistant te permite seguir de un vistazo tus consumos y máximas potencias alcanzadas. Para ello, se ap

VMG 163 Jan 5, 2023
Home Assistant integration for MyEnergi devices

myenergi for Home Assistant myenergi custom component for Home Assistant This is a very early release, will add more documentations soon! This compone

Johan Isacsson 70 Dec 18, 2022
Home Assistant integration for energy consumption data from UK SMETS (Smart) meters using the Hildebrand Glow API.

Hildebrand Glow (DCC) Integration Home Assistant integration for energy consumption data from UK SMETS (Smart) meters using the Hildebrand Glow API. T

Aniket 153 Dec 30, 2022
Electrolux Pure i9 robot vacuum integration for Home Assistant.

Home Assistant Pure i9 This repository integrates your Electrolux Pure i9 robot vacuum with the smart home platform Home Assistant. The integration co

Niklas Ekman 15 Dec 22, 2022
Water quality integration for Home Assistant with data provided by Budapest FVM

Water Quality FVM (Budapest, HU) custom integration for Home Assistant This custom component integrates water quality information provided by Budapest

Atticus Maximus 3 Dec 23, 2021
A Home Assistant integration for Solaredge inverters

A Home Assistant integration for Solaredge inverters. Supports multiple inverters chained through RS485.

Seth 50 Dec 23, 2022
Nordpool_diff custom integration for Home Assistant

nordpool_diff custom integration for Home Assistant Requires https://github.com/custom-components/nordpool Applies non-causal FIR differentiator1 to N

Joonas Pulakka 45 Dec 23, 2022
Smart EQ connect - Custom Integration for Home Assistant

Smart EQ Connect platform as a Custom Component for Home Assistant.

Rene Nulsch 2 Jan 4, 2022
OPNsense integration with Home Assistant

hass-opnsense Join OPNsense with home-assistant! hass-opnsense uses the built-in xmlrpc service of OPNsense for all interactions. This project is curr

Travis Glenn Hansen 54 Jan 3, 2023