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

[sonnen] Initial contribution of new binding for solar battery #11915

Merged
merged 27 commits into from
Jan 9, 2022

Conversation

chingon007
Copy link
Contributor

Initial contribution for a new binding which communicates with a solar battery from sonnen. It is a simple read only binding which just reads the values of the solar battery.

I mentioned my initiative in the forum here: https://community.openhab.org/t/new-binding-sonnen-battery/129178

Regards
Chingon

@chingon007 chingon007 requested a review from a team as a code owner December 31, 2021 14:58
@lolodomo
Copy link
Contributor

You broke the BOM POM (you forgot a tag). That's the reason of the failing build.

Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: chingon007 <tron81@gmx.de>
@chingon007
Copy link
Contributor Author

Thanks, just a small copy & paste error. Now it should work.

@chingon007
Copy link
Contributor Author

@lolodomo Ready to review. Clean and building :-)

@lolodomo
Copy link
Contributor

@lolodomo Ready to review. Clean and building :-)

Bravo ;)

I will review your proposal certainly next year now ;)

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/new-binding-sonnen-battery/129178/2

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

Review part 1 of 2

@cweitkamp cweitkamp added the new binding If someone has started to work on a binding. For a new binding PR. label Jan 1, 2022
Signed-off-by: chingon007 <tron81@gmx.de>
…d 2 for Battery Feeding and Dispense

Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: chingon007 <tron81@gmx.de>
@lolodomo
Copy link
Contributor

lolodomo commented Jan 8, 2022

When I try to compile your branch, I have errors with wrong copyrights. It looks like the compiler is using the check with 2021 and not 2022. How do you solve that to get a full compilation (mvn clean install) ?

Edit: works of course with mvn clean install -DskipChecks

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

lolodomo commented Jan 8, 2022

I just open a PR to your repo to provide the default translations properties file.
It is the result of the command mvn i18n:generate-default-translations
Of course, it will be required to update it if you change your XML thing file.

@chingon007
Copy link
Contributor Author

I had the same problem. I was wondering how to update the local mvn install. However I switched back the copyright 2021 in order to compile and then changed it back to 2022

chingon007 and others added 2 commits January 8, 2022 13:23
Provide the default translations properties
Compilation is fine

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

lolodomo commented Jan 8, 2022

I created another PR that resolves the @Nullable config parameter. I see no compilation or SAT errors.

Note that you should move all your classes in internal packages. I discovered that some of them are not. I let you change that.

chingon007 and others added 2 commits January 8, 2022 13:50
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@lolodomo
Copy link
Contributor

lolodomo commented Jan 8, 2022

I created a last PR with an improved class SonnenJSONCommunication resolving our discussions about nullable batteryData and some of my other review comments for this class. It is ok to keep batteryData nullable but it has to be set to null when appropriate.

@lolodomo
Copy link
Contributor

lolodomo commented Jan 8, 2022

I submitted to your repo a new PR to finalize the thing definition and the documentation.

Improved thing types and documentation
@chingon007
Copy link
Contributor Author

I submitted to your repo a new PR to finalize the thing definition and the documentation.

Thats great. Very much appreciated.

@chingon007
Copy link
Contributor Author

And to have something clean, your class Helper should be replaced by an exception class. I will create another PR when you have made progress on the other points.

I will work on that in the next days, as soon as I have time again.

Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: chingon007 <tron81@gmx.de>
@lolodomo
Copy link
Contributor

lolodomo commented Jan 8, 2022

I submitted a PR with my last enhancements regarding java code.

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

lolodomo commented Jan 8, 2022

@chingon007 : you implemented your thing handler in such a way the refresh job is started only when at least one channel is linked. This is correct in theory but adds a lot of complexity to your thing handler, while in practice you have no user that will create a thing without linking at least one channel. In fact, this will only happen during a short time when setting up the binding.
In my opinion, it would be ok to start your refresh job without checking if one channel is linked. Like that, your handler will be very simple, no need to override channelLinked, channelUnlinked and to have your map linkedChannels. You just have to handle the REFRESH command.

