Thanks, the derivative method has been giving me more accurate readings. Except every once in a while, it was resulting up with a really large negative numbers (which screws up the graph view). Not sure what’s causing it (possibly my router misreporting…), but added a max function to ignore those results.
I’m wondering if with this data I can create a new template sensor or something like that to view the total traffic by day and month, would be possible?
I cant see your image. The host is blocked here. Just drag your image file into the post on the forum.
EDIT: ok that is because the sensors do not have a unit. You will probably want to change that from bytes to MB anyway. Also you have a few errors in your templates (using the in sensor for the out template).
If you are on version 0.117.x this should work:
sensor:
- platform: snmp
name: 'ERX WAN In'
host: 192.168.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 WAN Out'
host: 192.168.1.1
baseoid: 1.3.6.1.2.1.31.1.1.1.10.4
community: 'public'
version: '2c'
scan_interval: 10
- platform: derivative
source: sensor.erx_wan_in
unit_time: s
unit: B
name: erx_wan_in_derivative
- platform: derivative
source: sensor.erx_wan_out
unit_time: s
unit: B
name: erx_wan_out_derivative
- platform: template
sensors:
erx_wan_in_mbps:
value_template: "{{ (states('sensor.erx_wan_in_derivative')|float*8/1000000)|round(2) }}"
unit_of_measurement: 'Mbps'
friendly_name: Internet in Dev
erx_wan_out_mbps:
value_template: "{{ (states('sensor.erx_wan_out_derivative')|float*8/1000000)|round(2) }}"
unit_of_measurement: 'Mbps'
friendly_name: Internet out Dev
erx_wan_download_mib:
value_template: "{{ (states('sensor.erx_wan_in')|float/1000000)|round(2) }}"
unit_of_measurement: 'MiB'
friendly_name: Internet in Dev
erx_wan_upload_mib:
value_template: "{{ (states('sensor.erx_wan_out')|float/1000000)|round(2) }}"
unit_of_measurement: 'MiB'
friendly_name: Internet out Dev
utility_meter:
wan_in_monthly:
source: sensor.erx_wan_download_mib
cycle: monthly
wan_in_daily:
source: sensor.erx_wan_download_mib
cycle: daily
wan_out_monthly:
source: sensor.erx_wan_upload_mib
cycle: monthly
wan_out_daily:
source: sensor.erx_wan_upload_mib
cycle: daily
if someone have the same problem with pppoe interface on a Ubiquiti USG, that change the OID randomly every time it restart, I created an appdaemon app to retrieve the data via SNMP and put on 2 HA entities