mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Use a TypedDict for REPORT_CONFIG in zha (#73629)
* Introduce ReportConfig TypedDict in zha * Fix hint * Always use Tuple * Replace empty list with empty tuple * Allow float for third config tuple value * ReportConfig -> AttrReportConfig * dict -> AttrReportConfig * Allow int attributes * Add coments
This commit is contained in:
parent
be2aa44559
commit
9a95649a22
@ -5,7 +5,7 @@ import asyncio
|
||||
from enum import Enum
|
||||
from functools import partialmethod, wraps
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING, Any, TypedDict
|
||||
|
||||
import zigpy.exceptions
|
||||
import zigpy.zcl
|
||||
@ -46,6 +46,16 @@ if TYPE_CHECKING:
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AttrReportConfig(TypedDict, total=True):
|
||||
"""Configuration to report for the attributes."""
|
||||
|
||||
# Could be either an attribute name or attribute id
|
||||
attr: str | int
|
||||
# The config for the attribute reporting configuration consists of a tuple for
|
||||
# (minimum_reported_time_interval_s, maximum_reported_time_interval_s, value_delta)
|
||||
config: tuple[int, int, int | float]
|
||||
|
||||
|
||||
def parse_and_log_command(channel, tsn, command_id, args):
|
||||
"""Parse and log a zigbee cluster command."""
|
||||
cmd = channel.cluster.server_commands.get(command_id, [command_id])[0]
|
||||
@ -99,7 +109,7 @@ class ChannelStatus(Enum):
|
||||
class ZigbeeChannel(LogMixin):
|
||||
"""Base channel for a Zigbee cluster."""
|
||||
|
||||
REPORT_CONFIG: tuple[dict[int | str, tuple[int, int, int | float]]] = ()
|
||||
REPORT_CONFIG: tuple[AttrReportConfig] = ()
|
||||
BIND: bool = True
|
||||
|
||||
# Dict of attributes to read on channel initialization.
|
||||
|
@ -5,7 +5,7 @@ from homeassistant.core import callback
|
||||
|
||||
from .. import registries
|
||||
from ..const import REPORT_CONFIG_IMMEDIATE, SIGNAL_ATTR_UPDATED
|
||||
from .base import ClientChannel, ZigbeeChannel
|
||||
from .base import AttrReportConfig, ClientChannel, ZigbeeChannel
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(closures.DoorLock.cluster_id)
|
||||
@ -13,7 +13,9 @@ class DoorLockChannel(ZigbeeChannel):
|
||||
"""Door lock channel."""
|
||||
|
||||
_value_attribute = 0
|
||||
REPORT_CONFIG = ({"attr": "lock_state", "config": REPORT_CONFIG_IMMEDIATE},)
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="lock_state", config=REPORT_CONFIG_IMMEDIATE),
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
"""Retrieve latest state."""
|
||||
@ -121,7 +123,9 @@ class WindowCovering(ZigbeeChannel):
|
||||
|
||||
_value_attribute = 8
|
||||
REPORT_CONFIG = (
|
||||
{"attr": "current_position_lift_percentage", "config": REPORT_CONFIG_IMMEDIATE},
|
||||
AttrReportConfig(
|
||||
attr="current_position_lift_percentage", config=REPORT_CONFIG_IMMEDIATE
|
||||
),
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
|
@ -27,7 +27,7 @@ from ..const import (
|
||||
SIGNAL_SET_LEVEL,
|
||||
SIGNAL_UPDATE_DEVICE,
|
||||
)
|
||||
from .base import ClientChannel, ZigbeeChannel, parse_and_log_command
|
||||
from .base import AttrReportConfig, ClientChannel, ZigbeeChannel, parse_and_log_command
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ChannelPool
|
||||
@ -42,7 +42,9 @@ class Alarms(ZigbeeChannel):
|
||||
class AnalogInput(ZigbeeChannel):
|
||||
"""Analog Input channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "present_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.BINDABLE_CLUSTERS.register(general.AnalogOutput.cluster_id)
|
||||
@ -50,7 +52,9 @@ class AnalogInput(ZigbeeChannel):
|
||||
class AnalogOutput(ZigbeeChannel):
|
||||
"""Analog Output channel."""
|
||||
|
||||
REPORT_CONFIG = ({"attr": "present_value", "config": REPORT_CONFIG_DEFAULT},)
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
ZCL_INIT_ATTRS = {
|
||||
"min_present_value": True,
|
||||
"max_present_value": True,
|
||||
@ -119,7 +123,9 @@ class AnalogOutput(ZigbeeChannel):
|
||||
class AnalogValue(ZigbeeChannel):
|
||||
"""Analog Value channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "present_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.ApplianceControl.cluster_id)
|
||||
@ -151,21 +157,27 @@ class BasicChannel(ZigbeeChannel):
|
||||
class BinaryInput(ZigbeeChannel):
|
||||
"""Binary Input channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "present_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.BinaryOutput.cluster_id)
|
||||
class BinaryOutput(ZigbeeChannel):
|
||||
"""Binary Output channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "present_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.BinaryValue.cluster_id)
|
||||
class BinaryValue(ZigbeeChannel):
|
||||
"""Binary Value channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "present_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.Commissioning.cluster_id)
|
||||
@ -177,12 +189,12 @@ class Commissioning(ZigbeeChannel):
|
||||
class DeviceTemperature(ZigbeeChannel):
|
||||
"""Device Temperature channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
REPORT_CONFIG = (
|
||||
{
|
||||
"attr": "current_temperature",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 50),
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.GreenPowerProxy.cluster_id)
|
||||
@ -225,7 +237,7 @@ class LevelControlChannel(ZigbeeChannel):
|
||||
"""Channel for the LevelControl Zigbee cluster."""
|
||||
|
||||
CURRENT_LEVEL = 0
|
||||
REPORT_CONFIG = ({"attr": "current_level", "config": REPORT_CONFIG_ASAP},)
|
||||
REPORT_CONFIG = (AttrReportConfig(attr="current_level", config=REPORT_CONFIG_ASAP),)
|
||||
ZCL_INIT_ATTRS = {
|
||||
"on_off_transition_time": True,
|
||||
"on_level": True,
|
||||
@ -275,21 +287,27 @@ class LevelControlChannel(ZigbeeChannel):
|
||||
class MultistateInput(ZigbeeChannel):
|
||||
"""Multistate Input channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "present_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.MultistateOutput.cluster_id)
|
||||
class MultistateOutput(ZigbeeChannel):
|
||||
"""Multistate Output channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "present_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(general.MultistateValue.cluster_id)
|
||||
class MultistateValue(ZigbeeChannel):
|
||||
"""Multistate Value channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "present_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="present_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.CLIENT_CHANNELS_REGISTRY.register(general.OnOff.cluster_id)
|
||||
@ -303,7 +321,7 @@ class OnOffChannel(ZigbeeChannel):
|
||||
"""Channel for the OnOff Zigbee cluster."""
|
||||
|
||||
ON_OFF = 0
|
||||
REPORT_CONFIG = ({"attr": "on_off", "config": REPORT_CONFIG_IMMEDIATE},)
|
||||
REPORT_CONFIG = (AttrReportConfig(attr="on_off", config=REPORT_CONFIG_IMMEDIATE),)
|
||||
ZCL_INIT_ATTRS = {
|
||||
"start_up_on_off": True,
|
||||
}
|
||||
@ -472,8 +490,10 @@ class PowerConfigurationChannel(ZigbeeChannel):
|
||||
"""Channel for the zigbee power configuration cluster."""
|
||||
|
||||
REPORT_CONFIG = (
|
||||
{"attr": "battery_voltage", "config": REPORT_CONFIG_BATTERY_SAVE},
|
||||
{"attr": "battery_percentage_remaining", "config": REPORT_CONFIG_BATTERY_SAVE},
|
||||
AttrReportConfig(attr="battery_voltage", config=REPORT_CONFIG_BATTERY_SAVE),
|
||||
AttrReportConfig(
|
||||
attr="battery_percentage_remaining", config=REPORT_CONFIG_BATTERY_SAVE
|
||||
),
|
||||
)
|
||||
|
||||
def async_initialize_channel_specific(self, from_cache: bool) -> Coroutine:
|
||||
|
@ -12,7 +12,7 @@ from ..const import (
|
||||
REPORT_CONFIG_OP,
|
||||
SIGNAL_ATTR_UPDATED,
|
||||
)
|
||||
from .base import ZigbeeChannel
|
||||
from .base import AttrReportConfig, ZigbeeChannel
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
|
||||
@ -63,15 +63,15 @@ class ElectricalMeasurementChannel(ZigbeeChannel):
|
||||
POWER_QUALITY_MEASUREMENT = 256
|
||||
|
||||
REPORT_CONFIG = (
|
||||
{"attr": "active_power", "config": REPORT_CONFIG_OP},
|
||||
{"attr": "active_power_max", "config": REPORT_CONFIG_DEFAULT},
|
||||
{"attr": "apparent_power", "config": REPORT_CONFIG_OP},
|
||||
{"attr": "rms_current", "config": REPORT_CONFIG_OP},
|
||||
{"attr": "rms_current_max", "config": REPORT_CONFIG_DEFAULT},
|
||||
{"attr": "rms_voltage", "config": REPORT_CONFIG_OP},
|
||||
{"attr": "rms_voltage_max", "config": REPORT_CONFIG_DEFAULT},
|
||||
{"attr": "ac_frequency", "config": REPORT_CONFIG_OP},
|
||||
{"attr": "ac_frequency_max", "config": REPORT_CONFIG_DEFAULT},
|
||||
AttrReportConfig(attr="active_power", config=REPORT_CONFIG_OP),
|
||||
AttrReportConfig(attr="active_power_max", config=REPORT_CONFIG_DEFAULT),
|
||||
AttrReportConfig(attr="apparent_power", config=REPORT_CONFIG_OP),
|
||||
AttrReportConfig(attr="rms_current", config=REPORT_CONFIG_OP),
|
||||
AttrReportConfig(attr="rms_current_max", config=REPORT_CONFIG_DEFAULT),
|
||||
AttrReportConfig(attr="rms_voltage", config=REPORT_CONFIG_OP),
|
||||
AttrReportConfig(attr="rms_voltage_max", config=REPORT_CONFIG_DEFAULT),
|
||||
AttrReportConfig(attr="ac_frequency", config=REPORT_CONFIG_OP),
|
||||
AttrReportConfig(attr="ac_frequency_max", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
ZCL_INIT_ATTRS = {
|
||||
"ac_current_divisor": True,
|
||||
|
@ -22,7 +22,7 @@ from ..const import (
|
||||
REPORT_CONFIG_OP,
|
||||
SIGNAL_ATTR_UPDATED,
|
||||
)
|
||||
from .base import ZigbeeChannel
|
||||
from .base import AttrReportConfig, ZigbeeChannel
|
||||
|
||||
AttributeUpdateRecord = namedtuple("AttributeUpdateRecord", "attr_id, attr_name, value")
|
||||
REPORT_CONFIG_CLIMATE = (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 25)
|
||||
@ -41,7 +41,7 @@ class FanChannel(ZigbeeChannel):
|
||||
|
||||
_value_attribute = 0
|
||||
|
||||
REPORT_CONFIG = ({"attr": "fan_mode", "config": REPORT_CONFIG_OP},)
|
||||
REPORT_CONFIG = (AttrReportConfig(attr="fan_mode", config=REPORT_CONFIG_OP),)
|
||||
ZCL_INIT_ATTRS = {"fan_mode_sequence": True}
|
||||
|
||||
@property
|
||||
@ -90,17 +90,25 @@ class ThermostatChannel(ZigbeeChannel):
|
||||
"""Thermostat channel."""
|
||||
|
||||
REPORT_CONFIG = (
|
||||
{"attr": "local_temperature", "config": REPORT_CONFIG_CLIMATE},
|
||||
{"attr": "occupied_cooling_setpoint", "config": REPORT_CONFIG_CLIMATE},
|
||||
{"attr": "occupied_heating_setpoint", "config": REPORT_CONFIG_CLIMATE},
|
||||
{"attr": "unoccupied_cooling_setpoint", "config": REPORT_CONFIG_CLIMATE},
|
||||
{"attr": "unoccupied_heating_setpoint", "config": REPORT_CONFIG_CLIMATE},
|
||||
{"attr": "running_mode", "config": REPORT_CONFIG_CLIMATE},
|
||||
{"attr": "running_state", "config": REPORT_CONFIG_CLIMATE_DEMAND},
|
||||
{"attr": "system_mode", "config": REPORT_CONFIG_CLIMATE},
|
||||
{"attr": "occupancy", "config": REPORT_CONFIG_CLIMATE_DISCRETE},
|
||||
{"attr": "pi_cooling_demand", "config": REPORT_CONFIG_CLIMATE_DEMAND},
|
||||
{"attr": "pi_heating_demand", "config": REPORT_CONFIG_CLIMATE_DEMAND},
|
||||
AttrReportConfig(attr="local_temperature", config=REPORT_CONFIG_CLIMATE),
|
||||
AttrReportConfig(
|
||||
attr="occupied_cooling_setpoint", config=REPORT_CONFIG_CLIMATE
|
||||
),
|
||||
AttrReportConfig(
|
||||
attr="occupied_heating_setpoint", config=REPORT_CONFIG_CLIMATE
|
||||
),
|
||||
AttrReportConfig(
|
||||
attr="unoccupied_cooling_setpoint", config=REPORT_CONFIG_CLIMATE
|
||||
),
|
||||
AttrReportConfig(
|
||||
attr="unoccupied_heating_setpoint", config=REPORT_CONFIG_CLIMATE
|
||||
),
|
||||
AttrReportConfig(attr="running_mode", config=REPORT_CONFIG_CLIMATE),
|
||||
AttrReportConfig(attr="running_state", config=REPORT_CONFIG_CLIMATE_DEMAND),
|
||||
AttrReportConfig(attr="system_mode", config=REPORT_CONFIG_CLIMATE),
|
||||
AttrReportConfig(attr="occupancy", config=REPORT_CONFIG_CLIMATE_DISCRETE),
|
||||
AttrReportConfig(attr="pi_cooling_demand", config=REPORT_CONFIG_CLIMATE_DEMAND),
|
||||
AttrReportConfig(attr="pi_heating_demand", config=REPORT_CONFIG_CLIMATE_DEMAND),
|
||||
)
|
||||
ZCL_INIT_ATTRS: dict[int | str, bool] = {
|
||||
"abs_min_heat_setpoint_limit": True,
|
||||
|
@ -7,7 +7,7 @@ from zigpy.zcl.clusters import lighting
|
||||
|
||||
from .. import registries
|
||||
from ..const import REPORT_CONFIG_DEFAULT
|
||||
from .base import ClientChannel, ZigbeeChannel
|
||||
from .base import AttrReportConfig, ClientChannel, ZigbeeChannel
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(lighting.Ballast.cluster_id)
|
||||
@ -29,9 +29,9 @@ class ColorChannel(ZigbeeChannel):
|
||||
CAPABILITIES_COLOR_TEMP = 0x10
|
||||
UNSUPPORTED_ATTRIBUTE = 0x86
|
||||
REPORT_CONFIG = (
|
||||
{"attr": "current_x", "config": REPORT_CONFIG_DEFAULT},
|
||||
{"attr": "current_y", "config": REPORT_CONFIG_DEFAULT},
|
||||
{"attr": "color_temperature", "config": REPORT_CONFIG_DEFAULT},
|
||||
AttrReportConfig(attr="current_x", config=REPORT_CONFIG_DEFAULT),
|
||||
AttrReportConfig(attr="current_y", config=REPORT_CONFIG_DEFAULT),
|
||||
AttrReportConfig(attr="color_temperature", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
MAX_MIREDS: int = 500
|
||||
MIN_MIREDS: int = 153
|
||||
|
@ -19,7 +19,7 @@ from ..const import (
|
||||
SIGNAL_ATTR_UPDATED,
|
||||
UNKNOWN,
|
||||
)
|
||||
from .base import ClientChannel, ZigbeeChannel
|
||||
from .base import AttrReportConfig, ClientChannel, ZigbeeChannel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ChannelPool
|
||||
@ -31,12 +31,12 @@ _LOGGER = logging.getLogger(__name__)
|
||||
class SmartThingsHumidity(ZigbeeChannel):
|
||||
"""Smart Things Humidity channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
REPORT_CONFIG = (
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 50),
|
||||
}
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@registries.CHANNEL_ONLY_CLUSTERS.register(0xFD00)
|
||||
@ -44,7 +44,7 @@ class SmartThingsHumidity(ZigbeeChannel):
|
||||
class OsramButton(ZigbeeChannel):
|
||||
"""Osram button channel."""
|
||||
|
||||
REPORT_CONFIG = []
|
||||
REPORT_CONFIG = ()
|
||||
|
||||
|
||||
@registries.CHANNEL_ONLY_CLUSTERS.register(registries.PHILLIPS_REMOTE_CLUSTER)
|
||||
@ -52,7 +52,7 @@ class OsramButton(ZigbeeChannel):
|
||||
class PhillipsRemote(ZigbeeChannel):
|
||||
"""Phillips remote channel."""
|
||||
|
||||
REPORT_CONFIG = []
|
||||
REPORT_CONFIG = ()
|
||||
|
||||
|
||||
@registries.CHANNEL_ONLY_CLUSTERS.register(0xFCC0)
|
||||
@ -60,7 +60,7 @@ class PhillipsRemote(ZigbeeChannel):
|
||||
class OppleRemote(ZigbeeChannel):
|
||||
"""Opple button channel."""
|
||||
|
||||
REPORT_CONFIG = []
|
||||
REPORT_CONFIG = ()
|
||||
|
||||
def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None:
|
||||
"""Initialize Opple channel."""
|
||||
@ -87,12 +87,12 @@ class OppleRemote(ZigbeeChannel):
|
||||
class SmartThingsAcceleration(ZigbeeChannel):
|
||||
"""Smart Things Acceleration channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{"attr": "acceleration", "config": REPORT_CONFIG_ASAP},
|
||||
{"attr": "x_axis", "config": REPORT_CONFIG_ASAP},
|
||||
{"attr": "y_axis", "config": REPORT_CONFIG_ASAP},
|
||||
{"attr": "z_axis", "config": REPORT_CONFIG_ASAP},
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="acceleration", config=REPORT_CONFIG_ASAP),
|
||||
AttrReportConfig(attr="x_axis", config=REPORT_CONFIG_ASAP),
|
||||
AttrReportConfig(attr="y_axis", config=REPORT_CONFIG_ASAP),
|
||||
AttrReportConfig(attr="z_axis", config=REPORT_CONFIG_ASAP),
|
||||
)
|
||||
|
||||
@callback
|
||||
def attribute_updated(self, attrid, value):
|
||||
@ -121,4 +121,4 @@ class SmartThingsAcceleration(ZigbeeChannel):
|
||||
class InovelliCluster(ClientChannel):
|
||||
"""Inovelli Button Press Event channel."""
|
||||
|
||||
REPORT_CONFIG = []
|
||||
REPORT_CONFIG = ()
|
||||
|
@ -8,14 +8,16 @@ from ..const import (
|
||||
REPORT_CONFIG_MAX_INT,
|
||||
REPORT_CONFIG_MIN_INT,
|
||||
)
|
||||
from .base import ZigbeeChannel
|
||||
from .base import AttrReportConfig, ZigbeeChannel
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(measurement.FlowMeasurement.cluster_id)
|
||||
class FlowMeasurement(ZigbeeChannel):
|
||||
"""Flow Measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "measured_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="measured_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
|
||||
@ -24,7 +26,9 @@ class FlowMeasurement(ZigbeeChannel):
|
||||
class IlluminanceLevelSensing(ZigbeeChannel):
|
||||
"""Illuminance Level Sensing channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "level_status", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="level_status", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
|
||||
@ -33,57 +37,63 @@ class IlluminanceLevelSensing(ZigbeeChannel):
|
||||
class IlluminanceMeasurement(ZigbeeChannel):
|
||||
"""Illuminance Measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "measured_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="measured_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(measurement.OccupancySensing.cluster_id)
|
||||
class OccupancySensing(ZigbeeChannel):
|
||||
"""Occupancy Sensing channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "occupancy", "config": REPORT_CONFIG_IMMEDIATE}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="occupancy", config=REPORT_CONFIG_IMMEDIATE),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(measurement.PressureMeasurement.cluster_id)
|
||||
class PressureMeasurement(ZigbeeChannel):
|
||||
"""Pressure measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [{"attr": "measured_value", "config": REPORT_CONFIG_DEFAULT}]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(attr="measured_value", config=REPORT_CONFIG_DEFAULT),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(measurement.RelativeHumidity.cluster_id)
|
||||
class RelativeHumidity(ZigbeeChannel):
|
||||
"""Relative Humidity measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 100),
|
||||
}
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(
|
||||
attr="measured_value",
|
||||
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 100),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(measurement.SoilMoisture.cluster_id)
|
||||
class SoilMoisture(ZigbeeChannel):
|
||||
"""Soil Moisture measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 100),
|
||||
}
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(
|
||||
attr="measured_value",
|
||||
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 100),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(measurement.LeafWetness.cluster_id)
|
||||
class LeafWetness(ZigbeeChannel):
|
||||
"""Leaf Wetness measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 100),
|
||||
}
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(
|
||||
attr="measured_value",
|
||||
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 100),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
|
||||
@ -92,12 +102,12 @@ class LeafWetness(ZigbeeChannel):
|
||||
class TemperatureMeasurement(ZigbeeChannel):
|
||||
"""Temperature measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 50),
|
||||
}
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(
|
||||
attr="measured_value",
|
||||
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 50),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
|
||||
@ -106,12 +116,12 @@ class TemperatureMeasurement(ZigbeeChannel):
|
||||
class CarbonMonoxideConcentration(ZigbeeChannel):
|
||||
"""Carbon Monoxide measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.000001),
|
||||
}
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(
|
||||
attr="measured_value",
|
||||
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.000001),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
|
||||
@ -120,24 +130,24 @@ class CarbonMonoxideConcentration(ZigbeeChannel):
|
||||
class CarbonDioxideConcentration(ZigbeeChannel):
|
||||
"""Carbon Dioxide measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.000001),
|
||||
}
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(
|
||||
attr="measured_value",
|
||||
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.000001),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(measurement.PM25.cluster_id)
|
||||
class PM25(ZigbeeChannel):
|
||||
"""Particulate Matter 2.5 microns or less measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.1),
|
||||
}
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(
|
||||
attr="measured_value",
|
||||
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.1),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
|
||||
@ -146,9 +156,9 @@ class PM25(ZigbeeChannel):
|
||||
class FormaldehydeConcentration(ZigbeeChannel):
|
||||
"""Formaldehyde measurement channel."""
|
||||
|
||||
REPORT_CONFIG = [
|
||||
{
|
||||
"attr": "measured_value",
|
||||
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.000001),
|
||||
}
|
||||
]
|
||||
REPORT_CONFIG = (
|
||||
AttrReportConfig(
|
||||
attr="measured_value",
|
||||
config=(REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.000001),
|
||||
),
|
||||
)
|
||||
|
@ -15,7 +15,7 @@ from ..const import (
|
||||
REPORT_CONFIG_OP,
|
||||
SIGNAL_ATTR_UPDATED,
|
||||
)
|
||||
from .base import ZigbeeChannel
|
||||
from .base import AttrReportConfig, ZigbeeChannel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import ChannelPool
|
||||
@ -66,9 +66,9 @@ class Metering(ZigbeeChannel):
|
||||
"""Metering channel."""
|
||||
|
||||
REPORT_CONFIG = (
|
||||
{"attr": "instantaneous_demand", "config": REPORT_CONFIG_OP},
|
||||
{"attr": "current_summ_delivered", "config": REPORT_CONFIG_DEFAULT},
|
||||
{"attr": "status", "config": REPORT_CONFIG_ASAP},
|
||||
AttrReportConfig(attr="instantaneous_demand", config=REPORT_CONFIG_OP),
|
||||
AttrReportConfig(attr="current_summ_delivered", config=REPORT_CONFIG_DEFAULT),
|
||||
AttrReportConfig(attr="status", config=REPORT_CONFIG_ASAP),
|
||||
)
|
||||
ZCL_INIT_ATTRS = {
|
||||
"demand_formatting": True,
|
||||
|
Loading…
x
Reference in New Issue
Block a user