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

[ecotouch] add Waterkotte EcoTouch binding (ported from OH1) #10010

Merged
merged 15 commits into from
Apr 27, 2021

Conversation

sibbi77
Copy link
Contributor

@sibbi77 sibbi77 commented Jan 31, 2021

@sibbi77 sibbi77 requested a review from a team as a code owner January 31, 2021 17:36
@fwolter fwolter added new binding If someone has started to work on a binding. For a new binding PR. oh1 migration Relates to migrating an openHAB 1 addon to openHAB 2 labels Jan 31, 2021

| Channel ID | Type | Read-Only | Description |
|---------------------|--------------------|-----------|-------------|
| temperature_outside | Number:Temperature | yes | The current outside temperature |
Copy link
Contributor

@Skinah Skinah Feb 21, 2021

Choose a reason for hiding this comment

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

Suggested change
| temperature_outside | Number:Temperature | yes | The current outside temperature |
| temperatureOutside | Number:Temperature | yes | The current outside temperature |

Please change all channels to use lowerCamelCase

see

https://www.openhab.org/docs/developer/guidelines.html#java-coding-style

EDIT: I see this is a OH1 binding upgrade, does that mean the channels have been kept the same? ie will it be a breaking change if the channels are changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First, thanks for reviewing! Yes this is a OH1 binding upgrade and all channels have been kept compatible to OH1 to minimize the migration work for the users. What should I do now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Leave it as is until someone with more knowledge steps in to make the call on what to do. I’ll help with what I can.

Copy link
Member

Choose a reason for hiding this comment

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

As far as I know underscores are still allowed in OH3.

<description></description>
<state readOnly="true" pattern="%.1f %unit%"/>
</channel-type>
<channel-type id="power_compressor">
Copy link
Contributor

@Skinah Skinah Feb 21, 2021

Choose a reason for hiding this comment

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

Suggested change
<channel-type id="power_compressor">
<channel-type id="power_compressor" advanced="true">

Can you mark any channels which wont be used often as advanced? This way people can use the 'select all' button and only get the most useful channels without needing to go through a big list, or worse selecting them all and have a large amount of channels then using persistence and using system resources. To see the advanced channels you just tick 'show advanced' when linking channels.

EDIT just saw you have marked some already :) cool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm unsure about the channels which should go into advanced. I tried to mark some as advanced, but that depends on what the users want to do. I'll try to put many more channels into advanced and only keep a dozen or so.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good as only you and people that use the binding can make that call. I usually ask two questions to myself when deciding

  1. Can it be useful in a rule?
  2. What are the channels that most users will want to add?

if it’s just a nice to have channel but not that useful to actually trigger an automation I tend to want it hidden under advanced. You can always hit the add all button and then tick show advanced and add a few more.

Signed-off-by: Sebastian Held <[email protected]>
@Skinah
Copy link
Contributor

Skinah commented Mar 2, 2021

Please compile this and look at the lines that appear when compiling and solve any warnings. Also in the target folder after compiling is done is a code-analasis folder, open the report file and solve all the issues that it has listed. Once you have done that then feel free to re-request a review. A lot of the classes are not marked as nonNullByDefault currently.

@sibbi77
Copy link
Contributor Author

sibbi77 commented Mar 2, 2021

Thanks! I'll read about that "nonNullByDefault" thing.

sibbi77 added 3 commits March 7, 2021 19:50
Signed-off-by: Sebastian Held <[email protected]>
Signed-off-by: Sebastian Held <[email protected]>
Signed-off-by: Sebastian Held <[email protected]>
Signed-off-by: Sebastian Held <[email protected]>
@sibbi77
Copy link
Contributor Author

sibbi77 commented Mar 7, 2021

I've a bunch of these "Potential null pointer access: this expression has a '@nullable' type" warnings left and cannot get rid of them, but I tried to address all other warnings and remarks.
For the final merge I would rebase and squash everything into one commit.

Signed-off-by: Sebastian Held <[email protected]>
@Skinah
Copy link
Contributor

Skinah commented Mar 9, 2021

I've a bunch of these "Potential null pointer access: this expression has a '@nullable' type" warnings left and cannot get rid of them, but I tried to address all other warnings and remarks.
For the final merge I would rebase and squash everything into one commit.

