Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reset functionality for attribute and tests #761

Merged
merged 3 commits into from
Dec 11, 2024

Conversation

DaJansenGit
Copy link
Member

@DaJansenGit DaJansenGit commented Dec 10, 2024

closes #760

Description copied from issue:

For attributes, for which a __get__ via element.attribute (e.g. tz.lighting_power) has been performed before and thus are already calculated, the status will be STATUS_AVAILABLE. Those attributes won't be recalculated again if the get` method is called again. This behaviour is on purpose and totally fine, but in some cases (e.g. enrichment) we want to reset those attributes, to make sure that the enrichment works properly.

Solution

This implements a reset() functionality useable through element.reset('lighting_power')
In test_attribute_reset_with_function_change() we identified a behavior where functions computing results based on a base value x require manual intervention when x changes:

  • When the base value x is modified
  • The attribute needs to be manually reset
  • Only after reset will the attribute recalculate using the new x value

Current Status:

While not ideal, this behavior is manageable as long as we properly use the reset functionality.

Decision:

Following the principle "Perfect is the enemy of the good. Half broken is better than completely broken," we'll keep this behavior for now. The current solution, though requiring manual intervention, is functional and understood. I also added a commit to this in the reset() function.

@DaJansenGit DaJansenGit self-assigned this Dec 10, 2024
@DaJansenGit DaJansenGit linked an issue Dec 10, 2024 that may be closed by this pull request
@DaJansenGit DaJansenGit merged commit e29161c into development Dec 11, 2024
1 check passed
@DaJansenGit DaJansenGit deleted the 760-add-reset-functionality-for-attributes branch December 11, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add reset functionality for attributes
2 participants