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

Use Voluptuous for BT Home Hub #3121

Merged
merged 1 commit into from
Sep 2, 2016
Merged
Changes from all commits
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
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