2016-01-19 13:10:17 +00:00
|
|
|
"""
|
|
|
|
Support for Insteon Hub.
|
|
|
|
|
2016-01-27 08:34:14 +00:00
|
|
|
For more details about this component, please refer to the documentation at
|
2016-02-02 23:23:59 +00:00
|
|
|
https://home-assistant.io/components/insteon_hub/
|
2016-01-27 08:25:44 +00:00
|
|
|
"""
|
2016-01-19 13:10:17 +00:00
|
|
|
import logging
|
2016-02-19 05:27:50 +00:00
|
|
|
|
2016-09-14 06:20:58 +00:00
|
|
|
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
|
2016-01-19 13:10:17 +00:00
|
|
|
|
2016-09-02 19:18:32 +00:00
|
|
|
REQUIREMENTS = ['insteon_hub==0.4.5']
|
2016-09-14 06:20:58 +00:00
|
|
|
|
2016-01-19 13:10:17 +00:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2016-09-14 06:20:58 +00:00
|
|
|
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)
|
|
|
|
|
2016-01-19 13:10:17 +00:00
|
|
|
|
2016-09-02 19:18:32 +00:00
|
|
|
def setup(hass, config):
|
|
|
|
"""Setup Insteon Hub component.
|
2016-03-08 16:55:57 +00:00
|
|
|
|
2016-09-02 19:18:32 +00:00
|
|
|
This will automatically import associated lights.
|
|
|
|
"""
|
|
|
|
import insteon
|
2016-01-28 03:01:32 +00:00
|
|
|
|
2016-01-28 05:55:36 +00:00
|
|
|
username = config[DOMAIN][CONF_USERNAME]
|
2016-01-19 13:10:17 +00:00
|
|
|
password = config[DOMAIN][CONF_PASSWORD]
|
2016-01-28 03:01:32 +00:00
|
|
|
api_key = config[DOMAIN][CONF_API_KEY]
|
|
|
|
|
2016-01-19 13:10:17 +00:00
|
|
|
global INSTEON
|
2016-09-02 19:18:32 +00:00
|
|
|
INSTEON = insteon.Insteon(username, password, api_key)
|
2016-01-19 13:10:17 +00:00
|
|
|
|
2016-01-28 05:55:36 +00:00
|
|
|
if INSTEON is None:
|
2016-09-14 06:20:58 +00:00
|
|
|
_LOGGER.error("Could not connect to Insteon service")
|
|
|
|
return False
|
2016-01-28 05:55:36 +00:00
|
|
|
|
2016-09-02 19:18:32 +00:00
|
|
|
discovery.load_platform(hass, 'light', DOMAIN, {}, config)
|
2016-08-25 12:47:07 +00:00
|
|
|
|
2016-09-02 19:18:32 +00:00
|
|
|
return True
|