]> git.basschouten.com Git - openhab-addons.git/commitdiff
[ecotouch] Fix description of nviSollKuehlen and coolEnableTemp being writable (...
authorSebastian Held <sebastian.held@gmx.de>
Fri, 24 Dec 2021 09:36:04 +0000 (10:36 +0100)
committerGitHub <noreply@github.com>
Fri, 24 Dec 2021 09:36:04 +0000 (10:36 +0100)
* Fix description of nviSollKuehlen being writable
* Fix description of coolEnableTemp being writable
* [ecotouch] make channels writable
* [ecotouch] silence compiler warnings
* change example to English

Signed-off-by: Sebastian Held <sebastian.held@gmx.de>
Co-authored-by: Jan Mattner <JanMattner@users.noreply.github.com>
bundles/org.openhab.binding.ecotouch/README.md
bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java
bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchHandler.java
bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchTags.java
bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml

index 2050f4ae66143a676b24a856d464588d684dbf26..b8831b4f240bd881f5d7c0410003832b295afd37 100644 (file)
@@ -64,7 +64,7 @@ Advanced channels:
 | Channel ID                       | Type                 | Read-Only | Description                                                             |
 |----------------------------------|----------------------|-----------|-------------------------------------------------------------------------|
 | compressor_power                 | Number:Dimensionless | yes       | Percent Power Compressor                                                |
-| coolEnableTemp                   | Number:Temperature   | yes       | Temperature Cooling Enable                                              |
+| coolEnableTemp                   | Number:Temperature   | no        | Temperature Cooling Enable                                              |
 | date_day                         | Number:Dimensionless | yes       | Day                                                                     |
 | date_month                       | Number:Dimensionless | yes       | Month                                                                   |
 | date_year                        | Number:Dimensionless | yes       | Year                                                                    |
@@ -85,7 +85,7 @@ Advanced channels:
 | maxVLTemp                        | Number:Temperature   | yes       | maxVLTemp                                                               |
 | nviHeizkreisNorm                 | Number:Temperature   | no        | nviHeizkreisNorm                                                        |
 | nviNormAussen                    | Number:Temperature   | no        | nviNormAussen                                                           |
-| nviSollKuehlen                   | Number:Temperature   | yes       | nviSollKuehlen                                                          |
+| nviSollKuehlen                   | Number:Temperature   | no        | nviSollKuehlen                                                          |
 | nviTHeizgrenze                   | Number:Temperature   | no        | nviTHeizgrenze                                                          |
 | nviTHeizgrenzeSoll               | Number:Temperature   | no        | nviTHeizgrenze Setpoint                                                 |
 | operating_hours_circulation_pump | Number:Time          | yes       | Operating Hours Circulation Pump                                        |
@@ -179,6 +179,7 @@ Number:Power HeatPump_power_el              { channel="ecotouch:geo:heatpump:pow
 Number:Power HeatPump_power_th              { channel="ecotouch:geo:heatpump:power_heating" }
 Number HeatPump_COP_heating                 { channel="ecotouch:geo:heatpump:cop_heating" }
 Number:Temperature HeatPump_adaptHeating    { channel="ecotouch:geo:heatpump:adapt_heating" }
+Switch HeatPump_state_sourcepump            { channel="ecotouch:geo:heatpump:state_sourcepump" }
 ```
 
 ### ecotouch.sitemap
@@ -198,3 +199,21 @@ sitemap ecotouch label="Waterkotte EcoTouch"
     Setpoint item=HeatPump_adaptHeating minValue=-2.0 maxValue=2.0 step=0.5
 }
 ```
+
+A snippet to show the current state of the heatpump (you need to have the corresponding items in your .items-file):
+
+```
+    Text label="State" icon="settings" {
+        Text item=HeatPump_state_sourcepump   label="State Source Pump [%s]"      valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_heatingpump  label="State Heating Pump [%s]"     valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_evd          label="State EVD [%s]"              valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_compressor1  label="State Compressor 1 [%s]"     valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_extheater    label="State External Heater [%s]"  valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_alarm        label="State Alarm [%s]"            valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_cooling      label="State Cooling [%s]"          valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_water        label="State Water [%s]"            valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_pool         label="State Pool [%s]"             valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_solar        label="State Solar [%s]"            valuecolor=[==ON="green", ==OFF="red"]
+        Text item=HeatPump_state_cooling4way  label="State Cooling4Way [%s]"      valuecolor=[==ON="green", ==OFF="red"]
+    }
+```
index 0e4ea47c091ed0dab4d144ee9f2a2f5c5cf90fd8..1078c88c622cd6663da3b0037299537206553b7f 100644 (file)
@@ -20,7 +20,11 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -110,10 +114,11 @@ public class EcoTouchConnector {
             throw new IOException("Too many users already logged in.");
         }
         if (cookies == null) {
-            if (cause == null)
+            if (cause == null) {
                 throw new IOException("Cannot login");
-            else
+            } else {
                 throw new IOException("Cannot login: " + cause);
+            }
         }
     }
 
@@ -212,8 +217,9 @@ public class EcoTouchConnector {
                 String line;
                 while ((line = reader.readLine()) != null) {
                     String line2 = reader.readLine();
-                    if (line2 == null)
+                    if (line2 == null) {
                         break;
+                    }
                     String doubleline = line + "\n" + line2;
                     Matcher m = responsePattern.matcher(doubleline);
                     if (m.find()) {
@@ -237,8 +243,9 @@ public class EcoTouchConnector {
                 }
                 loginAttempt++;
             } finally {
-                if (reader != null)
+                if (reader != null) {
                     reader.close();
+                }
             }
         }
 
@@ -291,8 +298,9 @@ public class EcoTouchConnector {
                 }
                 loginAttempt++;
             } finally {
-                if (reader != null)
+                if (reader != null) {
                     reader.close();
+                }
             }
         }
 
