mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +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
|
||||
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,
|
||||
safe_read, get_attr_id_by_name)
|
||||
from ..const import (
|
||||
CLUSTER_REPORT_CONFIGS, REPORT_CONFIG_DEFAULT, SIGNAL_ATTR_UPDATED,
|
||||
ATTRIBUTE_CHANNEL, EVENT_RELAY_CHANNEL, ZDO_CHANNEL
|
||||
REPORT_CONFIG_DEFAULT, SIGNAL_ATTR_UPDATED, ATTRIBUTE_CHANNEL,
|
||||
EVENT_RELAY_CHANNEL, ZDO_CHANNEL
|
||||
)
|
||||
from ..registries import CLUSTER_REPORT_CONFIGS
|
||||
|
||||
NODE_DESCRIPTOR_REQUEST = 0x0002
|
||||
MAINS_POWERED = 1
|
||||
|
@ -10,9 +10,9 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from . import ZigbeeChannel, parse_and_log_command
|
||||
from ..helpers import get_attr_id_by_name
|
||||
from ..const import (
|
||||
SIGNAL_ATTR_UPDATED,
|
||||
SIGNAL_MOVE_LEVEL, SIGNAL_SET_LEVEL, SIGNAL_STATE_ATTR, BASIC_CHANNEL,
|
||||
ON_OFF_CHANNEL, LEVEL_CHANNEL, POWER_CONFIGURATION_CHANNEL
|
||||
SIGNAL_ATTR_UPDATED, SIGNAL_MOVE_LEVEL, SIGNAL_SET_LEVEL,
|
||||
SIGNAL_STATE_ATTR, BASIC_CHANNEL, ON_OFF_CHANNEL, LEVEL_CHANNEL,
|
||||
POWER_CONFIGURATION_CHANNEL
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -121,18 +121,6 @@ class RadioType(enum.Enum):
|
||||
|
||||
|
||||
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_BATTERY_SAVE = 10800
|
||||
|
@ -10,16 +10,18 @@ import logging
|
||||
from homeassistant import const as ha_const
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from . import const as zha_const
|
||||
from .channels import (
|
||||
AttributeListeningChannel, EventRelayChannel, ZDOChannel
|
||||
)
|
||||
from .channels.registry import ZIGBEE_CHANNEL_REGISTRY
|
||||
from .const import (
|
||||
CONF_DEVICE_CONFIG, COMPONENTS, ZHA_DISCOVERY_NEW, DATA_ZHA,
|
||||
SENSOR_TYPE, UNKNOWN, BINARY_SENSOR_TYPES, NO_SENSOR_CLUSTERS,
|
||||
EVENT_RELAY_CLUSTERS, SENSOR_TYPES, GENERIC,
|
||||
POWER_CONFIGURATION_CHANNEL
|
||||
SENSOR_TYPE, UNKNOWN, 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
|
||||
|
||||
@ -53,16 +55,15 @@ def async_process_endpoint(
|
||||
|
||||
if endpoint.profile_id in zigpy.profiles.PROFILES:
|
||||
profile = zigpy.profiles.PROFILES[endpoint.profile_id]
|
||||
if zha_const.DEVICE_CLASS.get(endpoint.profile_id,
|
||||
{}).get(endpoint.device_type,
|
||||
None):
|
||||
if DEVICE_CLASS.get(endpoint.profile_id, {}).get(
|
||||
endpoint.device_type, None):
|
||||
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]
|
||||
|
||||
if ha_const.CONF_TYPE in node_config:
|
||||
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:
|
||||
profile_match = _async_handle_profile_match(
|
||||
@ -179,7 +180,7 @@ def _async_handle_single_cluster_matches(hass, endpoint, zha_device,
|
||||
zha_device,
|
||||
cluster,
|
||||
device_key,
|
||||
zha_const.SINGLE_INPUT_CLUSTER_DEVICE_CLASS,
|
||||
SINGLE_INPUT_CLUSTER_DEVICE_CLASS,
|
||||
is_new_join,
|
||||
))
|
||||
|
||||
@ -190,7 +191,7 @@ def _async_handle_single_cluster_matches(hass, endpoint, zha_device,
|
||||
zha_device,
|
||||
cluster,
|
||||
device_key,
|
||||
zha_const.SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS,
|
||||
SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS,
|
||||
is_new_join,
|
||||
))
|
||||
|
||||
|
@ -15,11 +15,11 @@ from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from .const import (
|
||||
DATA_ZHA, DATA_ZHA_CORE_COMPONENT, DOMAIN,
|
||||
SIGNAL_REMOVE, DATA_ZHA_GATEWAY, CONF_USB_PATH, CONF_BAUDRATE,
|
||||
DEFAULT_BAUDRATE, CONF_RADIO_TYPE, DATA_ZHA_RADIO, CONF_DATABASE,
|
||||
DEFAULT_DATABASE_NAME, DATA_ZHA_BRIDGE_ID, RADIO_TYPES,
|
||||
RADIO, CONTROLLER, RADIO_DESCRIPTION)
|
||||
DATA_ZHA, DATA_ZHA_CORE_COMPONENT, DOMAIN, SIGNAL_REMOVE, DATA_ZHA_GATEWAY,
|
||||
CONF_USB_PATH, CONF_BAUDRATE, DEFAULT_BAUDRATE, CONF_RADIO_TYPE,
|
||||
DATA_ZHA_RADIO, CONF_DATABASE, DEFAULT_DATABASE_NAME, DATA_ZHA_BRIDGE_ID,
|
||||
RADIO, CONTROLLER, RADIO_DESCRIPTION
|
||||
)
|
||||
from .device import ZHADevice, DeviceStatus
|
||||
from .channels import (
|
||||
ZDOChannel, MAINS_POWERED
|
||||
@ -31,6 +31,7 @@ from .discovery import (
|
||||
)
|
||||
from .store import async_get_registry
|
||||
from .patches import apply_application_controller_patch
|
||||
from .registries import RADIO_TYPES
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -11,7 +11,9 @@ from concurrent.futures import TimeoutError as Timeout
|
||||
from homeassistant.core import callback
|
||||
from .const import (
|
||||
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__)
|
||||
|
||||
|
@ -6,21 +6,30 @@ https://home-assistant.io/components/zha/
|
||||
"""
|
||||
|
||||
from .const import (
|
||||
DEVICE_CLASS, SINGLE_INPUT_CLUSTER_DEVICE_CLASS,
|
||||
SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS, COMPONENT_CLUSTERS, HUMIDITY,
|
||||
HUMIDITY,
|
||||
TEMPERATURE, ILLUMINANCE, PRESSURE, METERING, ELECTRICAL_MEASUREMENT,
|
||||
EVENT_RELAY_CLUSTERS, OPENING, ZONE,
|
||||
OCCUPANCY, CLUSTER_REPORT_CONFIGS, REPORT_CONFIG_IMMEDIATE,
|
||||
OCCUPANCY, REPORT_CONFIG_IMMEDIATE, OPENING, ZONE, RADIO_DESCRIPTION,
|
||||
REPORT_CONFIG_ASAP, REPORT_CONFIG_DEFAULT, REPORT_CONFIG_MIN_INT,
|
||||
REPORT_CONFIG_MAX_INT, REPORT_CONFIG_OP,
|
||||
NO_SENSOR_CLUSTERS, BINDABLE_CLUSTERS, ACCELERATION, SENSOR_TYPES,
|
||||
BINARY_SENSOR_TYPES, RADIO_TYPES, RadioType, RADIO, RADIO_DESCRIPTION,
|
||||
REPORT_CONFIG_MAX_INT, REPORT_CONFIG_OP, ACCELERATION, RadioType, RADIO,
|
||||
CONTROLLER
|
||||
)
|
||||
|
||||
SMARTTHINGS_HUMIDITY_CLUSTER = 64581
|
||||
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():
|
||||
"""Establish mappings between ZCL objects and HA ZHA objects.
|
||||
|
Loading…
x
Reference in New Issue
Block a user