mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Migrate to voluptuous (#2958)
This commit is contained in:
parent
d9322b81f3
commit
9219d65c3e
@ -4,27 +4,41 @@ Support for EnOcean binary sensors.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/binary_sensor.enocean/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorDevice, PLATFORM_SCHEMA, SENSOR_CLASSES_SCHEMA)
|
||||
from homeassistant.components import enocean
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.const import (CONF_NAME, CONF_ID, CONF_SENSOR_CLASS)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
DEPENDENCIES = ["enocean"]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_ID = "id"
|
||||
DEPENDENCIES = ['enocean']
|
||||
DEFAULT_NAME = 'EnOcean binary sensor'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ID): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
vol.Optional(CONF_SENSOR_CLASS, default=None): SENSOR_CLASSES_SCHEMA,
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the Binary Sensor platform fo EnOcean."""
|
||||
dev_id = config.get(CONF_ID, None)
|
||||
devname = config.get(CONF_NAME, "EnOcean binary sensor")
|
||||
add_devices([EnOceanBinarySensor(dev_id, devname)])
|
||||
dev_id = config.get(CONF_ID)
|
||||
devname = config.get(CONF_NAME)
|
||||
sensor_class = config.get(CONF_SENSOR_CLASS)
|
||||
|
||||
add_devices([EnOceanBinarySensor(dev_id, devname, sensor_class)])
|
||||
|
||||
|
||||
class EnOceanBinarySensor(enocean.EnOceanDevice, BinarySensorDevice):
|
||||
"""Representation of EnOcean binary sensors such as wall switches."""
|
||||
|
||||
def __init__(self, dev_id, devname):
|
||||
def __init__(self, dev_id, devname, sensor_class):
|
||||
"""Initialize the EnOcean binary sensor."""
|
||||
enocean.EnOceanDevice.__init__(self)
|
||||
self.stype = "listener"
|
||||
@ -32,12 +46,18 @@ class EnOceanBinarySensor(enocean.EnOceanDevice, BinarySensorDevice):
|
||||
self.which = -1
|
||||
self.onoff = -1
|
||||
self.devname = devname
|
||||
self._sensor_class = sensor_class
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""The default name for the binary sensor."""
|
||||
return self.devname
|
||||
|
||||
@property
|
||||
def sensor_class(self):
|
||||
"""Return the class of this sensor."""
|
||||
return self._sensor_class
|
||||
|
||||
def value_changed(self, value, value2):
|
||||
"""Fire an event with the data that have changed.
|
||||
|
||||
|
@ -4,23 +4,36 @@ EnOcean Component.
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/EnOcean/
|
||||
"""
|
||||
import logging
|
||||
|
||||
DOMAIN = "enocean"
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_DEVICE
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
REQUIREMENTS = ['enocean==0.31']
|
||||
|
||||
CONF_DEVICE = "device"
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DOMAIN = 'enocean'
|
||||
|
||||
ENOCEAN_DONGLE = None
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
vol.Required(CONF_DEVICE): cv.string,
|
||||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Setup the EnOcean component."""
|
||||
global ENOCEAN_DONGLE
|
||||
|
||||
serial_dev = config[DOMAIN].get(CONF_DEVICE, "/dev/ttyUSB0")
|
||||
serial_dev = config[DOMAIN].get(CONF_DEVICE)
|
||||
|
||||
ENOCEAN_DONGLE = EnOceanDongle(hass, serial_dev)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -7,27 +7,34 @@ https://home-assistant.io/components/light.enocean/
|
||||
import logging
|
||||
import math
|
||||
|
||||
from homeassistant.components.light import (Light, ATTR_BRIGHTNESS,
|
||||
SUPPORT_BRIGHTNESS)
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.components import enocean
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.light import (
|
||||
Light, ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, PLATFORM_SCHEMA)
|
||||
from homeassistant.const import (CONF_NAME, CONF_ID)
|
||||
from homeassistant.components import enocean
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ["enocean"]
|
||||
|
||||
CONF_ID = "id"
|
||||
CONF_SENDER_ID = "sender_id"
|
||||
DEPENDENCIES = ['enocean']
|
||||
DEFAULT_NAME = 'EnOcean Light'
|
||||
CONF_SENDER_ID = 'sender_id'
|
||||
|
||||
SUPPORT_ENOCEAN = SUPPORT_BRIGHTNESS
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ID): cv.string,
|
||||
vol.Required(CONF_SENDER_ID): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the EnOcean light platform."""
|
||||
sender_id = config.get(CONF_SENDER_ID, None)
|
||||
devname = config.get(CONF_NAME, "Enocean actuator")
|
||||
dev_id = config.get(CONF_ID, [0x00, 0x00, 0x00, 0x00])
|
||||
sender_id = config.get(CONF_SENDER_ID)
|
||||
devname = config.get(CONF_NAME)
|
||||
dev_id = config.get(CONF_ID)
|
||||
|
||||
add_devices([EnOceanLight(sender_id, devname, dev_id)])
|
||||
|
||||
|
@ -4,20 +4,32 @@ Support for EnOcean sensors.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.enocean/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import CONF_NAME
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_NAME, CONF_ID)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components import enocean
|
||||
|
||||
DEPENDENCIES = ["enocean"]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_ID = "id"
|
||||
DEFAULT_NAME = 'EnOcean sensor'
|
||||
DEPENDENCIES = ['enocean']
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ID): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup an EnOcean sensor device."""
|
||||
dev_id = config.get(CONF_ID, None)
|
||||
devname = config.get(CONF_NAME, None)
|
||||
dev_id = config.get(CONF_ID)
|
||||
devname = config.get(CONF_NAME)
|
||||
|
||||
add_devices([EnOceanSensor(dev_id, devname)])
|
||||
|
||||
|
||||
|
@ -4,25 +4,31 @@ Support for EnOcean switches.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.enocean/
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.const import CONF_NAME
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (CONF_NAME, CONF_ID)
|
||||
from homeassistant.components import enocean
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ["enocean"]
|
||||
DEFAULT_NAME = 'EnOcean Switch'
|
||||
DEPENDENCIES = ['enocean']
|
||||
|
||||
CONF_ID = "id"
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ID): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
})
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the EnOcean switch platform."""
|
||||
dev_id = config.get(CONF_ID, None)
|
||||
devname = config.get(CONF_NAME, "Enocean actuator")
|
||||
dev_id = config.get(CONF_ID)
|
||||
devname = config.get(CONF_NAME)
|
||||
|
||||
add_devices([EnOceanSwitch(dev_id, devname)])
|
||||
|
||||
|
@ -29,6 +29,7 @@ CONF_BLACKLIST = 'blacklist'
|
||||
CONF_CODE = 'code'
|
||||
CONF_CONDITION = 'condition'
|
||||
CONF_CUSTOMIZE = 'customize'
|
||||
CONF_DEVICE = 'device'
|
||||
CONF_DISARM_AFTER_TRIGGER = 'disarm_after_trigger'
|
||||
CONF_DISPLAY_OPTIONS = 'display_options'
|
||||
CONF_ELEVATION = 'elevation'
|
||||
@ -39,6 +40,7 @@ CONF_FILENAME = 'filename'
|
||||
CONF_HOST = 'host'
|
||||
CONF_HOSTS = 'hosts'
|
||||
CONF_ICON = 'icon'
|
||||
CONF_ID = 'id'
|
||||
CONF_LATITUDE = 'latitude'
|
||||
CONF_LONGITUDE = 'longitude'
|
||||
CONF_METHOD = 'method'
|
||||
|
Loading…
x
Reference in New Issue
Block a user