Redesign attribute callbacks #237
Merged
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.
Summary
AttrR.updateandAttrR._on_update_callbacks->AttrR._update_callbackAttrR.set()->AttrR.update()AttrW.process()->AttrW.put(sync_setpoint: bool = False)sync_setpointAttrR._on_set_callbacks->AttrR._on_update_callbacksAttrRorAttrRWwithout an IO, this is left unset soupdatedoes nothing.AttrW._process_callbacks->AttrW._on_put_callback. This is called when a new value is put.AttrRWwithout an IO, the on_put_callback falls back toAttrRW.setso that internal driver parameters work as expected. This replaces the oldSimpleHandlerin a much simple way.AttrW._write_display_callbacks->AttrW._sync_setpoint_callbacksput(sync_setpoint=True)to update the setpoint of the attribute being put, e.g. when a driver is manually putting to attributes based on user input such as a fan outAttrRW.updatethe first time to initialise the setpoints so that they aren't blankOutstanding Questions
Should transports ever call put with sync_setpoint=True? This will update the setpoints of all transports. I think it is useful to not do this so that it is clear when looking at the UI for a transport that the put was from somewhere else.Should fan out attributes call put with sync_setpoint=True? I think yes because it is effectively a user input and the UI should reflect that.Do the callback names make sense? Shouldon_putjust beput, or something else?