Skip to content

Commit

Permalink
Add configuration check and use default var names (#7963)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabaff authored and pvizeli committed Jun 8, 2017
1 parent 055db05 commit aaaf963
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions homeassistant/components/light/lutron.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
from homeassistant.components.lutron import (
LutronDevice, LUTRON_DEVICES, LUTRON_CONTROLLER)

DEPENDENCIES = ['lutron']

_LOGGER = logging.getLogger(__name__)

DEPENDENCIES = ['lutron']


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up Lutron lights."""
"""Set up the Lutron lights."""
devs = []
for (area_name, device) in hass.data[LUTRON_DEVICES]['light']:
dev = LutronLight(area_name, device, hass.data[LUTRON_CONTROLLER])
Expand Down
20 changes: 15 additions & 5 deletions homeassistant/components/lutron.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import asyncio
import logging

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.helpers import discovery
from homeassistant.helpers.entity import Entity

Expand All @@ -19,6 +23,14 @@
LUTRON_CONTROLLER = 'lutron_controller'
LUTRON_DEVICES = 'lutron_devices'

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Required(CONF_USERNAME): cv.string,
})
}, extra=vol.ALLOW_EXTRA)


def setup(hass, base_config):
"""Set up the Lutron component."""
Expand All @@ -29,13 +41,11 @@ def setup(hass, base_config):

config = base_config.get(DOMAIN)
hass.data[LUTRON_CONTROLLER] = Lutron(
config['lutron_host'],
config['lutron_user'],
config['lutron_password']
)
config[CONF_HOST], config[CONF_USERNAME], config[CONF_USERNAME])

hass.data[LUTRON_CONTROLLER].load_xml_db()
hass.data[LUTRON_CONTROLLER].connect()
_LOGGER.info("Connected to Main Repeater at %s", config['lutron_host'])
_LOGGER.info("Connected to main repeater at %s", config[CONF_HOST])

# Sort our devices into types
for area in hass.data[LUTRON_CONTROLLER].areas:
Expand Down

0 comments on commit aaaf963

Please sign in to comment.