-
-
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
[ecotouch] add Waterkotte EcoTouch binding (ported from OH1) #10010
Conversation
Signed-off-by: Sebastian Held <[email protected]>
|
||
| Channel ID | Type | Read-Only | Description | | ||
|---------------------|--------------------|-----------|-------------| | ||
| temperature_outside | Number:Temperature | yes | The current outside temperature | |
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.
| 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?
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.
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?
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.
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.
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.
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"> |
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.
<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.
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.
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.
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.
Sounds good as only you and people that use the binding can make that call. I usually ask two questions to myself when deciding
- Can it be useful in a rule?
- 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.
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
Signed-off-by: Sebastian Held <[email protected]>
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
...g.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchBindingConstants.java
Outdated
Show resolved
Hide resolved
...ding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConfiguration.java
Outdated
Show resolved
Hide resolved
....binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java
Outdated
Show resolved
Hide resolved
....binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java
Outdated
Show resolved
Hide resolved
....binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java
Outdated
Show resolved
Hide resolved
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. |
Thanks! I'll read about that "nonNullByDefault" thing. |
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]>
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. |
Signed-off-by: Sebastian Held <[email protected]>
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. |
if (cookies != null) { | ||
for (String cookie : cookies) { | ||
connection.addRequestProperty("Cookie", cookie.split(";", 2)[0]); | ||
} | ||
} |
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.
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.
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.
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]); | |
} | |
} |
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.
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?
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.
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.
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.
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.
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.
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.
Signed-off-by: Sebastian Held <[email protected]>
Signed-off-by: Sebastian Held <[email protected]>
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.
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"?> |
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.
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"?> |
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.
Same here.
## Binding Configuration | ||
|
||
No Binding configuration required. |
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.
This can be removed, then.
``` | ||
Thing ecotouch:geo:9a0ec0bbbd "Waterkotte Heatpump" @ "basement" [ ip="192.168.1.100", username="admin", password="wtkadmin", refresh=120 ] | ||
``` |
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.
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: |
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.
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 |
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.
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.
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 |
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.
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.
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.
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 | ||
|
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.
Please remove one empty line.
<channel-type id="temperature_source_in"> | ||
<item-type>Number:Temperature</item-type> | ||
<label>Temperature Source Input</label> | ||
<description></description> |
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.
You could drop the tag if it's empty.
<description></description> | ||
<state min="0" max="5" step="1" readOnly="false"/> | ||
</channel-type> | ||
|
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.
Please remove both empty lines.
Signed-off-by: Sebastian Held <[email protected]>
Signed-off-by: Sebastian Held <[email protected]>
Signed-off-by: Sebastian Held <[email protected]>
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 |
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.
Can you comment on that?
In file ecotouch_de.properties I've reduced the length of the *.label entries and added the longer description to the *.description tags. |
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 |
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. |
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. |
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. |
I think it looks odd if every word is capitalized in German. |
Signed-off-by: Sebastian Held <[email protected]>
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.
Thanks!
…#10010) Signed-off-by: Sebastian Held <[email protected]> Signed-off-by: John Marshall <[email protected]>
…#10010) Signed-off-by: Sebastian Held <[email protected]>
…#10010) Signed-off-by: Sebastian Held <[email protected]>
…#10010) Signed-off-by: Sebastian Held <[email protected]>
…#10010) Signed-off-by: Sebastian Held <[email protected]>
It was developed at https://github.com/sibbi77/openhab2-addons/tree/ecotouch-3.0.0