8000 Use constants (switch.orvibo) by fabaff · Pull Request #3148 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use constants (switch.orvibo) #3148

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

Merged
merged 1 commit into from
Sep 2, 2016
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
18 changes: 8 additions & 10 deletions homeassistant/components/switch/orvibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,32 @@

import voluptuous as vol

from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA
from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
from homeassistant.const import (
CONF_HOST, CONF_NAME, CONF_SWITCHES, CONF_MAC, CONF_DISCOVERY)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['orvibo==1.1.1']

_LOGGER = logging.getLogger(__name__)

CONF_SWITCHES = 'switches'
CONF_HOST = 'host'
CONF_NAME = 'name'
CONF_MAC = 'mac'
CONF_DISCOVERY = 'discovery'
DEFAULT_NAME = 'Orvibo S20 Switch'
DEFAULT_DISCOVERY = True

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_DISCOVERY, default=DEFAULT_DISCOVERY): cv.boolean,
vol.Required(CONF_SWITCHES, default=[]):
vol.All(cv.ensure_list, [{
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_MAC): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string
}])
}]),
vol.Optional(CONF_DISCOVERY, default=DEFAULT_DISCOVERY): cv.boolean,
})


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
"""Find and return S20 switches."""
"""Setup S20 switches."""
from orvibo.s20 import discover, S20, S20Exception

switch_data = {}
Expand All @@ -51,7 +49,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):

for host, data in switch_data.items():
try:
switches.append(S20Switch(data.get(CONF_NAME, DEFAULT_NAME),
switches.append(S20Switch(data.get(CONF_NAME),
S20(host, mac=data.get(CONF_MAC))))
_LOGGER.info("Initialized S20 at %s", host)
except S20Exception:
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
CONF_DEVICE = 'device'
CONF_DEVICES = 'devices'
CONF_DISARM_AFTER_TRIGGER = 'disarm_after_trigger'
CONF_DISCOVERY = 'discovery'
CONF_DISPLAY_OPTIONS = 'display_options'
CONF_ELEVATION = 'elevation'
CONF_ENTITY_ID = 'entity_id'
Expand All @@ -55,6 +56,7 @@
CONF_ID = 'id'
CONF_LATITUDE = 'latitude'
CONF_LONGITUDE = 'longitude'
CONF_MAC = 'mac'
CONF_METHOD = 'method'
CONF_MONITORED_CONDITIONS = 'monitored_conditions'
CONF_MONITORED_VARIABLES = 'monitored_variables'
Expand Down
0