Use Platform enum in ZHA (#61016)
This commit is contained in:
parent
5907f6690c
commit
a17031630f
28 changed files with 332 additions and 316 deletions
|
@ -4,7 +4,6 @@ import functools
|
|||
from zigpy.zcl.clusters.security import IasAce
|
||||
|
||||
from homeassistant.components.alarm_control_panel import (
|
||||
DOMAIN,
|
||||
FORMAT_TEXT,
|
||||
SUPPORT_ALARM_ARM_AWAY,
|
||||
SUPPORT_ALARM_ARM_HOME,
|
||||
|
@ -19,6 +18,7 @@ from homeassistant.const import (
|
|||
STATE_ALARM_ARMED_NIGHT,
|
||||
STATE_ALARM_DISARMED,
|
||||
STATE_ALARM_TRIGGERED,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -43,7 +43,9 @@ from .core.helpers import async_get_zha_config_value
|
|||
from .core.registries import ZHA_ENTITIES
|
||||
from .entity import ZhaEntity
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(
|
||||
ZHA_ENTITIES.strict_match, Platform.ALARM_CONTROL_PANEL
|
||||
)
|
||||
|
||||
IAS_ACE_STATE_MAP = {
|
||||
IasAce.PanelStatus.Panel_Disarmed: STATE_ALARM_DISARMED,
|
||||
|
@ -56,7 +58,7 @@ IAS_ACE_STATE_MAP = {
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation alarm control panel from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.ALARM_CONTROL_PANEL]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -10,10 +10,9 @@ from homeassistant.components.binary_sensor import (
|
|||
DEVICE_CLASS_OPENING,
|
||||
DEVICE_CLASS_SMOKE,
|
||||
DEVICE_CLASS_VIBRATION,
|
||||
DOMAIN,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.const import STATE_ON
|
||||
from homeassistant.const import STATE_ON, Platform
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -42,12 +41,12 @@ CLASS_MAPPING = {
|
|||
0x002D: DEVICE_CLASS_VIBRATION,
|
||||
}
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.BINARY_SENSOR)
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation binary sensor from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.BINARY_SENSOR]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -21,7 +21,6 @@ from homeassistant.components.climate.const import (
|
|||
CURRENT_HVAC_HEAT,
|
||||
CURRENT_HVAC_IDLE,
|
||||
CURRENT_HVAC_OFF,
|
||||
DOMAIN,
|
||||
FAN_AUTO,
|
||||
FAN_ON,
|
||||
HVAC_MODE_COOL,
|
||||
|
@ -40,7 +39,12 @@ from homeassistant.components.climate.const import (
|
|||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, PRECISION_TENTHS, TEMP_CELSIUS
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
PRECISION_TENTHS,
|
||||
TEMP_CELSIUS,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
|
@ -73,8 +77,8 @@ ATTR_UNOCCP_HEAT_SETPT = "unoccupied_heating_setpoint"
|
|||
ATTR_UNOCCP_COOL_SETPT = "unoccupied_cooling_setpoint"
|
||||
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
MULTI_MATCH = functools.partial(ZHA_ENTITIES.multipass_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.CLIMATE)
|
||||
MULTI_MATCH = functools.partial(ZHA_ENTITIES.multipass_match, Platform.CLIMATE)
|
||||
RUNNING_MODE = {0x00: HVAC_MODE_OFF, 0x03: HVAC_MODE_COOL, 0x04: HVAC_MODE_HEAT}
|
||||
|
||||
|
||||
|
@ -152,7 +156,7 @@ ZCL_TEMP = 100
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation sensor from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.CLIMATE]
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
SIGNAL_ADD_ENTITIES,
|
||||
|
|
|
@ -12,18 +12,7 @@ import zigpy_xbee.zigbee.application
|
|||
import zigpy_zigate.zigbee.application
|
||||
import zigpy_znp.zigbee.application
|
||||
|
||||
from homeassistant.components.alarm_control_panel import DOMAIN as ALARM
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE
|
||||
from homeassistant.components.cover import DOMAIN as COVER
|
||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER
|
||||
from homeassistant.components.fan import DOMAIN as FAN
|
||||
from homeassistant.components.light import DOMAIN as LIGHT
|
||||
from homeassistant.components.lock import DOMAIN as LOCK
|
||||
from homeassistant.components.number import DOMAIN as NUMBER
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR
|
||||
from homeassistant.components.siren import DOMAIN as SIREN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH
|
||||
from homeassistant.const import Platform
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from .typing import CALLABLE_T
|
||||
|
@ -111,18 +100,18 @@ CLUSTER_TYPE_IN = "in"
|
|||
CLUSTER_TYPE_OUT = "out"
|
||||
|
||||
PLATFORMS = (
|
||||
ALARM,
|
||||
BINARY_SENSOR,
|
||||
CLIMATE,
|
||||
COVER,
|
||||
DEVICE_TRACKER,
|
||||
FAN,
|
||||
LIGHT,
|
||||
LOCK,
|
||||
NUMBER,
|
||||
SENSOR,
|
||||
SIREN,
|
||||
SWITCH,
|
||||
Platform.ALARM_CONTROL_PANEL,
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.CLIMATE,
|
||||
Platform.COVER,
|
||||
Platform.DEVICE_TRACKER,
|
||||
Platform.FAN,
|
||||
Platform.LIGHT,
|
||||
Platform.LOCK,
|
||||
Platform.NUMBER,
|
||||
Platform.SENSOR,
|
||||
Platform.SIREN,
|
||||
Platform.SWITCH,
|
||||
)
|
||||
|
||||
CONF_ALARM_MASTER_CODE = "alarm_master_code"
|
||||
|
|
|
@ -11,25 +11,14 @@ from zigpy import zcl
|
|||
import zigpy.profiles.zha
|
||||
import zigpy.profiles.zll
|
||||
|
||||
from homeassistant.components.alarm_control_panel import DOMAIN as ALARM
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE
|
||||
from homeassistant.components.cover import DOMAIN as COVER
|
||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER
|
||||
from homeassistant.components.fan import DOMAIN as FAN
|
||||
from homeassistant.components.light import DOMAIN as LIGHT
|
||||
from homeassistant.components.lock import DOMAIN as LOCK
|
||||
from homeassistant.components.number import DOMAIN as NUMBER
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR
|
||||
from homeassistant.components.siren import DOMAIN as SIREN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH
|
||||
from homeassistant.const import Platform
|
||||
|
||||
# importing channels updates registries
|
||||
from . import channels as zha_channels # noqa: F401 pylint: disable=unused-import
|
||||
from .decorators import CALLABLE_T, DictRegistry, SetRegistry
|
||||
from .typing import ChannelType
|
||||
|
||||
GROUP_ENTITY_DOMAINS = [LIGHT, SWITCH, FAN]
|
||||
GROUP_ENTITY_DOMAINS = [Platform.LIGHT, Platform.SWITCH, Platform.FAN]
|
||||
|
||||
PHILLIPS_REMOTE_CLUSTER = 0xFC00
|
||||
SMARTTHINGS_ACCELERATION_CLUSTER = 0xFC02
|
||||
|
@ -64,34 +53,34 @@ REMOTE_DEVICE_TYPES = collections.defaultdict(list, REMOTE_DEVICE_TYPES)
|
|||
SINGLE_INPUT_CLUSTER_DEVICE_CLASS = {
|
||||
# this works for now but if we hit conflicts we can break it out to
|
||||
# a different dict that is keyed by manufacturer
|
||||
SMARTTHINGS_ACCELERATION_CLUSTER: BINARY_SENSOR,
|
||||
SMARTTHINGS_HUMIDITY_CLUSTER: SENSOR,
|
||||
VOC_LEVEL_CLUSTER: SENSOR,
|
||||
zcl.clusters.closures.DoorLock.cluster_id: LOCK,
|
||||
zcl.clusters.closures.WindowCovering.cluster_id: COVER,
|
||||
zcl.clusters.general.BinaryInput.cluster_id: BINARY_SENSOR,
|
||||
zcl.clusters.general.AnalogInput.cluster_id: SENSOR,
|
||||
zcl.clusters.general.AnalogOutput.cluster_id: NUMBER,
|
||||
zcl.clusters.general.MultistateInput.cluster_id: SENSOR,
|
||||
zcl.clusters.general.OnOff.cluster_id: SWITCH,
|
||||
zcl.clusters.general.PowerConfiguration.cluster_id: SENSOR,
|
||||
zcl.clusters.hvac.Fan.cluster_id: FAN,
|
||||
zcl.clusters.measurement.CarbonDioxideConcentration.cluster_id: SENSOR,
|
||||
zcl.clusters.measurement.CarbonMonoxideConcentration.cluster_id: SENSOR,
|
||||
zcl.clusters.measurement.FormaldehydeConcentration.cluster_id: SENSOR,
|
||||
zcl.clusters.measurement.IlluminanceMeasurement.cluster_id: SENSOR,
|
||||
zcl.clusters.measurement.OccupancySensing.cluster_id: BINARY_SENSOR,
|
||||
zcl.clusters.measurement.PressureMeasurement.cluster_id: SENSOR,
|
||||
zcl.clusters.measurement.RelativeHumidity.cluster_id: SENSOR,
|
||||
zcl.clusters.measurement.SoilMoisture.cluster_id: SENSOR,
|
||||
zcl.clusters.measurement.LeafWetness.cluster_id: SENSOR,
|
||||
zcl.clusters.measurement.TemperatureMeasurement.cluster_id: SENSOR,
|
||||
zcl.clusters.security.IasZone.cluster_id: BINARY_SENSOR,
|
||||
SMARTTHINGS_ACCELERATION_CLUSTER: Platform.BINARY_SENSOR,
|
||||
SMARTTHINGS_HUMIDITY_CLUSTER: Platform.SENSOR,
|
||||
VOC_LEVEL_CLUSTER: Platform.SENSOR,
|
||||
zcl.clusters.closures.DoorLock.cluster_id: Platform.LOCK,
|
||||
zcl.clusters.closures.WindowCovering.cluster_id: Platform.COVER,
|
||||
zcl.clusters.general.BinaryInput.cluster_id: Platform.BINARY_SENSOR,
|
||||
zcl.clusters.general.AnalogInput.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.general.AnalogOutput.cluster_id: Platform.NUMBER,
|
||||
zcl.clusters.general.MultistateInput.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.general.OnOff.cluster_id: Platform.SWITCH,
|
||||
zcl.clusters.general.PowerConfiguration.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.hvac.Fan.cluster_id: Platform.FAN,
|
||||
zcl.clusters.measurement.CarbonDioxideConcentration.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.measurement.CarbonMonoxideConcentration.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.measurement.FormaldehydeConcentration.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.measurement.IlluminanceMeasurement.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.measurement.OccupancySensing.cluster_id: Platform.BINARY_SENSOR,
|
||||
zcl.clusters.measurement.PressureMeasurement.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.measurement.RelativeHumidity.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.measurement.SoilMoisture.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.measurement.LeafWetness.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.measurement.TemperatureMeasurement.cluster_id: Platform.SENSOR,
|
||||
zcl.clusters.security.IasZone.cluster_id: Platform.BINARY_SENSOR,
|
||||
}
|
||||
|
||||
SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS = {
|
||||
zcl.clusters.general.OnOff.cluster_id: BINARY_SENSOR,
|
||||
zcl.clusters.security.IasAce.cluster_id: ALARM,
|
||||
zcl.clusters.general.OnOff.cluster_id: Platform.BINARY_SENSOR,
|
||||
zcl.clusters.security.IasAce.cluster_id: Platform.ALARM_CONTROL_PANEL,
|
||||
}
|
||||
|
||||
BINDABLE_CLUSTERS = SetRegistry()
|
||||
|
@ -99,31 +88,31 @@ CHANNEL_ONLY_CLUSTERS = SetRegistry()
|
|||
|
||||
DEVICE_CLASS = {
|
||||
zigpy.profiles.zha.PROFILE_ID: {
|
||||
SMARTTHINGS_ARRIVAL_SENSOR_DEVICE_TYPE: DEVICE_TRACKER,
|
||||
zigpy.profiles.zha.DeviceType.THERMOSTAT: CLIMATE,
|
||||
zigpy.profiles.zha.DeviceType.COLOR_DIMMABLE_LIGHT: LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.COLOR_TEMPERATURE_LIGHT: LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.DIMMABLE_BALLAST: LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.DIMMABLE_LIGHT: LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.DIMMABLE_PLUG_IN_UNIT: LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.EXTENDED_COLOR_LIGHT: LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.LEVEL_CONTROLLABLE_OUTPUT: COVER,
|
||||
zigpy.profiles.zha.DeviceType.ON_OFF_BALLAST: SWITCH,
|
||||
zigpy.profiles.zha.DeviceType.ON_OFF_LIGHT: LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.ON_OFF_PLUG_IN_UNIT: SWITCH,
|
||||
zigpy.profiles.zha.DeviceType.SHADE: COVER,
|
||||
zigpy.profiles.zha.DeviceType.SMART_PLUG: SWITCH,
|
||||
zigpy.profiles.zha.DeviceType.IAS_ANCILLARY_CONTROL: ALARM,
|
||||
zigpy.profiles.zha.DeviceType.IAS_WARNING_DEVICE: SIREN,
|
||||
SMARTTHINGS_ARRIVAL_SENSOR_DEVICE_TYPE: Platform.DEVICE_TRACKER,
|
||||
zigpy.profiles.zha.DeviceType.THERMOSTAT: Platform.CLIMATE,
|
||||
zigpy.profiles.zha.DeviceType.COLOR_DIMMABLE_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.COLOR_TEMPERATURE_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.DIMMABLE_BALLAST: Platform.LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.DIMMABLE_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.DIMMABLE_PLUG_IN_UNIT: Platform.LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.EXTENDED_COLOR_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.LEVEL_CONTROLLABLE_OUTPUT: Platform.COVER,
|
||||
zigpy.profiles.zha.DeviceType.ON_OFF_BALLAST: Platform.SWITCH,
|
||||
zigpy.profiles.zha.DeviceType.ON_OFF_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zha.DeviceType.ON_OFF_PLUG_IN_UNIT: Platform.SWITCH,
|
||||
zigpy.profiles.zha.DeviceType.SHADE: Platform.COVER,
|
||||
zigpy.profiles.zha.DeviceType.SMART_PLUG: Platform.SWITCH,
|
||||
zigpy.profiles.zha.DeviceType.IAS_ANCILLARY_CONTROL: Platform.ALARM_CONTROL_PANEL,
|
||||
zigpy.profiles.zha.DeviceType.IAS_WARNING_DEVICE: Platform.SIREN,
|
||||
},
|
||||
zigpy.profiles.zll.PROFILE_ID: {
|
||||
zigpy.profiles.zll.DeviceType.COLOR_LIGHT: LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.COLOR_TEMPERATURE_LIGHT: LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.DIMMABLE_LIGHT: LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.DIMMABLE_PLUGIN_UNIT: LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.EXTENDED_COLOR_LIGHT: LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.ON_OFF_LIGHT: LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.ON_OFF_PLUGIN_UNIT: SWITCH,
|
||||
zigpy.profiles.zll.DeviceType.COLOR_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.COLOR_TEMPERATURE_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.DIMMABLE_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.DIMMABLE_PLUGIN_UNIT: Platform.LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.EXTENDED_COLOR_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.ON_OFF_LIGHT: Platform.LIGHT,
|
||||
zigpy.profiles.zll.DeviceType.ON_OFF_PLUGIN_UNIT: Platform.SWITCH,
|
||||
},
|
||||
}
|
||||
DEVICE_CLASS = collections.defaultdict(dict, DEVICE_CLASS)
|
||||
|
|
|
@ -12,10 +12,15 @@ from homeassistant.components.cover import (
|
|||
ATTR_POSITION,
|
||||
DEVICE_CLASS_DAMPER,
|
||||
DEVICE_CLASS_SHADE,
|
||||
DOMAIN,
|
||||
CoverEntity,
|
||||
)
|
||||
from homeassistant.const import STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING
|
||||
from homeassistant.const import (
|
||||
STATE_CLOSED,
|
||||
STATE_CLOSING,
|
||||
STATE_OPEN,
|
||||
STATE_OPENING,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -37,12 +42,12 @@ from .entity import ZhaEntity
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.COVER)
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation cover from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.COVER]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
import functools
|
||||
import time
|
||||
|
||||
from homeassistant.components.device_tracker import DOMAIN, SOURCE_TYPE_ROUTER
|
||||
from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER
|
||||
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -19,12 +20,12 @@ from .core.registries import ZHA_ENTITIES
|
|||
from .entity import ZhaEntity
|
||||
from .sensor import Battery
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.DEVICE_TRACKER)
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation device tracker from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.DEVICE_TRACKER]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -11,12 +11,11 @@ from zigpy.zcl.clusters import hvac
|
|||
from homeassistant.components.fan import (
|
||||
ATTR_PERCENTAGE,
|
||||
ATTR_PRESET_MODE,
|
||||
DOMAIN,
|
||||
SUPPORT_SET_SPEED,
|
||||
FanEntity,
|
||||
NotValidPresetModeError,
|
||||
)
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.const import STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.core import State, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.util.percentage import (
|
||||
|
@ -53,13 +52,13 @@ PRESET_MODES = list(NAME_TO_PRESET_MODE)
|
|||
|
||||
DEFAULT_ON_PERCENTAGE = 50
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
GROUP_MATCH = functools.partial(ZHA_ENTITIES.group_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.FAN)
|
||||
GROUP_MATCH = functools.partial(ZHA_ENTITIES.group_match, Platform.FAN)
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation fan from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.FAN]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -30,7 +30,12 @@ from homeassistant.components.light import (
|
|||
SUPPORT_FLASH,
|
||||
SUPPORT_TRANSITION,
|
||||
)
|
||||
from homeassistant.const import ATTR_SUPPORTED_FEATURES, STATE_ON, STATE_UNAVAILABLE
|
||||
from homeassistant.const import (
|
||||
ATTR_SUPPORTED_FEATURES,
|
||||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import State, callback
|
||||
from homeassistant.helpers.debounce import Debouncer
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
|
@ -77,8 +82,8 @@ UPDATE_COLORLOOP_HUE = 0x8
|
|||
FLASH_EFFECTS = {light.FLASH_SHORT: EFFECT_BLINK, light.FLASH_LONG: EFFECT_BREATHE}
|
||||
|
||||
UNSUPPORTED_ATTRIBUTE = 0x86
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, light.DOMAIN)
|
||||
GROUP_MATCH = functools.partial(ZHA_ENTITIES.group_match, light.DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.LIGHT)
|
||||
GROUP_MATCH = functools.partial(ZHA_ENTITIES.group_match, Platform.LIGHT)
|
||||
PARALLEL_UPDATES = 0
|
||||
SIGNAL_LIGHT_GROUP_STATE_CHANGED = "zha_light_group_state_changed"
|
||||
|
||||
|
@ -102,7 +107,7 @@ class LightColorMode(enum.IntEnum):
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation light from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][light.DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.LIGHT]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -4,12 +4,8 @@ import functools
|
|||
import voluptuous as vol
|
||||
from zigpy.zcl.foundation import Status
|
||||
|
||||
from homeassistant.components.lock import (
|
||||
DOMAIN,
|
||||
STATE_LOCKED,
|
||||
STATE_UNLOCKED,
|
||||
LockEntity,
|
||||
)
|
||||
from homeassistant.components.lock import STATE_LOCKED, STATE_UNLOCKED, LockEntity
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -27,7 +23,7 @@ from .entity import ZhaEntity
|
|||
|
||||
# The first state is Zigbee 'Not fully locked'
|
||||
STATE_LIST = [STATE_UNLOCKED, STATE_LOCKED, STATE_UNLOCKED]
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.LOCK)
|
||||
|
||||
VALUE_TO_STATE = dict(enumerate(STATE_LIST))
|
||||
|
||||
|
@ -39,7 +35,7 @@ SERVICE_CLEAR_LOCK_USER_CODE = "clear_lock_user_code"
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation Door Lock from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.LOCK]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
import functools
|
||||
import logging
|
||||
|
||||
from homeassistant.components.number import DOMAIN, NumberEntity
|
||||
from homeassistant.components.number import NumberEntity
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -19,7 +20,7 @@ from .entity import ZhaEntity
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.NUMBER)
|
||||
|
||||
|
||||
UNITS = {
|
||||
|
@ -235,7 +236,7 @@ ICONS = {
|
|||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation Analog Output from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.NUMBER]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -22,7 +22,6 @@ from homeassistant.components.sensor import (
|
|||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DOMAIN,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
STATE_CLASS_TOTAL_INCREASING,
|
||||
SensorEntity,
|
||||
|
@ -51,6 +50,7 @@ from homeassistant.const import (
|
|||
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
|
||||
VOLUME_GALLONS,
|
||||
VOLUME_LITERS,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -99,8 +99,8 @@ BATTERY_SIZES = {
|
|||
}
|
||||
|
||||
CHANNEL_ST_HUMIDITY_CLUSTER = f"channel_0x{SMARTTHINGS_HUMIDITY_CLUSTER:04x}"
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
MULTI_MATCH = functools.partial(ZHA_ENTITIES.multipass_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.SENSOR)
|
||||
MULTI_MATCH = functools.partial(ZHA_ENTITIES.multipass_match, Platform.SENSOR)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -109,7 +109,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Zigbee Home Automation sensor from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.SENSOR]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -7,7 +7,6 @@ from typing import Any
|
|||
|
||||
from homeassistant.components.siren import (
|
||||
ATTR_DURATION,
|
||||
DOMAIN,
|
||||
SUPPORT_DURATION,
|
||||
SUPPORT_TURN_OFF,
|
||||
SUPPORT_TURN_ON,
|
||||
|
@ -20,6 +19,7 @@ from homeassistant.components.siren.const import (
|
|||
SUPPORT_VOLUME_SET,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -45,7 +45,7 @@ from .core.registries import ZHA_ENTITIES
|
|||
from .core.typing import ChannelType, ZhaDeviceType
|
||||
from .entity import ZhaEntity
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.SIREN)
|
||||
DEFAULT_DURATION = 5 # seconds
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the Zigbee Home Automation siren from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.SIREN]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
|
@ -7,8 +7,8 @@ from typing import Any
|
|||
from zigpy.zcl.clusters.general import OnOff
|
||||
from zigpy.zcl.foundation import Status
|
||||
|
||||
from homeassistant.components.switch import DOMAIN, SwitchEntity
|
||||
from homeassistant.const import STATE_ON, STATE_UNAVAILABLE
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.const import STATE_ON, STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.core import State, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
||||
|
@ -23,13 +23,13 @@ from .core.const import (
|
|||
from .core.registries import ZHA_ENTITIES
|
||||
from .entity import ZhaEntity, ZhaGroupEntity
|
||||
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, DOMAIN)
|
||||
GROUP_MATCH = functools.partial(ZHA_ENTITIES.group_match, DOMAIN)
|
||||
STRICT_MATCH = functools.partial(ZHA_ENTITIES.strict_match, Platform.SWITCH)
|
||||
GROUP_MATCH = functools.partial(ZHA_ENTITIES.group_match, Platform.SWITCH)
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Zigbee Home Automation switch from config entry."""
|
||||
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
|
||||
entities_to_create = hass.data[DATA_ZHA][Platform.SWITCH]
|
||||
|
||||
unsub = async_dispatcher_connect(
|
||||
hass,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue