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

Added fritzbox_netmonitor.py #5469

Merged
merged 2 commits into from
Feb 14, 2017

Conversation

PetePriority
Copy link
Contributor

@PetePriority PetePriority commented Jan 20, 2017

Description:
Adds a system-monitor sensor that provides various network related statistics of AVM Fritz!Box routers.

Pull request in home-assistant.github.io with documentation: home-assistant/home-assistant.io#1839

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: fritzbox_netmonitor
    host: 192.168.1.1
    resources:
      - type: is_linked
      - type: is_connected
      - type: wan_access_type
      - type: external_ip
      - type: uptime
      - type: bytes_sent
      - type: bytes_received
      - type: transmission_rate_up
      - type: transmission_rate_down
      - type: max_byte_rate_up
      - type: max_byte_rate_down
      - type: max_bit_rate_up
      - type: max_bit_rate_down

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.

@mention-bot
Copy link

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

_LOGGER = logging.getLogger(__name__)

SENSOR_TYPES = {
'is_linked': ['Link active', '', 'mdi:web'],
Copy link
Member

Choose a reason for hiding this comment

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

This is a true/false sensor type and thus should be moved to a binary_sensor. There are probably a bunch more too.

@pvizeli
Copy link
Member

pvizeli commented Jan 20, 2017

please use also monitored_conditions like https://home-assistant.io/components/sensor.synologydsm/ and a lot of other sensors from const.py

fabaff
fabaff previously requested changes Jan 21, 2017
@@ -0,0 +1,146 @@
"""
Support for monitoring the local system.
Copy link
Member

Choose a reason for hiding this comment

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

Needs an update.

Support for monitoring the local system.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.systemmonitor/
Copy link
Member

Choose a reason for hiding this comment

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

Should be https://home-assistant.io/components/sensor.fritzbox_netmonitor/

CONF_DEFAULT_IP = '169.254.1.1' # This IP is valid for all FRITZ!Box routers.

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_HOST, default=CONF_DEFAULT_IP): cv.string,
Copy link
Member

Choose a reason for hiding this comment

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

The sensors are missing. Add something like the sample below to check the configuration entry.

    vol.Optional(CONF_RESOURCES, default=[]):
        vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),

devices = []
for resource in config[CONF_RESOURCES]:
if 'arg' not in resource:
resource['arg'] = ''
Copy link
Member

Choose a reason for hiding this comment

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

I would like to suggest to simplify the configuration. You are not using arg and instead of

- type: is_linked
- type: is_connected
....

just use

- is_linked
- is_connected
....

add_devices(devices)

entity_ids = (dev.entity_id for dev in devices)
group.Group.create_group(hass, GROUP_NAME_ALL_DEVICES, entity_ids, False)
Copy link
Member

Choose a reason for hiding this comment

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

I think that we should let the user do the grouping. There would be a group for one sensor if only one is selected.

From my point of view, here the right way to go would be to expose the values as attributes. Then users can use a template sensor to grab the values and convert them as bytes and bits produce very quick very large numbers.

"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement

def update(self):
Copy link
Member

Choose a reason for hiding this comment

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

Here you should update your data object. You are communicating with your router, you want to throttle the data retrieval, and catch exceptions caused by connection issues.

It looks like that you use the systemmonitor sensor platform as a start. This platform is not communication with a third party.

@homeassistant
Copy link
Contributor

Hi @PetePriority,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@andrey-git
Copy link
Contributor

@PetePriority any updates on this PR?

@PetePriority
Copy link
Contributor Author

@andrey-git Sorry, I've been quite busy the last couple of weeks. I will implement the requested changes on the weekend.

@homeassistant
Copy link
Contributor

Hi @PetePriority,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@balloob balloob dismissed fabaff’s stale review February 14, 2017 07:57

Comments addressed

@balloob balloob merged commit e17410c into home-assistant:dev Feb 14, 2017
@balloob
Copy link
Member

balloob commented Feb 14, 2017

Top 🐬

@home-assistant home-assistant locked and limited conversation to collaborators May 19, 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.

9 participants