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

Add configurable host for bbox routers #16778

Merged
merged 4 commits into from
Sep 23, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions homeassistant/components/device_tracker/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/device_tracker.bbox/
"""
import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
isonet marked this conversation as resolved.
Show resolved Hide resolved
PLATFORM_SCHEMA, CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL, DOMAIN, DeviceScanner)

Choose a reason for hiding this comment

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

line too long (86 > 79 characters)

from homeassistant.const import CONF_HOST

from collections import namedtuple
import logging
from datetime import timedelta

import homeassistant.util.dt as dt_util
from homeassistant.components.device_tracker import DOMAIN, DeviceScanner
from homeassistant.util import Throttle

REQUIREMENTS = ['pybbox==0.0.5-alpha']

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = vol.All(
PLATFORM_SCHEMA.extend({
vol.Optional(CONF_HOST, default='192.168.1.254'): cv.string
}))

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=60)


Expand All @@ -33,6 +44,9 @@ class BboxDeviceScanner(DeviceScanner):
"""This class scans for devices connected to the bbox."""

def __init__(self, config):
"""Get host from config."""
self.host = config[CONF_HOST]

"""Initialize the scanner."""
self.last_results = [] # type: List[Device]

Expand Down Expand Up @@ -64,7 +78,7 @@ def _update_info(self):

import pybbox

box = pybbox.Bbox()
box = pybbox.Bbox(ip=self.host)
result = box.get_all_connected_devices()

now = dt_util.now()
Expand Down