Skip to content
Snippets Groups Projects
Unverified Commit c3222ef7 authored by David F. Mulcahey's avatar David F. Mulcahey Committed by GitHub
Browse files

Fix statuses for ZHA attribute reporting configuration event (#108532)

parent 8abb4e5f
No related branches found
No related tags found
No related merge requests found
...@@ -262,7 +262,7 @@ class ClusterHandler(LogMixin): ...@@ -262,7 +262,7 @@ class ClusterHandler(LogMixin):
"id": attr, "id": attr,
"name": attr_name, "name": attr_name,
"change": config[2], "change": config[2],
"success": False, "status": None,
} }
to_configure = [*self.REPORT_CONFIG] to_configure = [*self.REPORT_CONFIG]
...@@ -274,10 +274,7 @@ class ClusterHandler(LogMixin): ...@@ -274,10 +274,7 @@ class ClusterHandler(LogMixin):
reports = {rec["attr"]: rec["config"] for rec in chunk} reports = {rec["attr"]: rec["config"] for rec in chunk}
try: try:
res = await self.cluster.configure_reporting_multiple(reports, **kwargs) res = await self.cluster.configure_reporting_multiple(reports, **kwargs)
self._configure_reporting_status(reports, res[0]) self._configure_reporting_status(reports, res[0], event_data)
# if we get a response, then it's a success
for attr_stat in event_data.values():
attr_stat["success"] = True
except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex: except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex:
self.debug( self.debug(
"failed to set reporting on '%s' cluster for: %s", "failed to set reporting on '%s' cluster for: %s",
...@@ -304,7 +301,10 @@ class ClusterHandler(LogMixin): ...@@ -304,7 +301,10 @@ class ClusterHandler(LogMixin):
) )
def _configure_reporting_status( def _configure_reporting_status(
self, attrs: dict[str, tuple[int, int, float | int]], res: list | tuple self,
attrs: dict[str, tuple[int, int, float | int]],
res: list | tuple,
event_data: dict[str, dict[str, Any]],
) -> None: ) -> None:
"""Parse configure reporting result.""" """Parse configure reporting result."""
if isinstance(res, (Exception, ConfigureReportingResponseRecord)): if isinstance(res, (Exception, ConfigureReportingResponseRecord)):
...@@ -315,6 +315,8 @@ class ClusterHandler(LogMixin): ...@@ -315,6 +315,8 @@ class ClusterHandler(LogMixin):
self.name, self.name,
res, res,
) )
for attr in attrs:
event_data[attr]["status"] = Status.FAILURE.name
return return
if res[0].status == Status.SUCCESS and len(res) == 1: if res[0].status == Status.SUCCESS and len(res) == 1:
self.debug( self.debug(
...@@ -323,24 +325,38 @@ class ClusterHandler(LogMixin): ...@@ -323,24 +325,38 @@ class ClusterHandler(LogMixin):
self.name, self.name,
res, res,
) )
# 2.5.8.1.3 Status Field
# The status field specifies the status of the Configure Reporting operation attempted on this attribute, as detailed in 2.5.7.3.
# Note that attribute status records are not included for successfully configured attributes, in order to save bandwidth.
# In the case of successful configuration of all attributes, only a single attribute status record SHALL be included in the command,
# with the status field set to SUCCESS and the direction and attribute identifier fields omitted.
for attr in attrs:
event_data[attr]["status"] = Status.SUCCESS.name
return return
for record in res:
event_data[self.cluster.find_attribute(record.attrid).name][
"status"
] = record.status.name
failed = [ failed = [
self.cluster.find_attribute(record.attrid).name self.cluster.find_attribute(record.attrid).name
for record in res for record in res
if record.status != Status.SUCCESS if record.status != Status.SUCCESS
] ]
self.debug(
"Successfully configured reporting for '%s' on '%s' cluster",
set(attrs) - set(failed),
self.name,
)
self.debug( self.debug(
"Failed to configure reporting for '%s' on '%s' cluster: %s", "Failed to configure reporting for '%s' on '%s' cluster: %s",
failed, failed,
self.name, self.name,
res, res,
) )
success = set(attrs) - set(failed)
self.debug(
"Successfully configured reporting for '%s' on '%s' cluster",
set(attrs) - set(failed),
self.name,
)
for attr in success:
event_data[attr]["status"] = Status.SUCCESS.name
async def async_configure(self) -> None: async def async_configure(self) -> None:
"""Set cluster binding and attribute reporting.""" """Set cluster binding and attribute reporting."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment