Merge pull request #1022 from haraldnagel/dev
Move Insteon API KEY into configuration.yaml
This commit is contained in:
commit
d6db00b55a
2 changed files with 12 additions and 4 deletions
|
@ -12,12 +12,11 @@ from homeassistant.helpers import validate_config
|
||||||
from homeassistant.loader import get_component
|
from homeassistant.loader import get_component
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_USERNAME, CONF_PASSWORD, ATTR_DISCOVERED,
|
CONF_USERNAME, CONF_PASSWORD, CONF_API_KEY, ATTR_DISCOVERED,
|
||||||
ATTR_SERVICE, EVENT_PLATFORM_DISCOVERED)
|
ATTR_SERVICE, EVENT_PLATFORM_DISCOVERED)
|
||||||
|
|
||||||
DOMAIN = "insteon"
|
DOMAIN = "insteon"
|
||||||
REQUIREMENTS = ['insteon_hub==0.4.5']
|
REQUIREMENTS = ['insteon_hub==0.4.5']
|
||||||
API_KEY = "3eb14d15-a486-4d9e-99af-179d0e9417c11444718937.80636061"
|
|
||||||
INSTEON = None
|
INSTEON = None
|
||||||
DISCOVER_LIGHTS = "insteon.lights"
|
DISCOVER_LIGHTS = "insteon.lights"
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -30,15 +29,22 @@ def setup(hass, config):
|
||||||
"""
|
"""
|
||||||
if not validate_config(
|
if not validate_config(
|
||||||
config,
|
config,
|
||||||
{DOMAIN: [CONF_USERNAME, CONF_PASSWORD]},
|
{DOMAIN: [CONF_USERNAME, CONF_PASSWORD, CONF_API_KEY]},
|
||||||
_LOGGER):
|
_LOGGER):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
import insteon
|
import insteon
|
||||||
|
|
||||||
username = config[DOMAIN][CONF_USERNAME]
|
username = config[DOMAIN][CONF_USERNAME]
|
||||||
password = config[DOMAIN][CONF_PASSWORD]
|
password = config[DOMAIN][CONF_PASSWORD]
|
||||||
|
api_key = config[DOMAIN][CONF_API_KEY]
|
||||||
|
|
||||||
global INSTEON
|
global INSTEON
|
||||||
INSTEON = insteon.Insteon(username, password, API_KEY)
|
INSTEON = insteon.Insteon(username, password, api_key)
|
||||||
|
|
||||||
|
if INSTEON is None:
|
||||||
|
_LOGGER.error("Could not connect to Insteon service.")
|
||||||
|
return
|
||||||
|
|
||||||
comp_name = 'light'
|
comp_name = 'light'
|
||||||
discovery = DISCOVER_LIGHTS
|
discovery = DISCOVER_LIGHTS
|
||||||
|
|
|
@ -13,4 +13,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
for device in INSTEON.devices:
|
for device in INSTEON.devices:
|
||||||
if device.DeviceCategory == "Switched Lighting Control":
|
if device.DeviceCategory == "Switched Lighting Control":
|
||||||
devs.append(InsteonToggleDevice(device))
|
devs.append(InsteonToggleDevice(device))
|
||||||
|
if device.DeviceCategory == "Dimmable Lighting Control":
|
||||||
|
devs.append(InsteonToggleDevice(device))
|
||||||
add_devices(devs)
|
add_devices(devs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue