Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate polling attributes in electrical measurement cluster #354

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions tests/test_cluster_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,13 @@ async def poll_control_device_mock(zha_gateway: Gateway) -> Device:
1,
{
"ac_frequency",
"ac_frequency_max",
"active_power",
"active_power_max",
"apparent_power",
"rms_current",
"rms_current_ph_b",
"rms_current_ph_c",
"rms_current_max",
"rms_current_max_b",
"rms_current_max_c",
"rms_voltage",
"rms_voltage_max",
},
),
],
Expand Down
46 changes: 18 additions & 28 deletions zha/zigbee/cluster_handlers/homeautomation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from zha.zigbee.cluster_handlers import AttrReportConfig, ClusterHandler, registries
from zha.zigbee.cluster_handlers.const import (
CLUSTER_HANDLER_ELECTRICAL_MEASUREMENT,
REPORT_CONFIG_DEFAULT,
REPORT_CONFIG_OP,
)

Expand Down Expand Up @@ -65,10 +64,6 @@ class MeasurementType(enum.IntFlag):
attr=ElectricalMeasurement.AttributeDefs.active_power.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.active_power_max.name,
config=REPORT_CONFIG_DEFAULT,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.apparent_power.name,
config=REPORT_CONFIG_OP,
Expand All @@ -85,35 +80,30 @@ class MeasurementType(enum.IntFlag):
attr=ElectricalMeasurement.AttributeDefs.rms_current_ph_c.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_current_max.name,
config=REPORT_CONFIG_DEFAULT,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_current_max_ph_b.name,
config=REPORT_CONFIG_DEFAULT,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_current_max_ph_c.name,
config=REPORT_CONFIG_DEFAULT,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_voltage.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_voltage_max.name,
config=REPORT_CONFIG_DEFAULT,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.ac_frequency.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.ac_frequency_max.name,
config=REPORT_CONFIG_DEFAULT,
),
)
ZCL_POLLING_ATTRS = [
ElectricalMeasurement.AttributeDefs.ac_frequency.name,
ElectricalMeasurement.AttributeDefs.ac_frequency_max.name,
ElectricalMeasurement.AttributeDefs.active_power.name,
ElectricalMeasurement.AttributeDefs.active_power_max.name,
ElectricalMeasurement.AttributeDefs.apparent_power.name,
ElectricalMeasurement.AttributeDefs.rms_current.name,
ElectricalMeasurement.AttributeDefs.rms_current_max.name,
ElectricalMeasurement.AttributeDefs.rms_current_max_ph_b.name,
ElectricalMeasurement.AttributeDefs.rms_current_max_ph_c.name,
ElectricalMeasurement.AttributeDefs.rms_current_ph_b.name,
ElectricalMeasurement.AttributeDefs.rms_current_ph_c.name,
ElectricalMeasurement.AttributeDefs.rms_voltage.name,
ElectricalMeasurement.AttributeDefs.rms_voltage_max.name,
]
ZCL_INIT_ATTRS = {
ElectricalMeasurement.AttributeDefs.ac_current_divisor.name: True,
ElectricalMeasurement.AttributeDefs.ac_current_multiplier.name: True,
Expand All @@ -135,9 +125,9 @@ async def async_update(self):

# This is a polling cluster handler. Don't allow cache.
attrs = [
a["attr"]
for a in self.REPORT_CONFIG
if a["attr"] not in self.cluster.unsupported_attributes
attr
for attr in self.ZCL_POLLING_ATTRS
if attr not in self.cluster.unsupported_attributes
]
result = await self.get_attributes(attrs, from_cache=False, only_cache=False)
if result:
Expand Down
Loading