After finding that the IGP integration maxes out at 32bit counters (which is a day or less of traffic), I looked into other ways of making my internet usage visible. I looked long and hard at SNMP Bandwidth Monitor but somehow it didn’t feel right/easy.
This uses the 64 bit counters. If your router doesn’t have those, use 1.3.6.1.2.1.2.2.1.10.10 and 1.3.6.1.2.1.2.2.1.16.10 or similar.
I find this solution quite elegant because it only needs 3x2 sensors (SNMP, statistics, bandwidth) and the final sensor can be used in Lovelace right away.
You can customize the scan_interval and the sampling_size for smoother or more current values. When changing the latter, make sure you set sampling_size-1 as the factor in the template sensor (3 in my config because my sampling_size is 4). Scratch that, I added a state_attr to take care of that.
I’m relatively certain the OIDs are the same. These are generic SNMP MIBs that are used across many vendors. And the USG is basically an ER with some minor software differences. The only real difference could be the last number (2 in my case) because that defines the interface which is read. To find out the interface names, use
snmpbulkwalk -v 2c -c public 192.168.2.1 1.3.6.1.2.1.31.1.1.1.18
or
snmpbulkwalk -v 2c -c public 192.168.2.1 1.3.6.1.2.1.31.1.1.1.1
You cannot do that at the router level - the router reports (via SNMP) traffic statistics only at the interface level.
You might be able to do that if your TV is on a wired connection, and you have a switch that can report utilization on the interface connected to the TV (via SNMP).
Thank you, my TV is on a wired connection to a Unifi USG.
In the controller there is “Activity” under “statistics” when I click on the TV which is supposed to show me the bandwidth/throughput but it’s always showing as 0bps for some reason for any/all clients
Unifi only shows the bandwidth at the switch level anyway, so without a USW these numbers will always be 0. I can check on my switch if I can get bandwidth per port from it via SNMP, but I wouldn’t think it does that.
Yes, the USW reports counters per port, so if you have a USW you can use this plugin to monitor traffic on the switch port your TV is connected to. Other option is to put it on a separate VLAN, because that will become a new interface in the USG and that will report separate numbers.
Putting the TV on a separate VLAN sounds like a good workaround.
What would be the next steps? How can I set it up so HA can trigger automations based on that VLANs change in bandwidth? Also most importantly I don’t know the first thing about obtaining the OIDs for the VLAN
@seidler first off, thanks for this post! I already started to implement the other alternative you linked and did not like it either. Your solution seems much nicer!
Thanks for this. I Struggled to find my own OID, but I got it to work.
But I noticed that sometimes some negatives values are calculated for both in and out sensors (mbps).
Did you notice any issue like this? So the graph turns to be a mess. But most of the time, numbers seem to be right.
Based on this topic I tried to port this to my own situation, using a Unifi 8 port 60W switch.
Actually it is working, but for some reason the calculation back to Mbps is not in sync what I see on my Unifi controller, for example:
My ISP max download speed is 60Mbps, and while I download at full speed the sensor shows 210Mbps.
I am using the uplink of the switch towards my ISP router, which should not carry more than my max ISP speeds (and the Unifi Controller is reporting only the maximum ISP speeds)
Probably somebody has an idea what might do the trick in my situation?
This is what my config looks like: