pfSense stat monitor

This is a bit off topic, but I figured a few of you might be interested in this. Here is how to setup a bandwidth SNMP polling for your pfSence WAN interface. This will give you the following entities for your viewing pleasure:

image

You will need to enable SNMP read access on your firewall, I used the community string of “public”. Be sure to change the host IP below to your pfSense internal interface.

sensor:
  - platform: snmp
    name: 'pfsense WAN in'
    host: 10.1.1.1
    baseoid: 1.3.6.1.2.1.31.1.1.1.6.2
    community: 'public'
    version: '2c'
    scan_interval: 60

  - platform: snmp
    name: 'pfsense WAN out'
    host: 10.1.1.1
    baseoid: 1.3.6.1.2.1.31.1.1.1.10.2
    community: 'public'
    version: '2c'
    scan_interval: 60

  - platform: statistics
    name: 'pfsense WAN in Stats'
    entity_id: sensor.pfsense_wan_in
    sampling_size: 4
    max_age:
      hours: 24

  - platform: statistics
    name: 'pfsense WAN out Stats'
    entity_id: sensor.pfsense_wan_out
    sampling_size: 4
    max_age:
      hours: 24

  - platform: template
    sensors:
      internet_in_mbps:
        icon_template: mdi:cloud-download-outline
        value_template: "{{ (state_attr('sensor.pfsense_wan_in_stats','change_rate')|float*8*(state_attr('sensor.pfsense_wan_in_stats', 'sampling_size')-1)/1000000)|round(2) }}"
        unit_of_measurement: 'Mbps'
        entity_id: sensor.pfsense_wan_in_stats
      internet_out_mbps:
        icon_template: mdi:cloud-upload-outline
        value_template: "{{ (state_attr('sensor.pfsense_wan_out_stats','change_rate')|float*8*(state_attr('sensor.pfsense_wan_out_stats', 'sampling_size')-1)/1000000)|round(2) }}"
        unit_of_measurement: 'Mbps'
        entity_id: sensor.pfsense_wan_out_stats
8 Likes