I let you decide, I think the code is OK but you have to test it seriously in case you want to keep your optimization..

Enhancement of the thing handler
@chingon007
Copy link
Contributor Author

I submitted a PR with my last enhancements regarding java code.

Thanks a lot. I appreciate it. With this change I will make an enhancement to my other older binding in order to improve the code there as well.

@chingon007
Copy link
Contributor Author

@chingon007 : you implemented your thing handler in such a way the refresh job is started only when at least one channel is linked. This is correct in theory but adds a lot of complexity to your thing handler, while in practice you have no user that will create a thing without linking at least one channel. In fact, this will only happen during a short time when setting up the binding. In my opinion, it would be ok to start your refresh job without checking if one channel is linked. Like that, your handler will be very simple, no need to override channelLinked, channelUnlinked and to have your map linkedChannels. You just have to handle the REFRESH command.

I let you decide, I think the code is OK but you have to test it seriously in case you want to keep your optimization..

Thanks for the hint. I took that implementation from a other binding when I developed my first binding over a year ago. I understand what you mean. For the moment I will keep it and consider it to change it in the future.

@lolodomo
Copy link
Contributor

lolodomo commented Jan 9, 2022

Thanks a lot. I appreciate it. With this change I will make an enhancement to my other older binding in order to improve the code there as well.

Note that the way I changed with your method now returning the error message or an empty string is probably not the best implementation. Using an exception would have been probably a better implementation.

Thanks for the hint. I took that implementation from a other binding when I developed my first binding over a year ago. I understand what you mean. For the moment I will keep it and consider it to change it in the future.

Ok

I will have a final look today but everything is certainly ok now. Do you need time to test again that everything is still working or can I merge if I have no other comments ?

Signed-off-by: chingon007 <tron81@gmx.de>
@chingon007
Copy link
Contributor Author

I made just now the final testing. Found some typos. After this recent commit is passed it can be merged. Thanks a lot for your contribution.

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

lolodomo commented Jan 9, 2022

I just submitted a last PR adding 2 missing channels in README and with the last run of the i18n tool.

2 channels added in README + last run of i18n tool
@chingon007
Copy link
Contributor Author

I just submitted a last PR adding 2 missing channels in README and with the last run of the i18n tool.

Thanks. You are right. I forgot to add them.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

Code LGTM

@lolodomo lolodomo merged commit 46ba275 into openhab:main Jan 9, 2022
@lolodomo lolodomo added this to the 3.3 milestone Jan 9, 2022
@lolodomo
Copy link
Contributor

lolodomo commented Jan 9, 2022

@chingon007 : thank your for contributing this new binding.

Now, you could add your binding's logo to the openHAB website. See https://www.openhab.org/docs/developer/bindings/#add-your-binding-s-logo-to-the-openhab-website

mischmidt83 pushed a commit to mischmidt83/openhab-addons that referenced this pull request Jan 9, 2022
…ab#11915)

* Initial contribution of sonnen binding

Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: Michael Schmidt <mi.schmidt.83@gmail.com>
moesterheld pushed a commit to moesterheld/openhab-addons that referenced this pull request Jan 18, 2022
…ab#11915)

* Initial contribution of sonnen binding

Signed-off-by: chingon007 <tron81@gmx.de>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Jan 28, 2022
…ab#11915)

* Initial contribution of sonnen binding

Signed-off-by: chingon007 <tron81@gmx.de>
NickWaterton pushed a commit to NickWaterton/openhab-addons that referenced this pull request Apr 27, 2022
…ab#11915)

* Initial contribution of sonnen binding

Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: Nick Waterton <n.waterton@outlook.com>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
…ab#11915)

* Initial contribution of sonnen binding

Signed-off-by: chingon007 <tron81@gmx.de>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
…ab#11915)

* Initial contribution of sonnen binding

Signed-off-by: chingon007 <tron81@gmx.de>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants