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
An automatic web reconnaissance tool written in python3.

WebRecon is an automatic web reconnaissance tool written in python3. Provides a command line interaction similar to msfconsole. The Exasmple.py file is provided, and you can write your own scripts yo

prophet 1 Feb 06, 2022
Top server mcpe Indonesia!

server_mcpe Top server mcpe Indonesia! install pkg install python pkg install git git clone https://github.com/Latip176/server_mcpe cd server_mcpe pip

Muhammad Latif Harkat 2 Jul 17, 2022
Throttle rTorrent on Plex stream Start/Stop

Dependencies Python 3.6+ Tautulli Script Setup Edit rtorrent_throttle.py and set rTorrent username, password and RPC2 url. Tautulli Setup Commum Scrip

4 Apr 25, 2022
A repository to spoof ARP table of any devices and successfully establish Man in the Middle(MITM) attack using Python3 in Linux

arp_spoofer A repository to spoof ARP table of any devices and successfully establish Man in the Middle(MITM) attack using Python3 in Linux Usage: git

Surya Das N 1 Oct 30, 2021
Godzilla traffic decoder Godzilla Decoder 是一个用于 哥斯拉Godzilla 加密流量分析的辅助脚本。

Godzilla Decoder 简介 Godzilla Decoder 是一个用于 哥斯拉Godzilla 加密流量分析的辅助脚本。 Godzilla Decoder 基于 mitmproxy,是mitmproxy的addon脚本。 目前支持 哥斯拉3.0.3 PhpDynamicPayload的

He Ruiliang 40 Dec 25, 2022
Discord RPC Generator With Python

Discord-RPC-Generator Thank you for using this Discord Custom RP Generator. This is 100% safe and open source. Download Discord for your computer here

1 Nov 09, 2021
A Project to resolve hostname and receive IP

hostname-resolver A Project to resolve hostname and receive IP Installation git clone https://github.com/ihapiw/hostname-resolver.git Head into the ho

iHapiW 5 Sep 12, 2022
This is a top level socket library, making servers and clients EASY!

quick-net Sockets don't have to be a pain That's the motto this library was built with, and that's exactly what we made! This is a top-level socket li

Nate the great 15 Dec 17, 2021
Simple Port Scanner With Socket Module In Python 3x

PortScanner Simple Port Scanner With Socket Module In Python 3x How To Install Requirements Of This Port Scanner sudo apt install python3;sudo apt ins

1 Nov 23, 2021
pyWhisker is a Python equivalent of the original Whisker made by Elad Shamir and written in C#.

PyWhisker pyWhisker is a Python equivalent of the original Whisker made by Elad Shamir and written in C#. This tool allows users to manipulate the msD

Shutdown 325 Jan 08, 2023
Burp Extension that copies a request and builds a FFUF skeleton

ffuf is gaining a lot of traction within the infosec community as a fast portable web fuzzer. It has been compared and aligned (kinda) to Burp's Intruder functionality. Thus, Copy As FFUF is trying t

Desmond Miles 81 Dec 22, 2022
Some files casually made by @AneekBiswas

Python-Tools All Pyhthon Files are created and managed by @AneekBiswas Modules needed to be downloaded 1.CLI bagels.py random guess.py random text-tow

1 Feb 23, 2022
A Python script that alerts via SMS when a stock is reaching an inflection point

TradeAlert Not sure what this will ultimately become, but for now, its a Python script that alerts via SMS when a stock is reaching an inflection poin

3 Feb 22, 2022
Data Exfiltration without ever making a connection. Using TCP header space.

TCPwned PoC toy code to exfiltrate data without ever making a TCP connection. This will never show up in firewall logs, much less, actually be monitor

2 Nov 21, 2022
GNS3 Graphical Network Simulator

GNS3-gui GNS3 GUI repository.

GNS3 1.7k Dec 29, 2022
A Simple but Powerful cross-platform port scanning & and network automation tool.

DEDMAP is a Simple but Powerful, Clever and Flexible Cross-Platform Port Scanning tool made with ease to use and convenience in mind. Both TCP

Anurag Mondal 30 Dec 16, 2022
A python 3 library which helps in using nmap port scanner.

A python 3 library which helps in using nmap port scanner. This is done by converting each nmap command into a callable python3 method or function. System administrators can now automatic nmap scans

Nmmapper 179 Dec 19, 2022
Simple HTTP Server for CircuitPython

Introduction Simple HTTP Server for CircuitPython Dependencies This driver depen

Adafruit Industries 22 Jan 06, 2023
Usbkill - an anti-forensic kill-switch that waits for a change on your USB ports and then immediately shuts down your computer.

Usbkill - an anti-forensic kill-switch that waits for a change on your USB ports and then immediately shuts down your computer.

Hephaestos 4.1k Dec 30, 2022
A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.

A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.

George O 929 Jan 01, 2023