-
-
Notifications
You must be signed in to change notification settings - Fork 630
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
Update Characteristic value when setProps called #902
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Great you caught that one 🚀
My comments are mainly to direct you to reuse some of the already existent logic covering cases like that. Additionally, solely checking for the minValue
and maxValue
properties might not be enough to fully address the issue.
@Supereg I will have a look at this soon, thanks for comments! |
Can you have a look @Supereg? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey sorry for the delay, I wasn't sure if a follow-up review was already requested, and then kinda forgot about this 😕
Thanks for incorporating my feedback. I had some concerns on how setProps
is used internally, as it is partly called in yet uninitialized state. Happy to year your points in that discussion :)
In regard to the tests, quickly scanned over it. Seems like, due to the added validateUserInput
call (probably also because it is called through the constructor) the expected test results do not align anymore. Specifically the expectations on how many calls were made to characteristicWarning
are now a bit off. Would be great if you could investigate those cases, and adjust the values if it makes sense.
Co-authored-by: Andi <mail@anderl-bauer.de>
# Conflicts: # src/lib/Characteristic.ts
Pull Request Test Coverage Report for Build 3247995066
💛 - Coveralls |
@Supereg can I ask for hints or comments? |
@Supereg bump |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the contribution 🚀
Did you guys check this change for Programmable Switch Event and other I now get the “characteristic was supplied an illegal value” on restart, when having changed the supported button actions, and the last button action before the restart is no longer supported. I thought about changing the characteristic value when changing the properties, but don’t know how to do that without generating a ghost button action. |
My intention was to add some test cases in a follow up PR. Thanks for the input 👍
You are justing calling |
Yes. Based on the config.json settings, a button might support Double Press and/or Long Press in addition to Single Press. E.g. the On restart, Homebridge restores the Stateless Programmable Switch from cache, including the last button action as the value of Programmable Switch Event. My plugin sets the characteristic properties based on the changed config.json settings. When the last button action from before the change is now no longer supported, Homebridge complains that the (restored) value is out of bound. I think for |
Co-authored-by: Andi <mail@anderl-bauer.de>
Update Characteristic value when setProps called
♻️ Current situation
This PR is mainly about number values.
Currently, Characteristic default value is based upon minValue.
Once setProps is called and minValue is changed, then also value should be changed accordingly.
💡 Proposed solution
Problem that is solved
This PR will clamp Characteristic value, so there is no situation when allowed value range is 10-20 and value is 0.
Implications
updateValue is called, which means some actions might be triggered
Testing
Tested locally before and after with success.
Reviewer Nudging
Right at the top :)