Closed wdullaer closed 5 years ago
Nice!
I figured out why the bytes are resetting every now and then. I noticed (through the home-assistant log) that the reset happens around 4.3 GB, which happens to be 2^32-1, the max value of an unsigned 32 int. So my router kernel is using an unsigned int to count the bytes which essentially overflows and loops around to zero. Unless I find some other field to look at (which I doubt), we will only be able to accurately report on total data transfer by keeping some additional state somewhere else. All of this is on an RT-N66U, hopefully newer routers have a 64 bit architecture and use a 64 bit int for the counters
I figured out why the bytes are resetting every now and then. I noticed (through the home-assistant log) that the reset happens around 4.3 GB, which happens to be 2^32-1, the max value of an unsigned 32 int. So my router kernel is using an unsigned int to count the bytes which essentially overflows and loops around to zero. Unless I find some other field to look at (which I doubt), we will only be able to accurately report on total data transfer by keeping some additional state somewhere else. All of this is on an RT-N66U, hopefully newer routers have a 64 bit architecture and use a 64 bit int for the counters
Yes, I think that an frontend hack might be the way to go in the future for this.
https://travis-ci.org/kennedyshead/aioasuswrt
It was setup before :/
You will have to create a new PR with that fix
For travis, I think you need to rename travis.yaml
to .travis.yml
It must have been changed at some point, its correctly named now
Renamed
async_get_packets_total
toasync_get_bytes_total
to better represent what it is doing. This will require a change in the home-assistant sensor code, since it was part of the public API.async_get_bytes_total
now relies onasync_get_rx
andasync_get_tx
Removed cache parameter from
async_get_rx
andasync_get_tx
; it was not used andasync_get_bytes_total
is already doing cachingMake
async_get_rx
andasync_get_tx
return integersFixes #21
There seems to be an issue where the counters on my router are reset every 12 hours. According to the kernel documentation, this should not happen (counters are only reset on reboot or when the interface module is unloaded). A potential further improvement could be to pass in the name of the interface, so we can expose more sensors (WAN traffic, WLAN traffic, Guest wifi traffic etc)