This commit is contained in:
Fabian Affolter 2016-08-22 14:20:04 +02:00 committed by GitHub
parent fb639e08d7
commit e5969f0733
3 changed files with 15 additions and 16 deletions

View File

@ -5,20 +5,20 @@ For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/ https://home-assistant.io/components/demo/
""" """
from homeassistant.components.lock import LockDevice from homeassistant.components.lock import LockDevice
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED from homeassistant.const import (STATE_LOCKED, STATE_UNLOCKED)
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the demo lock platform.""" """Setup the Demo lock platform."""
add_devices_callback([ add_devices([
DemoLock('Front Door', STATE_LOCKED), DemoLock('Front Door', STATE_LOCKED),
DemoLock('Kitchen Door', STATE_UNLOCKED) DemoLock('Kitchen Door', STATE_UNLOCKED)
]) ])
class DemoLock(LockDevice): class DemoLock(LockDevice):
"""Representation of a demo lock.""" """Representation of a Demo lock."""
def __init__(self, name, state): def __init__(self, name, state):
"""Initialize the lock.""" """Initialize the lock."""

View File

@ -23,9 +23,9 @@ DEPENDENCIES = ['mqtt']
CONF_PAYLOAD_LOCK = 'payload_lock' CONF_PAYLOAD_LOCK = 'payload_lock'
CONF_PAYLOAD_UNLOCK = 'payload_unlock' CONF_PAYLOAD_UNLOCK = 'payload_unlock'
DEFAULT_NAME = "MQTT Lock" DEFAULT_NAME = 'MQTT Lock'
DEFAULT_PAYLOAD_LOCK = "LOCK" DEFAULT_PAYLOAD_LOCK = 'LOCK'
DEFAULT_PAYLOAD_UNLOCK = "UNLOCK" DEFAULT_PAYLOAD_UNLOCK = 'UNLOCK'
DEFAULT_OPTIMISTIC = False DEFAULT_OPTIMISTIC = False
PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({
@ -39,9 +39,9 @@ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({
# pylint: disable=unused-argument # pylint: disable=unused-argument
def setup_platform(hass, config, add_devices_callback, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the MQTT lock.""" """Setup the MQTT lock."""
add_devices_callback([MqttLock( add_devices([MqttLock(
hass, hass,
config[CONF_NAME], config[CONF_NAME],
config.get(CONF_STATE_TOPIC), config.get(CONF_STATE_TOPIC),

View File

@ -7,19 +7,18 @@ https://home-assistant.io/components/lock.vera/
import logging import logging
from homeassistant.components.lock import LockDevice from homeassistant.components.lock import LockDevice
from homeassistant.const import ( from homeassistant.const import (STATE_LOCKED, STATE_UNLOCKED)
STATE_LOCKED, STATE_UNLOCKED)
from homeassistant.components.vera import ( from homeassistant.components.vera import (
VeraDevice, VERA_DEVICES, VERA_CONTROLLER) VeraDevice, VERA_DEVICES, VERA_CONTROLLER)
DEPENDENCIES = ['vera']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['vera']
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Find and return Vera locks.""" """Find and return Vera locks."""
add_devices_callback( add_devices(
VeraLock(device, VERA_CONTROLLER) for VeraLock(device, VERA_CONTROLLER) for
device in VERA_DEVICES['lock']) device in VERA_DEVICES['lock'])