Emit OnOffClientClusterHandler attribute_updated events first
#642
+6
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
This changes the
OnOffClientClusterHandlerto first process the event, updating attribute cache and emittingattribute_updatedZHA events, then forwarding the cluster command to emit the ZHA event.Additional information
Issue
There are a lot of blueprints available that use the
restartautomation mode and unfortunately trigger on all ZHA events. Even if they're later ignored in the automations "action" section, the automation will still restart for them, aborting the existing run.Ideally, the automation should only trigger for events that actually need to be processed (filter in triggers section or conditions section). But since this is not the case, we need to change our behavior to not break all of the blueprints.
Previous behavior & alternative solutions
The previous behavior did not emit
attribute_updatedevents at all for remotes, as the normalClusterHandlerwas used, not theClientClusterHandler. Only the latter class includes behavior to emit ZHA events for attribute updates:zha/zha/zigbee/cluster_handlers/__init__.py
Lines 753 to 771 in 3adf2db
Alternatively, I'm thinking if we should just call
ClusterHandler._handle_attribute_updated_event()instead, skipping the ZHA event being emitted inClientClusterHandler. I think that should restore old behavior completely?As a third solution, I can only think of skipping ZHA events being emitted depending on which entity is associated with that cluster handler (where the entity already depends on the device type). This likely won't work nicely though.
Previous TODO:
Investigate not emitting
attribute_updatedevents for entireOnOffcluster (OnOffClientClusterHandler).See "Previous behavior & alternative solutions".
-> EDIT: See: #642 (comment)
Reported on Discord:
Related:
OnOffremote handling)OnOffclient cluster commands not updating attribute cache #635 (PR reintroducingOnOffhandling, now inOnOffClientClusterHandler)