"""
Support for French FAI Bouygues Bbox routers.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/device_tracker.bbox/
"""
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__)

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=60)


def get_scanner(hass, config):
    """Validate the configuration and return a Bbox scanner."""
    scanner = BboxDeviceScanner(config[DOMAIN])

    return scanner if scanner.success_init else None


Device = namedtuple('Device', ['mac', 'name', 'ip', 'last_update'])


class BboxDeviceScanner(DeviceScanner):
    """This class scans for devices connected to the bbox."""

    def __init__(self, config):
        """Initialize the scanner."""
        self.last_results = []  # type: List[Device]

        self.success_init = self._update_info()
        _LOGGER.info("Scanner initialized")

    def scan_devices(self):
        """Scan for new devices and return a list with found device IDs."""
        self._update_info()

        return [device.mac for device in self.last_results]

    def get_device_name(self, device):
        """Return the name of the given device or None if we don't know."""
        filter_named = [result.name for result in self.last_results if
                        result.mac == device]

        if filter_named:
            return filter_named[0]
        return None

    @Throttle(MIN_TIME_BETWEEN_SCANS)
    def _update_info(self):
        """Check the Bbox for devices.

        Returns boolean if scanning successful.
        """
        _LOGGER.info("Scanning...")

        import pybbox

        box = pybbox.Bbox()
        result = box.get_all_connected_devices()

        now = dt_util.now()
        last_results = []
        for device in result:
            if device['active'] != 1:
                continue
            last_results.append(
                Device(device['macaddress'], device['hostname'],
                       device['ipaddress'], now))

        self.last_results = last_results

        _LOGGER.info("Scan successful")
        return True

@@ -220,23 +220,8 @@
 ple%0A
-import logging%0A
 from
@@ -251,48 +251,49 @@
 lta%0A
-%0A
 import 
-homeassistant.util.dt as dt_util
+logging%0A%0Aimport voluptuous as vol%0A
 %0Afro
@@ -345,16 +345,22 @@
 ort 
+(%0A    
 DOMAIN, 
 Devi
@@ -359,61 +359,214 @@
 IN, 
-DeviceScanner%0Afrom homeassistant.util import Throttle
+PLATFORM_SCHEMA, DeviceScanner)%0Afrom homeassistant.const import CONF_HOST%0Aimport homeassistant.helpers.config_validation as cv%0Afrom homeassistant.util import Throttle%0Aimport homeassistant.util.dt as dt_util
 %0A%0ARE
@@ -642,16 +642,48 @@
 ame__)%0A%0A
+DEFAULT_HOST = '192.168.1.254'%0A%0A
 MIN_TIME
@@ -722,16 +722,125 @@
 ds=60)%0A%0A
+PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(%7B%0A    vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,%0A%7D)%0A%0A
 %0Adef get
@@ -1232,24 +1232,99 @@
 f, config):%0A
+        %22%22%22Get host from config.%22%22%22%0A        self.host = config%5BCONF_HOST%5D%0A%0A
         %22%22%22I
@@ -2256,16 +2256,28 @@
 ox.Bbox(
+ip=self.host
 )%0A      

Add configurable host for bbox routers (#16778)