-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[hdpowerview] Add support for calibrating a shade #12002
Conversation
65dc4bf
to
668292a
Compare
@jlaur in one of my own recent PR's I addressed and solved this issue here, in the |
Thanks for being vigilant! You definitely solved it. You solved it by using the calculated new position(s) to update the channels immediately. This works fine, and probably it will always work fine, unless we have a bug trying to set invalid positions which would then be rejected and positions would actually be unchanged. Now it's slightly refactored to use positions from the response for being (also) immediately updated. This should not change anything, as the returned values should be the same as the new positions requested. This is also what I have seen in my tests - as documented in PR description. The reason for this change is that I noticed multiple REST services actually returning an updated Shade object, and we didn't use this "free information" at all. This way we can now update positions the same unified way after each REST call returning a Shade object with position information. |
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.
@jlaur you have made some quite extensive changes which are difficult to track via the GitHub browser; so instead I will have to download and build the jar in my IDE and test it on my own installation; however here a a few trivial comments concerning adding new @return declarations to the java docs.
...dpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewWebTargets.java
Show resolved
Hide resolved
...dpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewWebTargets.java
Show resolved
Hide resolved
...dpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewWebTargets.java
Show resolved
Hide resolved
@jlaur now I have studied your code in my Eclipse IDE (where it is much easier to understand your changes), and I can confirm that the changes look good to me (except the trivia noted above). The new JAR is now running on my live system, and all the properties and channels are updating correctly; also I tried a few commands which worked too. However if you want me to try any specific tests, please let me know. |
Yes, first commit is kind of big because I didn't want to introduce boilerplate code in order to remove it again in next commit. So the refactoring already started in this single commit. However, after that I tried to provide explicit commits for each distinct change. It might be easier to read commit by commit?
I will have a look and try to fix them. Thanks for the help! |
My prior post crossed with yours. |
Thanks, Andrew! Besides updating the examples in the README, I plan to improve handling of dispose while there are still ongoing requests. It works correctly now, but an error is logged which could be confusing. Besides that I don't plan to do anything major, so you should be able to catch up just reading the next few commits. Hopefully I will get it done tonight, and make the pull request ready for review after that. :-) |
@andrewfg - and a little teaser: Of course I got some new ideas when working with this and testing it. |
^ |
I'll need to dig a little deeper to find a good solution for this. To be honest, I'm relatively new to Java and I have a hate/love relationship with all this null annotation stuff. Having |
Perhaps I will make a proposal tomorrow.. |
Attached are your de-serializer classes with @null annotations added. HDPowerView Null Annotations.zip Using these annotations, does in fact reveal some potential NPE failure points in your code in EDIT: use exceptions rather than return with
|
Thanks @andrewfg, I'll have a look and provide a separate PR for resolving these existing (although recently introduced) issues tonight. I'll also test what how gson will react when having a |
Let's continue in #12027. It will not be part of this PR as it's unrelated, and also I would like to extend the scope to fix not only the annotations, but also error handling and contract verification in general for all methods. |
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.
LGTM
@openhab/add-ons-maintainers - beowulfe is listed as codeowner for the hdpowerview binding, but the user doesn't exist on GitHub anymore. What's the procedure - just remove? Secondly, @andrewfg, would you like to be added as you have been quite actively contributing to this binding? I have added myself as I'm quite into the binding at this point and feel responsibility for it. |
@openhab/add-ons-maintainers - I just did a quick check, and he seems to be the only one missing as GitHub user - but listed as owner for two bindings:
Result:
|
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
3ad3e75
to
585a706
Compare
...dpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewWebTargets.java
Show resolved
Hide resolved
...dpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewWebTargets.java
Show resolved
Hide resolved
...dpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewWebTargets.java
Show resolved
Hide resolved
bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties
Outdated
Show resolved
Hide resolved
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
CI build failed with:
|
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.
LGTM
@wborn for help with the failing CI build. |
I see that a new Jenkins build was scheduled, but previous one succeeded. Also CI build succeeded before last two commits. So IMHO it should be safe. |
* Add support for calibrating a shade. Fixes openhab#11767 * Fix startup problems by decoupling capabilities cache from updateSoftProperties. * Minor refactoring of capabilities and shade id handling. * Dispose faster/safer by killing any remaining tasks. * Set shade thing status to UNKNOWN until we receive any data for shade. * Fix position update glitch after setting position. * Remove unneeded catch after shade id refactoring. * Document return values in Javadoc. * Avoid logging InterruptedException during dispose. * Add calibration example item. * Reduce nesting. * Add myself as reviewer for binding. * Add Andrew Fiddian-Green as reviewer for binding. * Handle JsonParseException. * Fix alphabetic order. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Add support for calibrating a shade. Fixes openhab#11767 * Fix startup problems by decoupling capabilities cache from updateSoftProperties. * Minor refactoring of capabilities and shade id handling. * Dispose faster/safer by killing any remaining tasks. * Set shade thing status to UNKNOWN until we receive any data for shade. * Fix position update glitch after setting position. * Remove unneeded catch after shade id refactoring. * Document return values in Javadoc. * Avoid logging InterruptedException during dispose. * Add calibration example item. * Reduce nesting. * Add myself as reviewer for binding. * Add Andrew Fiddian-Green as reviewer for binding. * Handle JsonParseException. * Fix alphabetic order. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Add support for calibrating a shade. Fixes openhab#11767 * Fix startup problems by decoupling capabilities cache from updateSoftProperties. * Minor refactoring of capabilities and shade id handling. * Dispose faster/safer by killing any remaining tasks. * Set shade thing status to UNKNOWN until we receive any data for shade. * Fix position update glitch after setting position. * Remove unneeded catch after shade id refactoring. * Document return values in Javadoc. * Avoid logging InterruptedException during dispose. * Add calibration example item. * Reduce nesting. * Add myself as reviewer for binding. * Add Andrew Fiddian-Green as reviewer for binding. * Handle JsonParseException. * Fix alphabetic order. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Nick Waterton <n.waterton@outlook.com>
* Add support for calibrating a shade. Fixes openhab#11767 * Fix startup problems by decoupling capabilities cache from updateSoftProperties. * Minor refactoring of capabilities and shade id handling. * Dispose faster/safer by killing any remaining tasks. * Set shade thing status to UNKNOWN until we receive any data for shade. * Fix position update glitch after setting position. * Remove unneeded catch after shade id refactoring. * Document return values in Javadoc. * Avoid logging InterruptedException during dispose. * Add calibration example item. * Reduce nesting. * Add myself as reviewer for binding. * Add Andrew Fiddian-Green as reviewer for binding. * Handle JsonParseException. * Fix alphabetic order. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Add support for calibrating a shade. Fixes openhab#11767 * Fix startup problems by decoupling capabilities cache from updateSoftProperties. * Minor refactoring of capabilities and shade id handling. * Dispose faster/safer by killing any remaining tasks. * Set shade thing status to UNKNOWN until we receive any data for shade. * Fix position update glitch after setting position. * Remove unneeded catch after shade id refactoring. * Document return values in Javadoc. * Avoid logging InterruptedException during dispose. * Add calibration example item. * Reduce nesting. * Add myself as reviewer for binding. * Add Andrew Fiddian-Green as reviewer for binding. * Handle JsonParseException. * Fix alphabetic order. Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
Fixes #11767
Signed-off-by: Jacob Laursen jacob-github@vindvejr.dk
This pull request adds support for calibrating a shade.
Some refactoring had to be done in order to avoid boilerplate code. While doing this I found some additional issues that have been addressed:
Tests
Position update after UP/DOWN command:
STOP command after UP/DOWN: