SNMP bandwidth monitor using statistics

Thanks for that. This is what I got for the Edgerouter X (comments show my WAN interfaces)

iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo"
iso.3.6.1.2.1.31.1.1.1.1.2 = STRING: "switch0"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "imq0"
iso.3.6.1.2.1.31.1.1.1.1.4 = STRING: "eth0" #WAN NBN
iso.3.6.1.2.1.31.1.1.1.1.5 = STRING: "eth1" #WAN 4G backup
iso.3.6.1.2.1.31.1.1.1.1.6 = STRING: "eth2"
iso.3.6.1.2.1.31.1.1.1.1.7 = STRING: "eth3"
iso.3.6.1.2.1.31.1.1.1.1.8 = STRING: "eth4"

I duplicated your sensors for my WAN interfaces, made a real mess a few times and then fixed it. Final config:

- platform: snmp
  name: 'ERX NBN WAN In'
  host: 10.1.1.1
  baseoid: 1.3.6.1.2.1.31.1.1.1.6.4
  community: 'public'
  version: '2c'
  scan_interval: 10
- platform: snmp
  name: 'ERX NBN WAN Out'
  host: 10.1.1.1
  baseoid: 1.3.6.1.2.1.31.1.1.1.10.4
  community: 'public'
  version: '2c'
  scan_interval: 10
- platform: statistics
  name: 'ERX NBN WAN In Stats'
  entity_id: sensor.erx_nbn_wan_in
  sampling_size: 4
  max_age:
    hours: 24
- platform: statistics
  name: 'ERX NBN WAN Out Stats'
  entity_id: sensor.erx_nbn_wan_out
  sampling_size: 4
  max_age:
    hours: 24
- platform: template
  sensors:
    nbn_internet_in_mbps:
      value_template: "{{ (state_attr('sensor.erx_nbn_wan_in_stats_mean','change_rate')|float*8*(state_attr('sensor.erx_nbn_wan_in_stats_mean', 'sampling_size')-1)/1000000)|round(2) }}"
      unit_of_measurement: 'MBps'
      entity_id: sensor.erx_nbn_wan_in_stats_mean
    nbn_internet_out_mbps:
      value_template: "{{ (state_attr('sensor.erx_nbn_wan_out_stats_mean','change_rate')|float*8*(state_attr('sensor.erx_nbn_wan_out_stats_mean', 'sampling_size')-1)/1000000)|round(2) }}"
      unit_of_measurement: 'MBps'
      entity_id: sensor.erx_nbn_wan_out_stats_mean

- platform: snmp
  name: 'ERX 4G WAN In'
  host: 10.1.1.1
  baseoid: 1.3.6.1.2.1.31.1.1.1.6.5
  community: 'public'
  version: '2c'
  scan_interval: 10
- platform: snmp
  name: 'ERX 4G WAN Out'
  host: 10.1.1.1
  baseoid: 1.3.6.1.2.1.31.1.1.1.10.5
  community: 'public'
  version: '2c'
  scan_interval: 10
- platform: statistics
  name: 'ERX 4G WAN in Stats'
  entity_id: sensor.erx_4g_wan_in
  sampling_size: 4
  max_age:
    hours: 24
- platform: statistics
  name: 'ERX 4G WAN out Stats'
  entity_id: sensor.erx_4g_wan_out
  sampling_size: 4
  max_age:
    hours: 24
- platform: template
  sensors:
    4g_internet_in_mbps:
      value_template: "{{ (state_attr('sensor.erx_4g_wan_in_stats_mean','change_rate')|float*8*(state_attr('sensor.erx_4g_wan_in_stats_mean', 'sampling_size')-1)/1000000)|round(2) }}"
      unit_of_measurement: 'MBps'
      entity_id: sensor.erx_4g_wan_in_stats_mean
    4g_internet_out_mbps:
      value_template: "{{ (state_attr('sensor.erx_4g_wan_out_stats_mean','change_rate')|float*8*(state_attr('sensor.erx_4g_wan_out_stats_mean', 'sampling_size')-1)/1000000)|round(2) }}"
      unit_of_measurement: 'MBps'
      entity_id: sensor.erx_4g_wan_out_stats_mean

Thanks Heaps for this.

Screenshot_2019-08-22%20Home%20Assistant

8 Likes