Use voluptuous for HDMI CEC & CONF_DEVICES constants (#3107)
parent
748d7f4ecb
commit
24d412938e
|
@ -7,14 +7,12 @@ https://home-assistant.io/components/climate.eq3btsmart/
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.climate import ClimateDevice
|
from homeassistant.components.climate import ClimateDevice
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS, CONF_DEVICES
|
||||||
from homeassistant.util.temperature import convert
|
from homeassistant.util.temperature import convert
|
||||||
|
|
||||||
REQUIREMENTS = ['bluepy_devices==0.2.0']
|
REQUIREMENTS = ['bluepy_devices==0.2.0']
|
||||||
|
|
||||||
CONF_MAC = 'mac'
|
CONF_MAC = 'mac'
|
||||||
CONF_DEVICES = 'devices'
|
|
||||||
CONF_ID = 'id'
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -28,7 +26,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
devices.append(EQ3BTSmartThermostat(mac, name))
|
devices.append(EQ3BTSmartThermostat(mac, name))
|
||||||
|
|
||||||
add_devices(devices)
|
add_devices(devices)
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-instance-attributes, import-error, abstract-method
|
# pylint: disable=too-many-instance-attributes, import-error, abstract-method
|
||||||
|
|
|
@ -9,13 +9,12 @@ import logging
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
import homeassistant.components.mqtt as mqtt
|
import homeassistant.components.mqtt as mqtt
|
||||||
|
from homeassistant.const import CONF_DEVICES
|
||||||
from homeassistant.components.mqtt import CONF_QOS
|
from homeassistant.components.mqtt import CONF_QOS
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
DEPENDENCIES = ['mqtt']
|
DEPENDENCIES = ['mqtt']
|
||||||
|
|
||||||
CONF_DEVICES = 'devices'
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend({
|
||||||
|
|
|
@ -1,25 +1,28 @@
|
||||||
"""
|
"""
|
||||||
CEC component.
|
CEC component.
|
||||||
|
|
||||||
Requires libcec + Python bindings.
|
For more details about this component, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/hdmi_cec/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_START
|
|
||||||
|
from homeassistant.const import (EVENT_HOMEASSISTANT_START, CONF_DEVICES)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
_CEC = None
|
_CEC = None
|
||||||
DOMAIN = 'hdmi_cec'
|
_LOGGER = logging.getLogger(__name__)
|
||||||
SERVICE_SELECT_DEVICE = 'select_device'
|
|
||||||
SERVICE_POWER_ON = 'power_on'
|
|
||||||
SERVICE_STANDBY = 'standby'
|
|
||||||
CONF_DEVICES = 'devices'
|
|
||||||
ATTR_DEVICE = 'device'
|
ATTR_DEVICE = 'device'
|
||||||
|
|
||||||
|
DOMAIN = 'hdmi_cec'
|
||||||
|
|
||||||
MAX_DEPTH = 4
|
MAX_DEPTH = 4
|
||||||
|
|
||||||
|
SERVICE_POWER_ON = 'power_on'
|
||||||
|
SERVICE_SELECT_DEVICE = 'select_device'
|
||||||
|
SERVICE_STANDBY = 'standby'
|
||||||
|
|
||||||
# pylint: disable=unnecessary-lambda
|
# pylint: disable=unnecessary-lambda
|
||||||
DEVICE_SCHEMA = vol.Schema({
|
DEVICE_SCHEMA = vol.Schema({
|
||||||
|
@ -27,7 +30,6 @@ DEVICE_SCHEMA = vol.Schema({
|
||||||
cv.string)
|
cv.string)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
vol.Required(CONF_DEVICES): DEVICE_SCHEMA
|
vol.Required(CONF_DEVICES): DEVICE_SCHEMA
|
||||||
|
@ -56,17 +58,14 @@ def setup(hass, config):
|
||||||
"""Setup CEC capability."""
|
"""Setup CEC capability."""
|
||||||
global _CEC
|
global _CEC
|
||||||
|
|
||||||
# cec is only available if libcec is properly installed
|
|
||||||
# and the Python bindings are accessible.
|
|
||||||
try:
|
try:
|
||||||
import cec
|
import cec
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_LOGGER.error("libcec must be installed")
|
_LOGGER.error("libcec must be installed")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Parse configuration into a dict of device name
|
# Parse configuration into a dict of device name to physical address
|
||||||
# to physical address represented as a list of
|
# represented as a list of four elements.
|
||||||
# four elements.
|
|
||||||
flat = {}
|
flat = {}
|
||||||
for pair in parse_mapping(config[DOMAIN].get(CONF_DEVICES, {})):
|
for pair in parse_mapping(config[DOMAIN].get(CONF_DEVICES, {})):
|
||||||
flat[pair[0]] = pad_physical_address(pair[1])
|
flat[pair[0]] = pad_physical_address(pair[1])
|
||||||
|
@ -78,7 +77,7 @@ def setup(hass, config):
|
||||||
cfg.bMonitorOnly = 1
|
cfg.bMonitorOnly = 1
|
||||||
cfg.clientVersion = cec.LIBCEC_VERSION_CURRENT
|
cfg.clientVersion = cec.LIBCEC_VERSION_CURRENT
|
||||||
|
|
||||||
# Set up CEC adapter.
|
# Setup CEC adapter.
|
||||||
_CEC = cec.ICECAdapter.Create(cfg)
|
_CEC = cec.ICECAdapter.Create(cfg)
|
||||||
|
|
||||||
def _power_on(call):
|
def _power_on(call):
|
||||||
|
|
|
@ -31,6 +31,7 @@ CONF_CODE = 'code'
|
||||||
CONF_CONDITION = 'condition'
|
CONF_CONDITION = 'condition'
|
||||||
CONF_CUSTOMIZE = 'customize'
|
CONF_CUSTOMIZE = 'customize'
|
||||||
CONF_DEVICE = 'device'
|
CONF_DEVICE = 'device'
|
||||||
|
CONF_DEVICES = 'devices'
|
||||||
CONF_DISARM_AFTER_TRIGGER = 'disarm_after_trigger'
|
CONF_DISARM_AFTER_TRIGGER = 'disarm_after_trigger'
|
||||||
CONF_DISPLAY_OPTIONS = 'display_options'
|
CONF_DISPLAY_OPTIONS = 'display_options'
|
||||||
CONF_ELEVATION = 'elevation'
|
CONF_ELEVATION = 'elevation'
|
||||||
|
|
Loading…
Reference in New Issue