Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add support for Mbits as a unit #84

Closed
clearwave1 opened this issue Nov 17, 2022 · 8 comments
Closed

Feature Request: Add support for Mbits as a unit #84

clearwave1 opened this issue Nov 17, 2022 · 8 comments

Comments

@clearwave1
Copy link

clearwave1 commented Nov 17, 2022

Most internet speed checks and the Ubiquiti Edgerouter uses megabits as the unit they report.

I have edited your code updates for over a year to add this feature for my own uses but it is so simple I thought maybe you could offer it to everyone.

All that is needed is the following in const.py:
MEGA_BIT = MEGA_BYTE / 8.4 (I came up with 8.4 by experimenting against the actual Edgerouter output)
ATTR_MBIT = "MBits"
UNIT_MAPPING = {
ATTR_BYTE: BYTE,
ATTR_KILO: KILO_BYTE,
ATTR_MEGA: MEGA_BYTE,
ATTR_MBIT: MEGA_BIT
}

UNIT_OF_MEASUREMENT_MAPPING = {
ATTR_BYTE: "B",
ATTR_KILO: "KB",
ATTR_MEGA: "MB",
ATTR_MBIT: "Mb"
}

Thanks in advance for considering this.

@clearwave1
Copy link
Author

@elad-bar - would you consider adding this or should I submit a pull request?

@elad-bar
Copy link
Owner

elad-bar commented Dec 3, 2022

I personally not going to use Mbits...

How would you like to implement it in terms of user's configuration?

Btw, bit / byte ratio is exactly 8, compared it in the past with the data extarcted by snmp, ui and unms,
unless you have found an official documentation that says otherwise, i suggest stick to it.

@clearwave1
Copy link
Author

Mbits is appropriate when watching upload/download speed real-time. This is also what Ookla and other speed test tools use.

I'm using this on the WAN interfaces to monitor the speed we're getting and using with each provider. Using Mbits for something like total download likely doesn't make sense so it would be optimal if the user could pick the metric per entity.

Finally, I'm an IT guy from way back so I'm aware that there are 8 bits to a byte. However, dividing your MEGA_BYTE variable by 8 does not come up with the same value that the router shows. I'm wondering whether your MEGA_BYTE value is possibly not correct. For me, the way around this after a bunch of testing was to use 8.4 as a divisor. Using 8.4 I get very close to the same value that the router shows (in Mbits).

By adding the code above, I am able to choose Mbits from your choice of units and get the values from the router in real-time in Mbits.

@elad-bar
Copy link
Owner

elad-bar commented Mar 2, 2023

please check release v2.0.27

thanks

@clearwave1
Copy link
Author

Where in the code do you do the unit calculation now? It appears that it has moved out of const.py.

@elad-bar
Copy link
Owner

elad-bar commented Mar 2, 2023

right, it is being done as part of the HA core functionality,
please take a look at issue #90

@clearwave1
Copy link
Author

I tried it and it now works as expected without me having to update your code each release.

Thanks very much for adding this.

@elad-bar
Copy link
Owner

elad-bar commented Mar 2, 2023

Thanks for the update, glad it works for you

@elad-bar elad-bar closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants