Skip to content

Commit

Permalink
Handle both REPORT_CONFIG and ZCL_INIT_ATTRS
Browse files Browse the repository at this point in the history
If both ZCL_INIT_ATTRS and REPORT_CONFIG contain
the same attribute, with the current cluster logic,
you end up in a situation where said attribute is
marked as both cacheable and uncacheable at the
same time, leading to it being configured twice.

As they are designed to be mutually exclusive of
each other, let's add the logic to remove attributes
from ZCL_INIT_ATTRS if they are already present in
REPORT_CONFIG.

REPORT_CONFIG will take precedence over ZCL_INIT_ATTRS.
  • Loading branch information
benbancroft committed Dec 29, 2024
1 parent c8cca3e commit 69f6242
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions zha/zigbee/cluster_handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,10 @@ async def async_initialize(self, from_cache: bool) -> None:
return

self.debug("initializing cluster handler: from_cache: %s", from_cache)
cached = [a for a, cached in self.ZCL_INIT_ATTRS.items() if cached]
uncached = [a for a, cached in self.ZCL_INIT_ATTRS.items() if not cached]
uncached.extend([cfg["attr"] for cfg in self.REPORT_CONFIG])
cache_config = self.ZCL_INIT_ATTRS.copy()
cache_config |= {cfg["attr"]: False for cfg in self.REPORT_CONFIG}
cached = [a for a, cached in cache_config.items() if cached]
uncached = [a for a, cached in cache_config.items() if not cached]

if cached:
self.debug("initializing cached cluster handler attributes: %s", cached)
Expand Down

0 comments on commit 69f6242

Please sign in to comment.