mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Cleanup remaining constants stuff in ZHA (#22050)
* clean up constants * fix quirks until it can be upgradded
This commit is contained in:
parent
851378739f
commit
89c96279ce
@ -6,3 +6,4 @@ at https://home-assistant.io/components/fan.zha/
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=W0614,W0401
|
# pylint: disable=W0614,W0401
|
||||||
from .core.const import * # noqa: F401,F403
|
from .core.const import * # noqa: F401,F403
|
||||||
|
from .core.registries import * # noqa: F401,F403
|
||||||
|
@ -17,9 +17,10 @@ from ..helpers import (
|
|||||||
bind_configure_reporting, construct_unique_id,
|
bind_configure_reporting, construct_unique_id,
|
||||||
safe_read, get_attr_id_by_name)
|
safe_read, get_attr_id_by_name)
|
||||||
from ..const import (
|
from ..const import (
|
||||||
CLUSTER_REPORT_CONFIGS, REPORT_CONFIG_DEFAULT, SIGNAL_ATTR_UPDATED,
|
REPORT_CONFIG_DEFAULT, SIGNAL_ATTR_UPDATED, ATTRIBUTE_CHANNEL,
|
||||||
ATTRIBUTE_CHANNEL, EVENT_RELAY_CHANNEL, ZDO_CHANNEL
|
EVENT_RELAY_CHANNEL, ZDO_CHANNEL
|
||||||
)
|
)
|
||||||
|
from ..registries import CLUSTER_REPORT_CONFIGS
|
||||||
|
|
||||||
NODE_DESCRIPTOR_REQUEST = 0x0002
|
NODE_DESCRIPTOR_REQUEST = 0x0002
|
||||||
MAINS_POWERED = 1
|
MAINS_POWERED = 1
|
||||||
|
@ -10,9 +10,9 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
|||||||
from . import ZigbeeChannel, parse_and_log_command
|
from . import ZigbeeChannel, parse_and_log_command
|
||||||
from ..helpers import get_attr_id_by_name
|
from ..helpers import get_attr_id_by_name
|
||||||
from ..const import (
|
from ..const import (
|
||||||
SIGNAL_ATTR_UPDATED,
|
SIGNAL_ATTR_UPDATED, SIGNAL_MOVE_LEVEL, SIGNAL_SET_LEVEL,
|
||||||
SIGNAL_MOVE_LEVEL, SIGNAL_SET_LEVEL, SIGNAL_STATE_ATTR, BASIC_CHANNEL,
|
SIGNAL_STATE_ATTR, BASIC_CHANNEL, ON_OFF_CHANNEL, LEVEL_CHANNEL,
|
||||||
ON_OFF_CHANNEL, LEVEL_CHANNEL, POWER_CONFIGURATION_CHANNEL
|
POWER_CONFIGURATION_CHANNEL
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -121,18 +121,6 @@ class RadioType(enum.Enum):
|
|||||||
|
|
||||||
|
|
||||||
DISCOVERY_KEY = 'zha_discovery_info'
|
DISCOVERY_KEY = 'zha_discovery_info'
|
||||||
DEVICE_CLASS = {}
|
|
||||||
SINGLE_INPUT_CLUSTER_DEVICE_CLASS = {}
|
|
||||||
SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS = {}
|
|
||||||
SENSOR_TYPES = {}
|
|
||||||
RADIO_TYPES = {}
|
|
||||||
BINARY_SENSOR_TYPES = {}
|
|
||||||
CLUSTER_REPORT_CONFIGS = {}
|
|
||||||
CUSTOM_CLUSTER_MAPPINGS = {}
|
|
||||||
COMPONENT_CLUSTERS = {}
|
|
||||||
EVENT_RELAY_CLUSTERS = []
|
|
||||||
NO_SENSOR_CLUSTERS = []
|
|
||||||
BINDABLE_CLUSTERS = []
|
|
||||||
|
|
||||||
REPORT_CONFIG_MAX_INT = 900
|
REPORT_CONFIG_MAX_INT = 900
|
||||||
REPORT_CONFIG_MAX_INT_BATTERY_SAVE = 10800
|
REPORT_CONFIG_MAX_INT_BATTERY_SAVE = 10800
|
||||||
|
@ -10,16 +10,18 @@ import logging
|
|||||||
from homeassistant import const as ha_const
|
from homeassistant import const as ha_const
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from . import const as zha_const
|
|
||||||
from .channels import (
|
from .channels import (
|
||||||
AttributeListeningChannel, EventRelayChannel, ZDOChannel
|
AttributeListeningChannel, EventRelayChannel, ZDOChannel
|
||||||
)
|
)
|
||||||
from .channels.registry import ZIGBEE_CHANNEL_REGISTRY
|
from .channels.registry import ZIGBEE_CHANNEL_REGISTRY
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_DEVICE_CONFIG, COMPONENTS, ZHA_DISCOVERY_NEW, DATA_ZHA,
|
CONF_DEVICE_CONFIG, COMPONENTS, ZHA_DISCOVERY_NEW, DATA_ZHA,
|
||||||
SENSOR_TYPE, UNKNOWN, BINARY_SENSOR_TYPES, NO_SENSOR_CLUSTERS,
|
SENSOR_TYPE, UNKNOWN, GENERIC, POWER_CONFIGURATION_CHANNEL
|
||||||
EVENT_RELAY_CLUSTERS, SENSOR_TYPES, GENERIC,
|
)
|
||||||
POWER_CONFIGURATION_CHANNEL
|
from .registries import (
|
||||||
|
BINARY_SENSOR_TYPES, NO_SENSOR_CLUSTERS, EVENT_RELAY_CLUSTERS,
|
||||||
|
SENSOR_TYPES, DEVICE_CLASS, COMPONENT_CLUSTERS,
|
||||||
|
SINGLE_INPUT_CLUSTER_DEVICE_CLASS, SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS
|
||||||
)
|
)
|
||||||
from ..device_entity import ZhaDeviceEntity
|
from ..device_entity import ZhaDeviceEntity
|
||||||
|
|
||||||
@ -53,16 +55,15 @@ def async_process_endpoint(
|
|||||||
|
|
||||||
if endpoint.profile_id in zigpy.profiles.PROFILES:
|
if endpoint.profile_id in zigpy.profiles.PROFILES:
|
||||||
profile = zigpy.profiles.PROFILES[endpoint.profile_id]
|
profile = zigpy.profiles.PROFILES[endpoint.profile_id]
|
||||||
if zha_const.DEVICE_CLASS.get(endpoint.profile_id,
|
if DEVICE_CLASS.get(endpoint.profile_id, {}).get(
|
||||||
{}).get(endpoint.device_type,
|
endpoint.device_type, None):
|
||||||
None):
|
|
||||||
profile_clusters = profile.CLUSTERS[endpoint.device_type]
|
profile_clusters = profile.CLUSTERS[endpoint.device_type]
|
||||||
profile_info = zha_const.DEVICE_CLASS[endpoint.profile_id]
|
profile_info = DEVICE_CLASS[endpoint.profile_id]
|
||||||
component = profile_info[endpoint.device_type]
|
component = profile_info[endpoint.device_type]
|
||||||
|
|
||||||
if ha_const.CONF_TYPE in node_config:
|
if ha_const.CONF_TYPE in node_config:
|
||||||
component = node_config[ha_const.CONF_TYPE]
|
component = node_config[ha_const.CONF_TYPE]
|
||||||
profile_clusters = zha_const.COMPONENT_CLUSTERS[component]
|
profile_clusters = COMPONENT_CLUSTERS[component]
|
||||||
|
|
||||||
if component and component in COMPONENTS:
|
if component and component in COMPONENTS:
|
||||||
profile_match = _async_handle_profile_match(
|
profile_match = _async_handle_profile_match(
|
||||||
@ -179,7 +180,7 @@ def _async_handle_single_cluster_matches(hass, endpoint, zha_device,
|
|||||||
zha_device,
|
zha_device,
|
||||||
cluster,
|
cluster,
|
||||||
device_key,
|
device_key,
|
||||||
zha_const.SINGLE_INPUT_CLUSTER_DEVICE_CLASS,
|
SINGLE_INPUT_CLUSTER_DEVICE_CLASS,
|
||||||
is_new_join,
|
is_new_join,
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -190,7 +191,7 @@ def _async_handle_single_cluster_matches(hass, endpoint, zha_device,
|
|||||||
zha_device,
|
zha_device,
|
||||||
cluster,
|
cluster,
|
||||||
device_key,
|
device_key,
|
||||||
zha_const.SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS,
|
SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS,
|
||||||
is_new_join,
|
is_new_join,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -15,11 +15,11 @@ from homeassistant.core import callback
|
|||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from .const import (
|
from .const import (
|
||||||
DATA_ZHA, DATA_ZHA_CORE_COMPONENT, DOMAIN,
|
DATA_ZHA, DATA_ZHA_CORE_COMPONENT, DOMAIN, SIGNAL_REMOVE, DATA_ZHA_GATEWAY,
|
||||||
SIGNAL_REMOVE, DATA_ZHA_GATEWAY, CONF_USB_PATH, CONF_BAUDRATE,
|
CONF_USB_PATH, CONF_BAUDRATE, DEFAULT_BAUDRATE, CONF_RADIO_TYPE,
|
||||||
DEFAULT_BAUDRATE, CONF_RADIO_TYPE, DATA_ZHA_RADIO, CONF_DATABASE,
|
DATA_ZHA_RADIO, CONF_DATABASE, DEFAULT_DATABASE_NAME, DATA_ZHA_BRIDGE_ID,
|
||||||
DEFAULT_DATABASE_NAME, DATA_ZHA_BRIDGE_ID, RADIO_TYPES,
|
RADIO, CONTROLLER, RADIO_DESCRIPTION
|
||||||
RADIO, CONTROLLER, RADIO_DESCRIPTION)
|
)
|
||||||
from .device import ZHADevice, DeviceStatus
|
from .device import ZHADevice, DeviceStatus
|
||||||
from .channels import (
|
from .channels import (
|
||||||
ZDOChannel, MAINS_POWERED
|
ZDOChannel, MAINS_POWERED
|
||||||
@ -31,6 +31,7 @@ from .discovery import (
|
|||||||
)
|
)
|
||||||
from .store import async_get_registry
|
from .store import async_get_registry
|
||||||
from .patches import apply_application_controller_patch
|
from .patches import apply_application_controller_patch
|
||||||
|
from .registries import RADIO_TYPES
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@ from concurrent.futures import TimeoutError as Timeout
|
|||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from .const import (
|
from .const import (
|
||||||
DEFAULT_BAUDRATE, REPORT_CONFIG_MAX_INT, REPORT_CONFIG_MIN_INT,
|
DEFAULT_BAUDRATE, REPORT_CONFIG_MAX_INT, REPORT_CONFIG_MIN_INT,
|
||||||
REPORT_CONFIG_RPT_CHANGE, RadioType, IN, OUT, BINDABLE_CLUSTERS)
|
REPORT_CONFIG_RPT_CHANGE, RadioType, IN, OUT
|
||||||
|
)
|
||||||
|
from .registries import BINDABLE_CLUSTERS
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -6,21 +6,30 @@ https://home-assistant.io/components/zha/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DEVICE_CLASS, SINGLE_INPUT_CLUSTER_DEVICE_CLASS,
|
HUMIDITY,
|
||||||
SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS, COMPONENT_CLUSTERS, HUMIDITY,
|
|
||||||
TEMPERATURE, ILLUMINANCE, PRESSURE, METERING, ELECTRICAL_MEASUREMENT,
|
TEMPERATURE, ILLUMINANCE, PRESSURE, METERING, ELECTRICAL_MEASUREMENT,
|
||||||
EVENT_RELAY_CLUSTERS, OPENING, ZONE,
|
OCCUPANCY, REPORT_CONFIG_IMMEDIATE, OPENING, ZONE, RADIO_DESCRIPTION,
|
||||||
OCCUPANCY, CLUSTER_REPORT_CONFIGS, REPORT_CONFIG_IMMEDIATE,
|
|
||||||
REPORT_CONFIG_ASAP, REPORT_CONFIG_DEFAULT, REPORT_CONFIG_MIN_INT,
|
REPORT_CONFIG_ASAP, REPORT_CONFIG_DEFAULT, REPORT_CONFIG_MIN_INT,
|
||||||
REPORT_CONFIG_MAX_INT, REPORT_CONFIG_OP,
|
REPORT_CONFIG_MAX_INT, REPORT_CONFIG_OP, ACCELERATION, RadioType, RADIO,
|
||||||
NO_SENSOR_CLUSTERS, BINDABLE_CLUSTERS, ACCELERATION, SENSOR_TYPES,
|
|
||||||
BINARY_SENSOR_TYPES, RADIO_TYPES, RadioType, RADIO, RADIO_DESCRIPTION,
|
|
||||||
CONTROLLER
|
CONTROLLER
|
||||||
)
|
)
|
||||||
|
|
||||||
SMARTTHINGS_HUMIDITY_CLUSTER = 64581
|
SMARTTHINGS_HUMIDITY_CLUSTER = 64581
|
||||||
SMARTTHINGS_ACCELERATION_CLUSTER = 64514
|
SMARTTHINGS_ACCELERATION_CLUSTER = 64514
|
||||||
|
|
||||||
|
DEVICE_CLASS = {}
|
||||||
|
SINGLE_INPUT_CLUSTER_DEVICE_CLASS = {}
|
||||||
|
SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS = {}
|
||||||
|
SENSOR_TYPES = {}
|
||||||
|
RADIO_TYPES = {}
|
||||||
|
BINARY_SENSOR_TYPES = {}
|
||||||
|
CLUSTER_REPORT_CONFIGS = {}
|
||||||
|
CUSTOM_CLUSTER_MAPPINGS = {}
|
||||||
|
COMPONENT_CLUSTERS = {}
|
||||||
|
EVENT_RELAY_CLUSTERS = []
|
||||||
|
NO_SENSOR_CLUSTERS = []
|
||||||
|
BINDABLE_CLUSTERS = []
|
||||||
|
|
||||||
|
|
||||||
def establish_device_mappings():
|
def establish_device_mappings():
|
||||||
"""Establish mappings between ZCL objects and HA ZHA objects.
|
"""Establish mappings between ZCL objects and HA ZHA objects.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user