Skip to content

Commit

Permalink
Separate polling attributes in homeautomation cluster
Browse files Browse the repository at this point in the history
As suggested in zigpy#339 (comment) this adds
an `ZCL_POLLING_ATTRS` to define attributes that should be polled
separatelly from the ones that can have reporting config.

This also moves some attributes that do no support reporting config out
of `REPORT_CONFIG`.
  • Loading branch information
abmantis committed Jan 19, 2025
1 parent a833f43 commit 6c4926b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
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
32 changes: 31 additions & 1 deletion zha/zigbee/cluster_handlers/homeautomation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@ class MeasurementType(enum.IntFlag):
POWER_QUALITY_MEASUREMENT = 256

REPORT_CONFIG = (
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.active_power.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.apparent_power.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_current.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_current_ph_b.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_current_ph_c.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.rms_voltage.name,
config=REPORT_CONFIG_OP,
),
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.ac_frequency.name,
config=REPORT_CONFIG_OP,
),
)
ZCL_POLLING_ATTRS = (
AttrReportConfig(
attr=ElectricalMeasurement.AttributeDefs.active_power.name,
config=REPORT_CONFIG_OP,
Expand Down Expand Up @@ -136,7 +166,7 @@ async def async_update(self):
# This is a polling cluster handler. Don't allow cache.
attrs = [
a["attr"]
for a in self.REPORT_CONFIG
for a in self.ZCL_POLLING_ATTRS
if a["attr"] not in self.cluster.unsupported_attributes
]
result = await self.get_attributes(attrs, from_cache=False, only_cache=False)
Expand Down

0 comments on commit 6c4926b

Please sign in to comment.