from homeassistant.const import TEMP_CELSIUS from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) CONF_TYPE = 'type' CONF_MAX_VOLTS = 'max_volts' DEFAULT_VOLTS = 1.2 DEPENDENCIES = ['zigbee'] TYPES = ['analog', 'temperature'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_TYPE): vol.In(TYPES), vol.Optional(CONF_MAX_VOLTS, default=DEFAULT_VOLTS): vol.Coerce(float), }) def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the ZigBee platform. Uses the 'type' config value to work out which type of ZigBee sensor we're dealing with and instantiates the relevant classes to handle it. """ typ = config.get(CONF_TYPE) try: sensor_class, config_class = TYPE_CLASSES[typ] except KeyError:
https://home-assistant.io/components/binary_sensor.zigbee/ """ import voluptuous as vol from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.zigbee import ( ZigBeeDigitalIn, ZigBeeDigitalInConfig, PLATFORM_SCHEMA) CONF_ON_STATE = 'on_state' DEFAULT_ON_STATE = 'high' DEPENDENCIES = ['zigbee'] STATES = ['high', 'low'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_ON_STATE): vol.In(STATES), }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Zigbee binary sensor platform.""" add_entities( [ZigBeeBinarySensor(hass, ZigBeeDigitalInConfig(config))], True) class ZigBeeBinarySensor(ZigBeeDigitalIn, BinarySensorDevice): """Use ZigBeeDigitalIn as binary sensor.""" pass
https://home-assistant.io/components/binary_sensor.zigbee/ """ import voluptuous as vol from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.zigbee import ( ZigBeeDigitalIn, ZigBeeDigitalInConfig, PLATFORM_SCHEMA) CONF_ON_STATE = 'on_state' DEFAULT_ON_STATE = 'high' DEPENDENCIES = ['zigbee'] STATES = ['high', 'low'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_ON_STATE): vol.In(STATES), }) def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the ZigBee binary sensor platform.""" add_devices( [ZigBeeBinarySensor(hass, ZigBeeDigitalInConfig(config))], True) class ZigBeeBinarySensor(ZigBeeDigitalIn, BinarySensorDevice): """Use ZigBeeDigitalIn as binary sensor.""" pass
from homeassistant.components.zigbee import PLATFORM_SCHEMA from homeassistant.const import TEMP_CELSIUS from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) CONF_TYPE = 'type' CONF_MAX_VOLTS = 'max_volts' DEFAULT_VOLTS = 1.2 DEPENDENCIES = ['zigbee'] TYPES = ['analog', 'temperature'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_TYPE): vol.In(TYPES), vol.Optional(CONF_MAX_VOLTS, default=DEFAULT_VOLTS): vol.Coerce(float), }) def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the ZigBee platform. Uses the 'type' config value to work out which type of ZigBee sensor we're dealing with and instantiates the relevant classes to handle it. """ typ = config.get(CONF_TYPE) try: sensor_class, config_class = TYPE_CLASSES[typ] except KeyError: _LOGGER.exception("Unknown ZigBee sensor type: %s", typ)
"""Support for Zigbee lights.""" import voluptuous as vol from homeassistant.components.light import Light from homeassistant.components.zigbee import (ZigBeeDigitalOut, ZigBeeDigitalOutConfig, PLATFORM_SCHEMA) CONF_ON_STATE = 'on_state' DEFAULT_ON_STATE = 'high' DEPENDENCIES = ['zigbee'] STATES = ['high', 'low'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_ON_STATE, default=DEFAULT_ON_STATE): vol.In(STATES), }) def setup_platform(hass, config, add_entities, discovery_info=None): """Create and add an entity based on the configuration.""" add_entities([ZigBeeLight(hass, ZigBeeDigitalOutConfig(config))]) class ZigBeeLight(ZigBeeDigitalOut, Light): """Use ZigBeeDigitalOut as light.""" pass
For more details about this platform, please refer to the documentation at https://home-assistant.io/components/light.zigbee/ """ import voluptuous as vol from homeassistant.components.light import Light from homeassistant.components.zigbee import ( ZigBeeDigitalOut, ZigBeeDigitalOutConfig, PLATFORM_SCHEMA) CONF_ON_STATE = 'on_state' DEFAULT_ON_STATE = 'high' DEPENDENCIES = ['zigbee'] STATES = ['high', 'low'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_ON_STATE, default=DEFAULT_ON_STATE): vol.In(STATES), }) def setup_platform(hass, config, add_entities, discovery_info=None): """Create and add an entity based on the configuration.""" add_entities([ZigBeeLight(hass, ZigBeeDigitalOutConfig(config))]) class ZigBeeLight(ZigBeeDigitalOut, Light): """Use ZigBeeDigitalOut as light.""" pass