8000 Add Bbox Router bandwidth as sensors by HydrelioxGitHub · Pull Request #3956 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add Bbox Router bandwidth as sensors #3956

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

Merged
merged 3 commits into from
Oct 22, 2016
Merged

Add Bbox Router bandwidth as sensors #3956

merged 3 commits into from
Oct 22, 2016

Conversation

HydrelioxGitHub
Copy link
Contributor
@HydrelioxGitHub HydrelioxGitHub commented Oct 19, 2016

Description:
Add possibility to monitor max and currently used bandwidth of your xdsl connection for Bbox Routeur

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#1292
Example entry for configuration.yaml (if applicable):

sensor:
  - platform: bbox
    monitored_variables:
      - down_max_bandwidth
      - up_max_bandwidth
      - current_down_bandwidth
      - current_up_bandwidth

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

Add possibility to monitor max and currently used bandwidth of your xdsl connection for Bbox Routeur
@mention-bot
Copy link

@HydrelioxGitHub, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @robbiet480 and @fabaff to be potential reviewers.

fabaff
fabaff previously requested changes Oct 20, 2016
@@ -0,0 +1,144 @@
"""
Support for Bbox Bouygues Modem Routeur.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups translating mistake, thank you.

@@ -228,6 +228,10 @@
VOLUME_GALLONS = 'gal' # type: str
VOLUME_FLUID_OUNCE = 'fl. oz.' # type: str

# Bandwidth units
BANDWIDTH_MEGABITS_SECONDS = 'Mbps' # type: str
BANDWIDTH_GIGABITS_SECONDS = 'Gbps' # type: str
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other sensors are already using the form MB/s and not the abbreviation Mbps. I think that we should stick with the existing format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why there is not unit of this kind in the const.py ?
Anyway Mb/s and MB/s are not the same unit. The small b means bit, the other (B) means byte (https://www.softperfect.com/contact/knowledgebase.php?article=10)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if only one platform need something we don't add it to const.py. Then the constants should only be defined in the platform itself. Well, it looks like that we are not consistent with those units anyway.

I was talking about the form for the units...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok maybe for this PR I will put these units in the sensor file. I will look for other composent that used this kind of units. If there are a few component usine thèses, I will make another PR to gather all in the const.py file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a plan. See tracking issue.

@@ -385,3 +389,4 @@
TEMPERATURE = 'temperature' # type: str
SPEED_MS = 'speed_ms' # type: str
ILLUMINANCE = 'illuminance' # type: str
BANDWIDTH = 'bandwidth' # type: str
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make much sense to add constants which are not used. If needed new constants can be added every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I planned to use it, but not on this PR. And I forgot to remove it on the commit. Thanks again

@property
def state(self):
"""Return the state of the sensor."""
return round(self._state, 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should move the rounding to the calculations in update().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rouding and divided by 1000 should both be in the state method because the update purpose is just to refresh data and not not make some transformation on it.

But I'm maybe wrong. Can you add some details on why this should be at one place or not ? (It will be useful for me for future development)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason to keep it at one place is simple, better maintainability. No need to search over the whole file if you want to change something. Most platforms are doing it in update() and just returning the state here.

# Create a data fetcher to support all of the configured sensors. Then make
# the first call to init the data.
try:
bbox_data = BboxData()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No configuration needed? No password, username, IP of the router, not even defaults?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because the bbox is provided to be plug and play so IP the box give to itself is always 192.168.1.254 . And credentials are only needed for critical operation (reboot of the router for example). Restriction is you can only use this API on your local network

@HydrelioxGitHub HydrelioxGitHub changed the title Add Bbox Routeur bandwidth as sensors Add Bbox Router bandwidth as sensors Oct 20, 2016
Unit constant get back into the main sensor file
@balloob balloob dismissed fabaff’s stale review October 22, 2016 04:34

Comment addressed

@balloob balloob merged commit 1d2d338 into home-assistant:dev Oct 22, 2016
@HydrelioxGitHub HydrelioxGitHub deleted the bbox-sensor branch February 14, 2017 01:05
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0