From d67c34e2bff02de86d8e3099ee03f774a97ee949 Mon Sep 17 00:00:00 2001 From: Sebastian Held Date: Fri, 24 Dec 2021 10:36:04 +0100 Subject: [PATCH] [ecotouch] Fix description of nviSollKuehlen and coolEnableTemp being writable (#11716) * 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 Co-authored-by: Jan Mattner --- .../org.openhab.binding.ecotouch/README.md | 23 +++++++++++++++++-- .../ecotouch/internal/EcoTouchConnector.java | 20 +++++++++++----- .../ecotouch/internal/EcoTouchHandler.java | 19 +++++++++++---- .../ecotouch/internal/EcoTouchTags.java | 19 +++++++++------ .../resources/OH-INF/thing/thing-types.xml | 4 ++-- 5 files changed, 64 insertions(+), 21 deletions(-) diff --git a/bundles/org.openhab.binding.ecotouch/README.md b/bundles/org.openhab.binding.ecotouch/README.md index 2050f4ae6..b8831b4f2 100644 --- a/bundles/org.openhab.binding.ecotouch/README.md +++ b/bundles/org.openhab.binding.ecotouch/README.md @@ -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"] + } +``` diff --git a/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java b/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java index 0e4ea47c0..1078c88c6 100644 --- a/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java +++ b/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchConnector.java @@ -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(); + } } } diff --git a/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchHandler.java b/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchHandler.java index c8b5c72c3..4fd97bd41 100644 --- a/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchHandler.java +++ b/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchHandler.java @@ -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(); + } } } diff --git a/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchTags.java b/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchTags.java index 19572aaa5..1c5493298 100644 --- a/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchTags.java +++ b/bundles/org.openhab.binding.ecotouch/src/main/java/org/openhab/binding/ecotouch/internal/EcoTouchTags.java @@ -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 - 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()) { diff --git a/bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml index 1272f90c8..91ec05504 100644 --- a/bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.ecotouch/src/main/resources/OH-INF/thing/thing-types.xml @@ -586,13 +586,13 @@ Number:Temperature Temperature - + Number:Temperature Temperature - + Number:Temperature