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
IP Pinger - This tool allows you to enter an IP and check if its currently connected to a host

IP Pinger - This tool allows you to enter an IP and check if its currently connected to a host

invasion 3 Feb 18, 2022
VRF-StarkNet - Contracts for verifiable randomness on StarkNet

VRF-StarkNet Contracts for verifiable randomness on StarkNet Motivation Deployed

Non 32 Oct 30, 2022
Build surface water network for MODFLOW's SFR Package

Surface water network Creates surface water network, which can be used to create MODFLOW's SFR. Python packages Python 3.6+ is required. Required geop

Mike Taves 20 Nov 22, 2022
Repo for investigation of timeouts that happens with prolonged training on clients

Flower-timeout Repo for investigation of timeouts that happens with prolonged training on clients. This repository is meant purely for demonstration o

1 Jan 21, 2022
TLD records archive. Revisiting the original TLDR project by mandatoryprogrammer, on the hunt for more root nameserver changes.

tldr A(nother) continuously updated historical TLD records archive. This repository is updated approximately every three hours with the results from D

Chris Partridge 11 Dec 14, 2022
This application aims to read all wifi passwords and visualizes the complexity in graph formation by taking into account several criteria and help you generate new random passwords.

This application aims to read all wifi passwords and visualizes the complexity in graph formation by taking into account several criteria and help you generate new random passwords.

Njomza Rexhepi 0 May 29, 2022
A great python/java dynamic DNS service for NameSilo, with log, email reminder...

English NameSilo DDNS is a DDNS service for NameSilo domain names for home broadband , it can automatically detect IP changes in home broadband

云牧青 77 Dec 28, 2022
Vent domain information retrieval tool, which is capable of retrieving customer information

Vent domain information retrieval tool, which is capable of retrieving customer information. This tool has been created for the purpose of complete education, Iam not responsible for any illegal acti

Md. Ridwanul Islam Muntakim 25 Dec 09, 2022
Octodns-cloudflare - Cloudflare DNS provider for octoDNS

CloudflareProvider provider for octoDNS An octoDNS provider that targets Cloudfl

octoDNS 6 May 28, 2022
An opensource library to use SNMP get/bulk/set/walk in Python

SNMP-UTILS An opensource library to use SNMP get/bulk/set/walk in Python Features Work with OIDS json list [Find Here](#OIDS List) GET command SET com

Alexandre Gossard 3 Aug 03, 2022
Azure-function-proxy - Basic proxy as an azure function serverless app

azure function proxy (for phishing) here are config files for using *[.]azureweb

17 Nov 09, 2022
BlueHawk is an HTTP/1.1 compliant web server developed in python

This project is done as a part of Computer Networks course. It aims at the implementation of the HTTP/1.1 Protocol based on RFC 2616 and includes the basic HTTP methods of GET, POST, PUT, DELETE and

2 Nov 11, 2022
A benchmark for stateful fuzzing of network protocols

A benchmark for stateful fuzzing of network protocols

3 Apr 25, 2022
Herramienta para transferir eventos de Shadowserver REST API hacia Azure Blob Storage.

Herramienta para transferir eventos de Shadowserver REST API hacia Azure Blob Storage.

CSIRT-RD 1 Feb 04, 2022
This is the code repository for the USENIX Security 2021 paper, "Weaponizing Middleboxes for TCP Reflected Amplification".

weaponizing-censors Censors pose a threat to the entire Internet. In this work, we show that censoring middleboxes and firewalls can be weaponized by

UMD Breakerspace 119 Dec 31, 2022
Ping IP addresses and domains in parallel to find the accessible and inaccessible ones.

🚀 IPpy Parallel testing of IP addresses and domains in python. Reads IP addresses and domains from a CSV file and gives two lists of accessible and i

Shivam Mathur 54 May 21, 2022
Arp-spoofing, this script was written for people who want to spoof any vulnerable machine such as Wİndows, of course it could have been more sophisticatedly created but these repos will be updated constantly

ARP-SPOOF ARP spoofing is a type of attack in which a malicious actor sends falsified ARP (Address Resolution Protocol) messages over a local area net

2 Dec 28, 2021
Python tutorial for implementing Oxylabs' Residential Proxies with AIOHTTP

Integrating Oxylabs' Residential Proxies with AIOHTTP Requirements for the Integration For the integration to work you'll need to install aiohttp libr

Oxylabs.io 6 Sep 14, 2022
Socket programming is a way of connecting two nodes on a network to communicate with each other

Socket Programming in Python Socket programming is a way of connecting two nodes on a network to communicate with each other. One socket(node) listens

Janak raikhola 1 Jul 05, 2022
An advanced real time threat intelligence framework to identify threats and malicious web traffic on the basis of IP reputation and historical data.

ARTIF is a new advanced real time threat intelligence framework built that adds another abstraction layer on the top of MISP to identify threats and malicious web traffic on the basis of IP reputatio

CRED 225 Dec 31, 2022