Skip to content

Commit

Permalink
Use Voluptuous for BT Home Hub (#3121)
Browse files Browse the repository at this point in the history
  • Loading branch information
kellerza authored and Teagan42 committed Sep 2, 2016
1 parent 78f0e68 commit 586e47d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions homeassistant/components/device_tracker/bt_home_hub_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
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

Expand All @@ -26,14 +27,14 @@

_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
Expand All @@ -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()
Expand Down Expand Up @@ -85,7 +86,7 @@ def _update_info(self):
return False

with self.lock:
_LOGGER.info("Scanning")
_LOGGER.info('Scanning')

data = _get_homehub_data(self.url)

Expand Down

0 comments on commit 586e47d

Please sign in to comment.