From 586e47d08d9b602d141306c8a878396b14be5682 Mon Sep 17 00:00:00 2001 From: Johann Kellerman Date: Fri, 2 Sep 2016 06:28:28 +0200 Subject: [PATCH] Use Voluptuous for BT Home Hub (#3121) --- .../components/device_tracker/bt_home_hub_5.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/device_tracker/bt_home_hub_5.py b/homeassistant/components/device_tracker/bt_home_hub_5.py index c447fae1635..3b4115ff355 100644 --- a/homeassistant/components/device_tracker/bt_home_hub_5.py +++ b/homeassistant/components/device_tracker/bt_home_hub_5.py @@ -13,9 +13,10 @@ import json from urllib.parse import unquote import requests +import voluptuous as vol -from homeassistant.helpers import validate_config -from homeassistant.components.device_tracker import DOMAIN +import homeassistant.helpers.config_validation as cv +from homeassistant.components.device_tracker import DOMAIN, PLATFORM_SCHEMA from homeassistant.const import CONF_HOST from homeassistant.util import Throttle @@ -26,14 +27,14 @@ _LOGGER = logging.getLogger(__name__) _MAC_REGEX = re.compile(r'(([0-9A-Fa-f]{1,2}\:){5}[0-9A-Fa-f]{1,2})') +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ + vol.Required(CONF_HOST): cv.string +}) + # pylint: disable=unused-argument def get_scanner(hass, config): """Return a BT Home Hub 5 scanner if successful.""" - if not validate_config(config, - {DOMAIN: [CONF_HOST]}, - _LOGGER): - return None scanner = BTHomeHub5DeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None @@ -44,7 +45,7 @@ class BTHomeHub5DeviceScanner(object): def __init__(self, config): """Initialise the scanner.""" - _LOGGER.info("Initialising BT Home Hub 5") + _LOGGER.info('Initialising BT Home Hub 5') self.host = config.get(CONF_HOST, '192.168.1.254') self.lock = threading.Lock() @@ -85,7 +86,7 @@ class BTHomeHub5DeviceScanner(object): return False with self.lock: - _LOGGER.info("Scanning") + _LOGGER.info('Scanning') data = _get_homehub_data(self.url)