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

Add configuration check and use default var names #7963

Merged
merged 1 commit into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
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
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