Add post update hook to module and use in smart LightEffect (#921)

Adds a post update hook to modules so they can calculate values and collections once rather than on each property access
This commit is contained in:
Steven B
2024-05-19 10:18:17 +01:00
committed by GitHub
parent 3490a1ef84
commit 9989d0f6ec
5 changed files with 46 additions and 23 deletions

View File

@@ -107,6 +107,18 @@ class Module(ABC):
"""Initialize features after the initial update.
This can be implemented if features depend on module query responses.
It will only be called once per module and will always be called
after *_post_update_hook* has been called for every device module and its
children's modules.
"""
def _post_update_hook(self): # noqa: B027
"""Perform actions after a device update.
This can be implemented if a module needs to perform actions each time
the device has updated like generating collections for property access.
It will be called after every update and will be called prior to
*_initialize_features* on the first update.
"""
def _add_feature(self, feature: Feature):