Can you give the warning, the file and line number of where the warning is given? Happy to look at the latest code changes and give a suggestion on how to solve it so you don't bang your head on the wall.

Comment on lines 200 to 204
if (cookies != null) {
for (String cookie : cookies) {
connection.addRequestProperty("Cookie", cookie.split(";", 2)[0]);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here it get the following warning:
[WARNING] org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java:[201,42] Potential null pointer access: this expression has a '@Nullable' type
cookies is Nullable, but I check for null before use. I'm lost here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (cookies != null) {
for (String cookie : cookies) {
connection.addRequestProperty("Cookie", cookie.split(";", 2)[0]);
}
}
List<String> localCookies=cookies;
if (localCookies != null) {
for (String cookie : localCookies) {
connection.addRequestProperty("Cookie", cookie.split(";", 2)[0]);
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does that mean, that the same class instance is executed by two different tasks at the same time? It is clear, that I can have more than one instance, if I have more than one heat pump. I thought serialization is performed by the framework.
If that is not true, I'll have to check all places for data races and have mutexes all around... That seems unreasonable and unlikely to me...
I would guess that the static checker is just not aware of the framework's serialization. Isn't there a magic attribute to provide that info?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not the best person to explain things to you as I am new to Java. Does the code suggested solve the compiler's warning for null? Your concerns about data races and serialization are not related to this, it is about potentially another thread making the handle to the object null if my understanding is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The root of the problem is: the compiler thinks cookies can turn into null between line 200 and 201. That's only possible if multithreading is allowed AND the very same instance of the object is executed in two different threads. Your workaround would prevent the compiler from flagging the line 201 as a problem, because you created a local variable on the stack, which is bound to the thread. This will "fix" this particular problem (with an ugly workaround) but if the compiler is right in flagging it, then I have to check the complete code for data races.
Is there any documentation, how openhab implements multithreading? Again, I think the compiler warning is a false positive, because otherwise it would make binding implementation unnecessary complicated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it is a trade off, so where it is possible variables should be nonNullable and initialized at creation. Whilst it may be that you know your code 100% inside out, if someone else comes along to maintain it they may not know it as well. My knowledge is not very good, if you want to discuss how openHAB implements multithreading you should ask on the forum in the dev section. The suggestion I made to you, is what others have given me when I needed help.

sibbi77 added 2 commits March 9, 2021 08:07
Signed-off-by: Sebastian Held <[email protected]>
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! I reviewed your code and here is my feedback.

Great that you already fixed all of the compiler warnings about null values with @Skinah's help!

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

This file is generated automatically and should therefore not be part of your code.

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Comment on lines 18 to 20
## Binding Configuration

No Binding configuration required.
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed, then.

Comment on lines 26 to 28
```
Thing ecotouch:geo:9a0ec0bbbd "Waterkotte Heatpump" @ "basement" [ ip="192.168.1.100", username="admin", password="wtkadmin", refresh=120 ]
```
Copy link
Member

Choose a reason for hiding this comment

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

You could move this to the end of the file into the Examples section to be consistent with other bindings.

There should also be examples for the .items file. See other bindings for reference.


## Channels

All available channels can be seen inside PaperUI. Here is a small extract:
Copy link
Member

Choose a reason for hiding this comment

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

Can you express this a bit more abstract as PaperUI was replaced in OH3?

Actually, the readme should state all Channels as many users use textual configuration.

thing-type.ecotouch.air.description = Waterkotte EcoTouch Air Luftw�rmepumpe

# thing type config description (geo)
thing-type.config.ecotouch.geo.ip.label = IP Adresse / Hostname der W�rmepumpe
Copy link
Member

Choose a reason for hiding this comment

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

Labels are expected to be as short as possible. Guideline is 2-3 words with max 20-25 chars. See https://www.openhab.org/docs/developer/bindings/thing-xml.html#formatting-labels-and-descriptions

Please check all.

Suggested change
thing-type.config.ecotouch.geo.ip.label = IP Adresse / Hostname der W�rmepumpe
thing-type.config.ecotouch.geo.ip.label = IP Adresse / Hostname

channel-type.ecotouch.temperature_solar_flow.description = Solarkreis Vorlauftemperatur
channel-type.ecotouch.position_expansion_valve.label = Ventil�ffnung el. Expansionsventil
channel-type.ecotouch.position_expansion_valve.description = Ventil�ffnung elektrisches Expansionsventil
channel-type.ecotouch.power_compressor.label = elektrische Antriebsleitung Verdichter
Copy link
Member

Choose a reason for hiding this comment

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

Words in labels should be capitalized (except prepositions and so on). See https://www.openhab.org/docs/developer/bindings/thing-xml.html#formatting-labels-and-descriptions

Please check all.

Copy link
Member

Choose a reason for hiding this comment

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

Can you comment on that?

channel-type.ecotouch.ecovent_moisture_value.description = EcoVent Luftfeuchtigkeit
channel-type.ecotouch.ecovent_output_y1.label = EcoVent L�fterdrehzahl
channel-type.ecotouch.ecovent_output_y1.description = EcoVent L�fterdrehzahl

Copy link
Member

Choose a reason for hiding this comment

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

Please remove one empty line.

<channel-type id="temperature_source_in">
<item-type>Number:Temperature</item-type>
<label>Temperature Source Input</label>
<description></description>
Copy link
Member

Choose a reason for hiding this comment

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

You could drop the tag if it's empty.

<description></description>
<state min="0" max="5" step="1" readOnly="false"/>
</channel-type>

Copy link
Member

Choose a reason for hiding this comment

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

Please remove both empty lines.

sibbi77 added 3 commits April 11, 2021 20:04
Signed-off-by: Sebastian Held <[email protected]>
Signed-off-by: Sebastian Held <[email protected]>
Signed-off-by: Sebastian Held <[email protected]>
@sibbi77
Copy link
Contributor Author

sibbi77 commented Apr 11, 2021

tried to fix all mentioned problems

channel-type.ecotouch.temperature_solar_flow.description = Solarkreis Vorlauftemperatur
channel-type.ecotouch.position_expansion_valve.label = Ventil�ffnung el. Expansionsventil
channel-type.ecotouch.position_expansion_valve.description = Ventil�ffnung elektrisches Expansionsventil
channel-type.ecotouch.power_compressor.label = elektrische Antriebsleitung Verdichter
Copy link
Member

Choose a reason for hiding this comment

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

Can you comment on that?

@sibbi77
Copy link
Contributor Author

sibbi77 commented Apr 19, 2021

In file ecotouch_de.properties I've reduced the length of the *.label entries and added the longer description to the *.description tags.

@fwolter
Copy link
Member

fwolter commented Apr 19, 2021

My orignal comment was:

Words in labels should be capitalized (except prepositions and so on). See https://www.openhab.org/docs/developer/bindings/thing-xml.html#formatting-labels-and-descriptions

@sibbi77
Copy link
Contributor Author

sibbi77 commented Apr 19, 2021

That may work for English, but other bindings also don't follow these rules in their German translation. The referenced document also states to have at most 25 characters in a label, that's what I did.

@fwolter
Copy link
Member

fwolter commented Apr 19, 2021

You might be right, that doesn't work in German. But at least the first word in the label should be upper case, otherwise it looks odd, even in German.

@sibbi77
Copy link
Contributor Author

sibbi77 commented Apr 19, 2021

You're right, I'll fix that. If you think, new Bindings should follow the capitalization rule even in non English languages and ported bindings are not yet updated, I can even make that change, too. Your decision.

@fwolter
Copy link
Member

fwolter commented Apr 19, 2021

I think it looks odd if every word is capitalized in German.

Signed-off-by: Sebastian Held <[email protected]>
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

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

Thanks!

@fwolter fwolter merged commit 7d13795 into openhab:main Apr 27, 2021
@fwolter fwolter added this to the 3.1 milestone Apr 27, 2021
themillhousegroup pushed a commit to themillhousegroup/openhab2-addons that referenced this pull request May 10, 2021
computergeek1507 pushed a commit to computergeek1507/openhab-addons that referenced this pull request Jul 13, 2021
frederictobiasc pushed a commit to frederictobiasc/openhab-addons that referenced this pull request Oct 26, 2021
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
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. oh1 migration Relates to migrating an openHAB 1 addon to openHAB 2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants