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

[netatmo] Null annotations Part 3 of 3 #8057

Merged
merged 4 commits into from
Jul 9, 2020

Conversation

lolodomo
Copy link
Contributor

@lolodomo lolodomo commented Jul 3, 2020

Fix #7913

Signed-off-by: Laurent Garnier lg.hc@free.fr

Fix openhab#7913

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo lolodomo added the work in progress A PR that is not yet ready to be merged label Jul 3, 2020
@lolodomo
Copy link
Contributor Author

lolodomo commented Jul 3, 2020

I tagged this PR with "Work in progress" due to the number of changes and the usage of Optional I am not expert in. This requires a good testing before a merge.
By the way, reviews are already welcome.

@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jul 3, 2020

After a quick test, everything looks good. I am confident in my changes. But I will do more tests to be very sure.

@lolodomo lolodomo removed the work in progress A PR that is not yet ready to be merged label Jul 4, 2020
@lolodomo
Copy link
Contributor Author

lolodomo commented Jul 4, 2020

Tag "Work in progress" removed, I found only little bug that I immediately fixed and which was already present before this PR, the video status from the last event must be computed only if the event contains a video.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Copy link
Contributor

@clinique clinique left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Fix openhab#8083

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jul 7, 2020

@clinique : please review my last change, I implemented the configuration option for the background discovery. Works perfectly as expected.

- Some features like the video surveillance are accessed via the local network, so it may be helpful to set a static IP address
for the camera within your local network.

- The URL of the live snapshot is a fixed URL so the value of the channel cameraLivePictureUrl / welcomeCameraLivePictureUrl will never be updated once first set by the binding. So to get a refreshed picture, you need to use the refresh parameter in your sitemap image element.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put each sentence on its own line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done to avoid a warning in the checks (blank line required after a list item, something like that).
Either 2 lines to help maintenance but a warning, or one line and no warning.
Let me know what you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leave as is then. I've prefer to avoid the warning even if it might be misguided.

Comment on lines 241 to 255
NetatmoBridgeHandler handler = getBridgeHandler();
if (handler == null) {
if (!getBridgeHandler().isPresent() || device == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caching the bridge handler result in a local variable is much safer from a concurrency standpoint.

if (bridgeHandler != null && avatarURL == null && module != null) {
NAWelcomeFace face = module.getFace();
private @Nullable String getAvatarURL() {
if (getBridgeHandler().isPresent() && avatarURL == null && getModule().isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBridgeHandler() and getModule() should be cached to local variables

Comment on lines 106 to 107
if (getBridgeHandler().isPresent() && getLastEvent().isPresent()
&& getLastEvent().get().getSnapshot() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBridgeHandler() and getLastEvent() should be cached to local variables

Comment on lines 90 to 91
return (getLastEvent().isPresent() && getLastEvent().get().getMessage() != null)
? toStringType(getLastEvent().get().getMessage().replace("<b>", "").replace("</b>", ""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you get the idea, fix wherever else it might apply.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@TravisBuddy
Copy link

Travis tests were successful

Hey @lolodomo,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@lolodomo
Copy link
Contributor Author

lolodomo commented Jul 8, 2020

Review comments taken into account.
Only remains the one about README. Let me know what of the 2 options you prefer.

@cpmeister cpmeister merged commit 51dacbd into openhab:2.5.x Jul 9, 2020
@cpmeister cpmeister added this to the 2.5.7 milestone Jul 9, 2020
@lolodomo lolodomo deleted the netatmo_null3 branch July 9, 2020 22:35
@lolodomo
Copy link
Contributor Author

lolodomo commented Jul 9, 2020

Thank you for the quick review and merge.

knikhilwiz pushed a commit to knikhilwiz/openhab2-addons that referenced this pull request Jul 12, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Jul 26, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: CSchlipp <christian@schlipp.de>
MPH80 pushed a commit to MPH80/openhab-addons that referenced this pull request Aug 3, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: MPH80 <michael@hazelden.me>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Daan Meijer <daan@studioseptember.nl>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
* [netatmo] Null annotations Part 3 of 3
Fix openhab#7913
* Video status only set when there is a video in the event
* Add a setting to enable/disable the background discovery
Fix openhab#8083
* Cache Optional result in local variable

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
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.

[netatmo] Null annotations
4 participants