So i found the part about SNMP here very helpful but i couldn’t wrap my head around the template and the stats part.
and the values i measured was way off (sometimes 1500Mbs when the router reported 500Mbs and other times 160Mbs when the router reported 140Mbs ) but i think i have found the problem and an alternative solution
i believe (not at all sure) that the change rate on the statistics is just how much the value changes for each update without any regards to time, but what you really want for this (turning the running total into Mb/s) is the derivative of the value you get from the router and luckily enough there is a build in sensor for that that will calculate the derivation and take the time between updates into account.
i have done it like this:
platform: snmp
name: 'ER lite WAN In'
host: 192.168.3.1
baseoid: 1.3.6.1.2.1.31.1.1.1.6.2
community: 'public'
version: '2c'
scan_interval: 10
platform: derivative
source: sensor.er_lite_wan_in
unit_time: s
unit: B
name: erl_wan_in_derivative
platform: template
sensors:
erl_wan_in_mbps:
value_template: "{{ ((states('sensor.erl_wan_in_derivative')|float*8)/1000000)|round(2) }}"
unit_of_measurement: 'Mbps'
entity_id: sensor.erl_wan_in_derivative
friendly_name: Internet in Dev
i did a little test with this where i integrated both this and the approach described other places in this thread where i would pick to points where i had a value on each and calculate how many MB had been transferred in that time span and then calculate an error for each of the approaches and i think the results speak for them self:
i hope this can help someone.