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

Make a number of refactors to how the state of devices is set. #53

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

kingsleyadam
Copy link
Owner

This is a refactor to how the state of devices is set. This should reduce the amount of duplicate code. Thanks @derjoerg for the suggestions on this one.

  • Add new _state_refresh_output_pairings and _state_refresh_input_pairings to the Base class to store the pairings for refreshing the state of the device.
  • Move self._refresh_state_from_outputs() to the Base class as we have to run this on each initialization of a device.
  • Move the refresh_state function into the Base class and use the new _state_refresh_output_pairings to update the device state.
  • For each device class move the _state and _brightness (if it exists) initial setter to the __init__ of the class itself. This should ensure the devices state properties always have a value, with an initial value of None.
  • For the movment_detector class, it's possible it won't have brightness. Add a new test case where a movement detector doesn't have brightness but ensure the state of brightness is still set to a None value.

@kingsleyadam kingsleyadam merged commit dc7c4e6 into main Oct 18, 2024
8 checks passed
@kingsleyadam kingsleyadam deleted the u/kingsleyadam/refactorStateCode branch October 18, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant