Reduce ZHA OTA logbook entries and extraneous updates (#114591)

pull/114764/head
puddly 2024-04-02 08:16:59 -07:00 committed by Franck Nijhof
parent 5af5f3694e
commit 4e0d6f287e
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 7 additions and 5 deletions

View File

@ -553,6 +553,13 @@ class OtaClientClusterHandler(ClientClusterHandler):
Ota.AttributeDefs.current_file_version.name: True,
}
@callback
def attribute_updated(self, attrid: int, value: Any, timestamp: Any) -> None:
"""Handle an attribute updated on this cluster."""
# We intentionally avoid the `ClientClusterHandler` attribute update handler:
# it emits a logbook event on every update, which pollutes the logbook
ClusterHandler.attribute_updated(self, attrid, value, timestamp)
@property
def current_file_version(self) -> int | None:
"""Return cached value of current_file_version attribute."""

View File

@ -130,14 +130,9 @@ class ZHAFirmwareUpdateEntity(
def _get_cluster_version(self) -> str | None:
"""Synchronize current file version with the cluster."""
device = self._ota_cluster_handler._endpoint.device # pylint: disable=protected-access
if self._ota_cluster_handler.current_file_version is not None:
return f"0x{self._ota_cluster_handler.current_file_version:08x}"
if device.sw_version is not None:
return device.sw_version
return None
@callback