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

[shelly]Enhancements and bug fixes #6764

Merged
merged 15 commits into from Feb 4, 2020
Merged

Conversation

markus7017
Copy link
Contributor

@markus7017 markus7017 commented Jan 5, 2020

This PR includes all changes from #6592 and replaces it. PR #6592 has been closed.

Signed-off-by: markus7017 markus7017@gmail.com

…hs new

PR

Signed-off-by: markus7017 <markus7017@gmail.com>
@TravisBuddy
Copy link

Travis tests have failed

Hey @markus7017,
please read the following log in order to understand the failure reason. There might also be some helpful tips along the way.
It will be awesome if you fix what is wrong and commit the changes.

2nd Build

Expand here
Single addon pull request: Building org.openhab.binding.shelly
[ERROR] Failed to execute goal org.commonjava.maven.plugins:directory-maven-plugin:0.3.1:directory-of (directories) on project org.openhab.binding.shelly: Cannot find directory for project: org.openhab.addons:org.openhab.addons.reactor -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Signed-off-by: markus7017 <markus7017@gmail.com>
@TravisBuddy
Copy link

Travis tests were successful

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

@markus7017
Copy link
Contributor Author

PR #6728 will solve most of the Travis warnings

Signed-off-by: markus7017 <markus7017@gmail.com>
@TravisBuddy
Copy link

Travis tests were successful

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

@Hilbrand Hilbrand added enhancement An enhancement or new feature for an existing add-on work in progress A PR that is not yet ready to be merged labels Jan 6, 2020
@markus7017 markus7017 changed the title [shelly][WIP] Version 2.5.1 enhancements and bug fixes [shelly]Version 2.5.1 enhancements and bug fixes Jan 6, 2020
@markus7017 markus7017 removed the work in progress A PR that is not yet ready to be merged label Jan 6, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
@TravisBuddy
Copy link

Travis tests were successful

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

@markus7017
Copy link
Contributor Author

@kaikreuzer Who will be the 2nd reviewer?

@markus7017 markus7017 added work in progress A PR that is not yet ready to be merged and removed work in progress A PR that is not yet ready to be merged labels Jan 11, 2020
@TravisBuddy
Copy link

Travis tests were successful

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

Signed-off-by: Markus Michels <markus7017@gmail.com>
@kaikreuzer
Copy link
Member

Well, just delete your local 2.5.x branch, rename shelly-snapshot-2.5.x to 2.5.x and do a force push. That should bring this PR to the code revision you have on your shelly-snapshot-2.5.x branch.

@kaikreuzer
Copy link
Member

Alternatively do a cherry pick of the new commits from shelly-snapshot-2.5.x to 2.5.x and do a normal push.

marked as advanced; Typos in properties corrected

Signed-off-by: Markus Michels <markus7017@gmail.com>
@markus7017 markus7017 changed the title [shelly]Version 2.5.1 enhancements and bug fixes [shelly]Enhancements and bug fixes Feb 2, 2020
@TravisBuddy
Copy link

Travis tests have failed

Hey @markus7017,
please read the following log in order to understand the failure reason. There might also be some helpful tips along the way.
It will be awesome if you fix what is wrong and commit the changes.

1st Build

Expand here
Single addon pull request: Building org.openhab.binding.shelly
[WARNING] Could not find file feature file features/karaf/openhab-addons/src/main/feature/feature.xml
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyHttpApi.java:[485,21051] Potential null pointer access: this expression has a '@Nullable' type
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/pom.xml [0:0]: Unused Export-Package instructions: [org.openhab.*] 
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/pom.xml [0:0]: Unused Import-Package instructions: [io.swagger.annotations.*, javax.annotation.security.*, org.eclipse.jdt.annotation.*, org.openhab.core.automation.annotation.*, org.openhab.*, com.google.common.*] 
[WARNING] Could not find file feature file features/karaf/openhab-addons/src/main/feature/feature.xml
[ERROR] Code Analysis Tool has found: 
 1 error(s)! 
 11 warning(s) 
 4 info(s)
[WARNING] org.openhab.binding.shelly.internal.ShellyHandlerFactory.java:[153]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.api.ShellyEventServlet.java:[124]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.coap.ShellyCoapHandler.java:[116]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.coap.ShellyCoapHandler.java:[220]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.coap.ShellyCoapHandler.java:[291]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.discovery.ShellyDiscoveryParticipant.java:[169]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.java:[132]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.java:[304]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.java:[388]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.java:[749]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyColorUtils.java:[152]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[ERROR] ESH-INF.thing.channels.xml:[263]
There were whitespace characters used for indentation. Please use tab characters instead
[ERROR] Failed to execute goal org.openhab.tools.sat:sat-plugin:0.9.0:report (sat-all) on project org.openhab.binding.shelly: 
[ERROR] Code Analysis Tool has found 1 error(s)! 
[ERROR] Please fix the errors and rerun the build.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :org.openhab.binding.shelly

