No sorry I don’t have access to that information. I use it to monitor the realtime traffic rather than total usage over time, so can’t speak to the long term accurancy
I have perfected the config since and haven’t had to touch it anymore. Now my counters match the ISP ±1% and all measurements are reliable. This is a diagram of what I came up with eventually for each interface and traffic direction (up, down) to monitor:
sensor:
- platform: snmp
name: "WAN Interface Down Octets"
unique_id: wan_interface_down_octets
host: 192.168.150.1
version: "3"
username: !secret isr_snmp_user
auth_key: !secret isr_snmp_auth_key
auth_protocol: "hmac-sha"
priv_key: !secret isr_snmp_priv_key
priv_protocol: "aes-cfb-128"
# ifHCInOctets G0/0/0.
# Running total of octects (Bytes) going into the interface since router reboot.
baseoid: 1.3.6.1.2.1.31.1.1.1.6.1
state_class: total_increasing
icon: mdi:cloud-download
unit_of_measurement: "B"
- platform: derivative
# Calculate the throughput by sampling the SNMP sensor
name: "Network - WAN Down Throughput - Bps"
source: sensor.network_wan_interface_down_octects
unit_time: s
round: 2
template:
- sensor:
- name: "WAN Down Throughput"
unique_id: wan_down_throughput
unit_of_measurement: Mbps
icon: mdi:cloud-download
# Convert throughput derivative from Bps to Mbps
state: "{{ ((states('sensor.network_wan_down_throughput_bps') | int) * 8 / 10**6) | round(1) }}"
state_class: measurement
- name: "WAN Down Usage"
unique_id: wan_down_usage
unit_of_measurement: GiB
icon: mdi:cloud-download
# Convert usage meter below from B to GiB
state: "{{ ((states('sensor.network_wan_down_data_usage_meter_bytes') | int) / 2**30) | round(2) }}"
state_class: total_increasing
utility_meter:
network_wan_down_data_usage_meter_bytes:
unique_id: network_wan_down_data_usage_meter_bytes
name: Network - WAN Down Data Usage Meter - Bytes
source: sensor.wan_interface_down_octets
cycle: monthly
offset:
hours: 72
minutes: 0
seconds: 0
Correct, no negatives. The accuracy of the readings is critical because I always get within a hair of my data limit and the ISP will ding me $10 per 100 GB above.
I still get negatives in throughoutput for a split second or so during spikes. I dont think you see it since you are using gauges for throughouts. Try using a graph and use a speedtest.
…Anyway, i fixed it by adding a max to the formula in the template sensor:
I tested with an automation that notifies if the throughput goes negative and it didn’t happen running a couple of speed tests. Have you checked that the problem is not the SNMP data?
Remember that integer (32-bit) values counting bytes will wrap fairly regularly. Calculating a difference (derivative) at that point will cause a large negative value. I have a solution for that somewhere on this thread. It’s not an issue for 64-bit values — at least not during a normal lifetime at current Internet speeds.
I beg to differ, seen it happen when adding interface boards to big routers. Tools like Cacti can re-index, but HA is not a network grapher by design as Cacti is
Im looking to monitor the WAN stats in and out on the Ubiquiti UDR, however it doesnt seem to have the ability to provide SNMP traffic from the UDR itself. Any ideas? The Ubuiti Integration doesnt provide them.