diff --git a/homeassistant/components/insteon_hub.py b/homeassistant/components/insteon_hub.py index 306acab5361..906f15b6c3f 100644 --- a/homeassistant/components/insteon_hub.py +++ b/homeassistant/components/insteon_hub.py @@ -6,26 +6,33 @@ https://home-assistant.io/components/insteon_hub/ """ import logging -from homeassistant.const import CONF_API_KEY, CONF_PASSWORD, CONF_USERNAME -from homeassistant.helpers import validate_config, discovery +import voluptuous as vol + +from homeassistant.const import (CONF_API_KEY, CONF_PASSWORD, CONF_USERNAME) +from homeassistant.helpers import discovery +import homeassistant.helpers.config_validation as cv -DOMAIN = "insteon_hub" REQUIREMENTS = ['insteon_hub==0.4.5'] -INSTEON = None + _LOGGER = logging.getLogger(__name__) +DOMAIN = 'insteon_hub' +INSTEON = None + +CONFIG_SCHEMA = vol.Schema({ + DOMAIN: vol.Schema({ + vol.Required(CONF_API_KEY): cv.string, + vol.Required(CONF_PASSWORD): cv.string, + vol.Required(CONF_USERNAME): cv.string, + }) +}, extra=vol.ALLOW_EXTRA) + def setup(hass, config): """Setup Insteon Hub component. This will automatically import associated lights. """ - if not validate_config( - config, - {DOMAIN: [CONF_USERNAME, CONF_PASSWORD, CONF_API_KEY]}, - _LOGGER): - return False - import insteon username = config[DOMAIN][CONF_USERNAME] @@ -36,8 +43,8 @@ def setup(hass, config): INSTEON = insteon.Insteon(username, password, api_key) if INSTEON is None: - _LOGGER.error("Could not connect to Insteon service.") - return + _LOGGER.error("Could not connect to Insteon service") + return False discovery.load_platform(hass, 'light', DOMAIN, {}, config)