index c8b5c72c37a4a265641932acf71acf06f40056a0..4fd97bd4171d78582b4a3890018d67571b025642 100644 (file)
@@ -18,7 +18,11 @@ import static org.openhab.core.library.unit.Units.*;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -107,6 +111,10 @@ public class EcoTouchHandler extends BaseThingHandler {
             // send command to heat pump
             try {
                 EcoTouchTags ecoTouchTag = EcoTouchTags.fromString(channelUID.getId());
+                if (ecoTouchTag == null) {
+                    logger.warn("ID: {} unknown", channelUID.getId());
+                    return;
+                }
                 if (ecoTouchTag == EcoTouchTags.TYPE_ADAPT_HEATING) {
                     // this type needs special treatment
                     QuantityType<?> value = (QuantityType<?>) command;
@@ -189,8 +197,9 @@ public class EcoTouchHandler extends BaseThingHandler {
                     for (EcoTouchTags ecoTouchTag : EcoTouchTags.values()) {
                         String channel = ecoTouchTag.getCommand();
                         boolean linked = isLinked(channel);
-                        if (linked)
+                        if (linked) {
                             tags.add(ecoTouchTag.getTagName());
+                        }
                     }
                     var localConnector = connector;
                     if (localConnector != null) {
@@ -216,8 +225,9 @@ public class EcoTouchHandler extends BaseThingHandler {
             };
 
             var localConfig = config;
-            if (localConfig != null)
+            if (localConfig != null) {
                 refreshJob = scheduler.scheduleWithFixedDelay(runnable, 10, localConfig.refresh, TimeUnit.SECONDS);
+            }
         }
     }
 
@@ -229,7 +239,8 @@ public class EcoTouchHandler extends BaseThingHandler {
             localRefreshJob = null;
         }
         var localConnector = connector;
-        if (localConnector != null)
+        if (localConnector != null) {
             localConnector.logout();
+        }
     }
 }
index 19572aaa537ea4ea8f6f65fec45944bf808421c8..1c549329827cc3feaa9a88abf4116d6d8ecbe4c4 100644 (file)
@@ -22,12 +22,16 @@ import java.util.List;
 
 import javax.measure.Unit;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
 /**
  * Represents all valid commands which could be processed by this binding
  *
  * @author Sebastian Held <sebastian.held@gmx.de> - Initial contribution
  * @since 1.5.0
  */
+@NonNullByDefault
 public enum EcoTouchTags {
 
     // German: Außentemperatur
@@ -1131,12 +1135,12 @@ public enum EcoTouchTags {
      * Represents the heatpump command as it will be used in *.items
      * configuration
      */
-    String command;
+    String command = "";
     /**
      * Represents the internal raw heatpump command as it will be used in
      * querying the heat pump
      */
-    String tagName;
+    String tagName = "";
 
     Unit<?> unit = ONE;
 
@@ -1172,7 +1176,7 @@ public enum EcoTouchTags {
     /**
      * If \c type is Type.Enum, this defines the meaning of the values (0-based)
      */
-    String[] stringEnum = null;
+    String @Nullable [] stringEnum = null;
 
     /**
      * @return command name (uses in *.items files)
@@ -1244,10 +1248,11 @@ public enum EcoTouchTags {
         if (type == Type.Bitfield) {
             // ignore any scaling from \ref divisor
             int value = raw.intValue();
-            if ((value & (1 << bitnum)) != 0)
+            if ((value & (1 << bitnum)) != 0) {
                 return BigDecimal.ONE;
-            else
+            } else {
                 return BigDecimal.ZERO;
+            }
         }
         BigDecimal result = raw.divide(new BigDecimal(divisor));
         return result;
@@ -1260,8 +1265,8 @@ public enum EcoTouchTags {
      *            command string e.g. "temperature_outside"
      * @return matching EcoTouchTags instance, if available
      */
-    public static EcoTouchTags fromString(String heatpumpCommand) {
-        if ("".equals(heatpumpCommand)) {
+    public static @Nullable EcoTouchTags fromString(String heatpumpCommand) {
+        if (heatpumpCommand.isEmpty()) {
             return null;
         }
         for (EcoTouchTags c : EcoTouchTags.values()) {
index 1272f90c89c31dd9b2580fe4a226930d26ac4eeb..91ec05504bf5cc861380bd76256a7cea8041cc0e 100644 (file)
                <item-type>Number:Temperature</item-type>
                <label>Temperature Cooling Enable</label>
                <category>Temperature</category>
-               <state readOnly="true" pattern="%.1f %unit%"/>
+               <state readOnly="false" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="nviSollKuehlen" advanced="true">
                <item-type>Number:Temperature</item-type>
                <label>nviSollKuehlen</label>
                <category>Temperature</category>
-               <state readOnly="true" pattern="%.1f %unit%"/>
+               <state readOnly="false" pattern="%.1f %unit%"/>
        </channel-type>
        <channel-type id="tempchange_heating_pv" advanced="true">
                <item-type>Number:Temperature</item-type>