### 2nd Build
Expand here
Single addon pull request: Building org.openhab.binding.shelly
[WARNING] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] Could not find file feature file features/karaf/openhab-addons/src/main/feature/feature.xml
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/home/travis/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.11/jaxb-impl-2.2.11.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoapJSonDTO.java:[119,3730] The constructor Integer(int) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyUtils.java:[103,3483] The method setScale(int, int) from the type BigDecimal is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/ShellyUtils.java:[103,3511] The field BigDecimal.ROUND_HALF_DOWN is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/api/ShellyHttpApi.java:[485,21051] Potential null pointer access: this expression has a '@Nullable' type
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyRelayHandler.java:[379,18527] The constructor Double(double) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyRelayHandler.java:[381,18726] The constructor Double(double) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyRelayHandler.java:[438,21575] The constructor Double(double) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyRelayHandler.java:[442,21916] The constructor Double(double) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyColorUtils.java:[182,5385] The constructor Double(double) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyLightHandler.java:[402,20647] The constructor Double(double) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyLightHandler.java:[501,26078] The constructor Double(double) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyLightHandler.java:[505,26219] The constructor Double(double) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java:[424,19770] The constructor Integer(int) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/handler/ShellyBaseHandler.java:[425,19878] The constructor Integer(int) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/src/main/java/org/openhab/binding/shelly/internal/coap/ShellyCoapHandler.java:[348,15899] The constructor Integer(int) is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/pom.xml [0:0]: Unused Export-Package instructions: [org.openhab.*] 
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.shelly/pom.xml [0:0]: Unused Import-Package instructions: [io.swagger.annotations.*, javax.annotation.security.*, org.eclipse.jdt.annotation.*, org.openhab.core.automation.annotation.*, org.openhab.*, com.google.common.*] 
[WARNING] Could not find file feature file features/karaf/openhab-addons/src/main/feature/feature.xml
[ERROR] Code Analysis Tool has found: 
 1 error(s)! 
 11 warning(s) 
 4 info(s)
[WARNING] org.openhab.binding.shelly.internal.ShellyHandlerFactory.java:[153]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.api.ShellyEventServlet.java:[124]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.coap.ShellyCoapHandler.java:[116]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.coap.ShellyCoapHandler.java:[220]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.coap.ShellyCoapHandler.java:[291]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.discovery.ShellyDiscoveryParticipant.java:[169]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.java:[132]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.java:[304]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.java:[388]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyBaseHandler.java:[749]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[WARNING] org.openhab.binding.shelly.internal.handler.ShellyColorUtils.java:[152]
Avoid catching NullPointerException; consider removing the cause of the NPE.
[ERROR] ESH-INF.thing.channels.xml:[263]
There were whitespace characters used for indentation. Please use tab characters instead
[ERROR] Failed to execute goal org.openhab.tools.sat:sat-plugin:0.9.0:report (sat-all) on project org.openhab.binding.shelly: 
[ERROR] Code Analysis Tool has found 1 error(s)! 
[ERROR] Please fix the errors and rerun the build.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :org.openhab.binding.shelly

Signed-off-by: Markus Michels <markus7017@gmail.com>
@TravisBuddy
Copy link

Travis tests were successful

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

@markus7017
Copy link
Contributor Author

@kaikreuzer Ok, should be ready to continue. Last change is setting status UNKNOWN on initialization and this shows up here and in my 2.5.x branch.

* @param status Shelly device status
* @return true: one or more inputs were updated
*/
@SuppressWarnings({ "null", "unused" })
Copy link
Member

Choose a reason for hiding this comment

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

Why do you have to suppress unused? Can't you simply remove unused variables?
Also, please try to avoid null suppressions and rather refactor the code to be fully null-safe.
Ok, if you address this in a future PR, no blocker wrt merging now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because Eclipse sometimes just report BS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

example: For this statement Eclipse reports a redundant null check

Strong thingName = properties.get(PROPERTY_SERVICE_NAME) != null ? properties.get(PROPERTY_SERVICE_NAME).toLowerCase() : thingType;
how to resolved those warnings?

Copy link
Member

Choose a reason for hiding this comment

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

Which is correct, because theoretically another thread could meanwhile remove the property before you call the get.
This should solve those issues:

String thingName = properties.get(PROPERTY_SERVICE_NAME);
thingName = thingName!=null ? thingName.toLowerCase() : thingType;

Copy link
Contributor Author

@markus7017 markus7017 Feb 4, 2020

Choose a reason for hiding this comment

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

nope, now it's "thingName!=null"

Copy link
Member

@kaikreuzer kaikreuzer Feb 5, 2020

Choose a reason for hiding this comment

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

Then probably this way:

String serviceName = properties.get(PROPERTY_SERVICE_NAME);
String thingName = serviceName!=null ? serviceName.toLowerCase() : thingType;

That's anyhow cleaner than my previous suggestion.

Signed-off-by: Markus Michels <markus7017@gmail.com>
Signed-off-by: Markus Michels <markus7017@gmail.com>
@markus7017
Copy link
Contributor Author

@kaikreuzer done

@TravisBuddy
Copy link

Travis tests were successful

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

@TravisBuddy
Copy link

Travis tests were successful

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

@kaikreuzer kaikreuzer merged commit e78b117 into openhab:2.5.x Feb 4, 2020
andibraeu pushed a commit to andibraeu/openhab-addons that referenced this pull request Feb 17, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
leluna pushed a commit to leluna/openhab2-addons that referenced this pull request Mar 21, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
Signed-off-by: leluna <hengrui.jiang@googlemail.com>
Hans-Reiner pushed a commit to Hans-Reiner/openhab2-addons that referenced this pull request Apr 11, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
Signed-off-by: Hans-Reiner Hoffmann <hans-reiner.hoffmann@gmx.de>
J-N-K pushed a commit to J-N-K/openhab-addons that referenced this pull request Jul 14, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
Signed-off-by: markus7017 <markus7017@gmail.com>
Signed-off-by: Daan Meijer <daan@studioseptember.nl>
@markus7017 markus7017 deleted the 2.5.x branch May 26, 2022 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants