]> git.basschouten.com Git - openhab-addons.git/commitdiff
[openwebnet] handle Thermo Central Unit monitoring messages (#12485)
authorConte Andrea <andrea@conte.com>
Fri, 18 Mar 2022 18:00:48 +0000 (19:00 +0100)
committerGitHub <noreply@github.com>
Fri, 18 Mar 2022 18:00:48 +0000 (19:00 +0100)
* - handled what=30 (failure discovered ), what=22 (at least 1 probe in off), what=23 (at least 1 probe in protection), what=24 (at least 1 probe in manual)
- related channels added
* - update README
- ignore messages from probes and central unit and keep track only of messages from a real thermostat
* add example of failureDiscovered channel
* Update bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml
* changed capital letters (atLeastOneProbeOFF -> atLeatOneProbeOff) as suggested

Signed-off-by: Conte Andrea <andrea@conte.com>
bundles/org.openhab.binding.openwebnet/README.md
bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetBindingConstants.java
bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/handler/OpenWebNetThermoregulationHandler.java
bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermoCentralUnit.xml
bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml

index 0124e26b0efc12b9833c3a1b5d81a1b21505e9e9..043cfdb30f8a11d586d4512427d06d1d233b57bb 100644 (file)
@@ -188,7 +188,10 @@ The (optional) Central Unit can be configured defining a `bus_themo_cu` Thing.
 | `batteryStatus`              | `bus_thermo_cu`                        | String             | The Central Unit Battery status: `OK`, `KO`                                                                                                                                             | R          | Y        |
 | `weeklyProgram`              | `bus_thermo_cu`                        | Number             | The program number (`1`, `2`, `3`) when Central Unit mode is `WEEKLY`                                                                                                                   | R/W        | N        |
 | `scenarioProgram`            | `bus_thermo_cu`                        | Number             | The program number (`1`, `2`, .. ,  `16`) when Central Unit mode is `SCENARIO`                                                                                                          | R/W        | N        |
-
+| `failureDiscovered`          | `bus_thermo_cu`                        | Switch             | Indicates if a Failure was discovered by the Central Unit: `ON`, `OFF`                                                                                                                  | R          | Y        |
+| `atLeastOneProbeOff`         | `bus_thermo_cu`                        | Switch             | Indicates if at least one probe is in OFF mode: `ON`, `OFF`                                                                                                                             | R          | Y        |
+| `atLeastOneProbeProtection`  | `bus_thermo_cu`                        | Switch             | Indicates if at least one probe is in PROTECTION mode: `ON`, `OFF`                                                                                                                      | R          | Y        |
+| `atLeastOneProbeManual`      | `bus_thermo_cu`                        | Switch             | Indicates if at least one probe is in MANUAL mode: `ON`, `OFF`                                                                                                                          | R          | Y        |
 
 ### Notes on channels
 
@@ -291,11 +294,16 @@ Number:Power        iCENTRAL_Tb           "Power [%.0f %unit%]" { channel="openw
 // 99 zones central unit 
 Group   gCentralUnit                "Central Unit"                
 Number:Temperature iCU_3550_manualset "Temperature"       (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:setpointTemperature", ga="thermostatTemperatureSetpoint" }
-String iCU_3550_remote    "Remote Control"    (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:remoteControl" }
-String iCU_3550_battery   "Battery Status"    (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:batteryStatus" }
-String iCU_3550_mode      "Mode"              (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:mode" }
-Number iCU_3550_wpn       "Weekly Program"    (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:weeklyProgram" } 
-Number iCU_3550_spn       "Scenario Program"  (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:scenarioProgram" } 
+String iCU_3550_remote    "Remote Control"                    (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:remoteControl" }
+String iCU_3550_battery   "Battery Status"                    (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:batteryStatus" }
+String iCU_3550_mode      "Mode"                              (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:mode" }
+Number iCU_3550_wpn       "Weekly Program"                    (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:weeklyProgram" } 
+Number iCU_3550_spn       "Scenario Program"                  (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:scenarioProgram" } 
+String iCU_3550_func      "Function"                          (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:function" }
+Switch iCU_3550_at1off    "At least one probe in OFF"         (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:atLeastOneProbeOff" } 
+Switch iCU_3550_at1pro    "At least one probe in PROTECTION"  (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:atLeastOneProbeProtection" } 
+Switch iCU_3550_at1man    "At least one probe in MANUAL"      (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:atLeastOneProbeManual" } 
+Switch iCU_3550_failure   "Failure discovered"                (gCentralUnit) { channel="openwebnet:bus_thermo_cu:mybridge:CU_3550:failureDiscovered" } 
 
 Group   gLivingRoomZone                         "Living Room Zone"   { ga="Thermostat" [ modes="auto=GENERIC,heat=HEATING,cool=COOLING", thermostatTemperatureRange="7,35", useFahrenheit=false ] }
 Number:Temperature  iLR_zone_temp               "Temperature [%.1f %unit%]"   (gLivingRoomZone) { channel="openwebnet:bus_thermo_zone:mybridge:LR_zone:temperature", ga="thermostatTemperatureAmbient" }
index 806a2c404ff5187caf4d0eb6fe0930ff9feaac96..b5a436cd9e3abfba5cf37548632d5e3737acafb3 100644 (file)
@@ -133,6 +133,10 @@ public class OpenWebNetBindingConstants {
     public static final String CHANNEL_CU_BATTERY_STATUS = "batteryStatus";
     public static final String CHANNEL_CU_WEEKLY_PROGRAM_NUMBER = "weeklyProgram";
     public static final String CHANNEL_CU_SCENARIO_PROGRAM_NUMBER = "scenarioProgram";
+    public static final String CHANNEL_CU_FAILURE_DISCOVERED = "failureDiscovered";
+    public static final String CHANNEL_CU_AT_LEAST_ONE_PROBE_OFF = "atLeastOneProbeOff";
+    public static final String CHANNEL_CU_AT_LEAST_ONE_PROBE_PROTECTION = "atLeastOneProbeProtection";
+    public static final String CHANNEL_CU_AT_LEAST_ONE_PROBE_MANUAL = "atLeastOneProbeManual";
 
     // energy management
     public static final String CHANNEL_POWER = "power";
index f9af4e14a39868eac9035fd954159f02be722665..c839a98f152e5727a00dfb17e67674360d733ed1 100644 (file)
@@ -14,7 +14,11 @@ package org.openhab.binding.openwebnet.internal.handler;
 
 import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_ACTUATORS;
 import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CONDITIONING_VALVES;
+import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CU_AT_LEAST_ONE_PROBE_MANUAL;
+import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CU_AT_LEAST_ONE_PROBE_OFF;
+import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CU_AT_LEAST_ONE_PROBE_PROTECTION;
 import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CU_BATTERY_STATUS;
+import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CU_FAILURE_DISCOVERED;
 import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CU_REMOTE_CONTROL;
 import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CU_SCENARIO_PROGRAM_NUMBER;
 import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_CU_WEEKLY_PROGRAM_NUMBER;
@@ -26,11 +30,13 @@ import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants
 import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_TEMPERATURE;
 import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.CHANNEL_TEMP_SETPOINT;
 
+import java.util.HashSet;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants;
 import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.library.types.StringType;
 import org.openhab.core.library.unit.SIUnits;
@@ -79,6 +85,10 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler {
 
     private String programNumber = "";
 
+    private static Set<String> probesInProtection = new HashSet<String>();
+    private static Set<String> probesInOFF = new HashSet<String>();
+    private static Set<String> probesInManual = new HashSet<String>();
+
     private static final String CU_REMOTE_CONTROL_ENABLED = "ENABLED";
     private static final String CU_REMOTE_CONTROL_DISABLED = "DISABLED";
     private static final String CU_BATTERY_OK = "OK";
@@ -284,22 +294,25 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler {
             // it's OK and then change to KO if according message is received
             updateCUBatteryStatus(CU_BATTERY_OK);
 
+            // same in case of Failure Discovered
+            updateCUFailureDiscovered(OnOffType.OFF);
+
             if (msg.getWhat() == Thermoregulation.WhatThermo.REMOTE_CONTROL_DISABLED) {
                 updateCURemoteControlStatus(CU_REMOTE_CONTROL_DISABLED);
             } else if (msg.getWhat() == Thermoregulation.WhatThermo.REMOTE_CONTROL_ENABLED) {
                 updateCURemoteControlStatus(CU_REMOTE_CONTROL_ENABLED);
             } else if (msg.getWhat() == Thermoregulation.WhatThermo.BATTERY_KO) {
                 updateCUBatteryStatus(CU_BATTERY_KO);
-            } // must intercept all possibile WHATs (will be implemented soon)
-            else if (msg.getWhat() == Thermoregulation.WhatThermo.AT_LEAST_ONE_PROBE_OFF) {
-                logger.debug("handleMessage() Ignoring unsupported WHAT {}. Frame={}", msg.getWhat(), msg);
+            } else if (msg.getWhat() == Thermoregulation.WhatThermo.AT_LEAST_ONE_PROBE_OFF) {
+                updateCUAtLeastOneProbeOff(OnOffType.ON);
             } else if (msg.getWhat() == Thermoregulation.WhatThermo.AT_LEAST_ONE_PROBE_ANTIFREEZE) {
-                logger.debug("handleMessage() Ignoring unsupported WHAT {}. Frame={}", msg.getWhat(), msg);
+                updateCUAtLeastOneProbeProtection(OnOffType.ON);
             } else if (msg.getWhat() == Thermoregulation.WhatThermo.AT_LEAST_ONE_PROBE_MANUAL) {
-                logger.debug("handleMessage() Ignoring unsupported WHAT {}. Frame={}", msg.getWhat(), msg);
+                updateCUAtLeastOneProbeManual(OnOffType.ON);
             } else if (msg.getWhat() == Thermoregulation.WhatThermo.FAILURE_DISCOVERED) {
-                logger.debug("handleMessage() Ignoring unsupported WHAT {}. Frame={}", msg.getWhat(), msg);
-            } else if (msg.getWhat() == Thermoregulation.WhatThermo.RELEASE_SENSOR_LOCAL_ADJUST) {
+                updateCUFailureDiscovered(OnOffType.ON);
+            } // must intercept all possibile WHATs (will be implemented soon)
+            else if (msg.getWhat() == Thermoregulation.WhatThermo.RELEASE_SENSOR_LOCAL_ADJUST) {
                 logger.debug("handleMessage() Ignoring unsupported WHAT {}. Frame={}", msg.getWhat(), msg);
             } else {
                 // check and eventually parse mode and function
@@ -355,6 +368,39 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler {
         Thermoregulation.OperationMode mode = w.getMode();
         Thermoregulation.Function function = w.getFunction();
 
+        // keep track of thermostats (zones) status
+        if (!isCentralUnit && (!((WhereThermo) deviceWhere).isProbe())) {
+            if (mode == Thermoregulation.OperationMode.OFF) {
+                probesInManual.remove(tmsg.getWhere().value());
+                probesInProtection.remove(tmsg.getWhere().value());
+                if (probesInOFF.add(tmsg.getWhere().value())) {
+                    logger.debug("atLeastOneProbeInOFF: added WHERE ---> {}", tmsg.getWhere());
+                }
+            } else if (mode == Thermoregulation.OperationMode.PROTECTION) {
+                probesInManual.remove(tmsg.getWhere().value());
+                probesInOFF.remove(tmsg.getWhere().value());
+                if (probesInProtection.add(tmsg.getWhere().value())) {
+                    logger.debug("atLeastOneProbeInProtection: added WHERE ---> {}", tmsg.getWhere());
+                }
+            } else if (mode == Thermoregulation.OperationMode.MANUAL) {
+                probesInProtection.remove(tmsg.getWhere().value());
+                probesInOFF.remove(tmsg.getWhere().value());
+                if (probesInManual.add(tmsg.getWhere().value())) {
+                    logger.debug("atLeastOneProbeInManual: added WHERE ---> {}", tmsg.getWhere());
+                }
+            }
+
+            if (probesInOFF.isEmpty()) {
+                updateCUAtLeastOneProbeOff(OnOffType.OFF);
+            }
+            if (probesInProtection.isEmpty()) {
+                updateCUAtLeastOneProbeProtection(OnOffType.OFF);
+            }
+            if (probesInManual.isEmpty()) {
+                updateCUAtLeastOneProbeManual(OnOffType.OFF);
+            }
+        }
+
         updateState(CHANNEL_FUNCTION, new StringType(function.toString()));
         updateState(CHANNEL_MODE, new StringType(mode.toString()));
 
@@ -438,7 +484,33 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler {
 
     private void updateCUBatteryStatus(String status) {
         updateState(CHANNEL_CU_BATTERY_STATUS, new StringType(status));
-        logger.debug("updateCUBatteryStatus(): {}", status);
+
+        if (status == CU_BATTERY_KO) { // do not log default value (which is automatically setted)
+            logger.debug("updateCUBatteryStatus(): {}", status);
+        }
+    }
+
+    private void updateCUFailureDiscovered(OnOffType status) {
+        updateState(CHANNEL_CU_FAILURE_DISCOVERED, status);
+
+        if (status == OnOffType.ON) { // do not log default value (which is automatically setted)
+            logger.debug("updateCUFailureDiscovered(): {}", status);
+        }
+    }
+
+    private void updateCUAtLeastOneProbeOff(OnOffType status) {
+        updateState(CHANNEL_CU_AT_LEAST_ONE_PROBE_OFF, status);
+        logger.debug("updateCUAtLeastOneProbeOff(): {}", status);
+    }
+
+    private void updateCUAtLeastOneProbeProtection(OnOffType status) {
+        updateState(CHANNEL_CU_AT_LEAST_ONE_PROBE_PROTECTION, status);
+        logger.debug("updateCUAtLeastOneProbeProtection(): {}", status);
+    }
+
+    private void updateCUAtLeastOneProbeManual(OnOffType status) {
+        updateState(CHANNEL_CU_AT_LEAST_ONE_PROBE_MANUAL, status);
+        logger.debug("updateCUAtLeastOneProbeManual(): {}", status);
     }
 
     private Boolean channelExists(String channelID) {
index e893e628470f7d1b33a2b8719aba683508d42d4d..792bb64bacec366e14424099aaa97a4cfb5fbba3 100644 (file)
                        <channel id="remoteControl" typeId="remoteControl"/>
                        <channel id="batteryStatus" typeId="batteryStatus"/>
                        <channel id="function" typeId="functionCentralUnit"/>
+                       <channel id="failureDiscovered" typeId="failureDiscovered"/>
+                       <channel id="atLeastOneProbeOff" typeId="atLeastOneProbeOff"/>
+                       <channel id="atLeastOneProbeProtection" typeId="atLeastOneProbeProtection"/>
+                       <channel id="atLeastOneProbeManual" typeId="atLeastOneProbeManual"/>
                        <!-- read/write -->
                        <channel id="setpointTemperature" typeId="setpointTemperature"/>
                        <channel id="mode" typeId="modeCentralUnit"/>
index fafa4086ed2b162ee24d75e32d4d532438045831..c8b91b615cfc0e2cfd0127f69b6c509dda9b6a6a 100644 (file)
                </state>
        </channel-type>
 
+       <channel-type id="failureDiscovered" advanced="true">
+               <item-type>Switch</item-type>
+               <label>Failure Discovered</label>
+               <description>Central Unit Failure Discovered (read only)</description>
+               <state readOnly="true"></state>
+       </channel-type>
+
+       <channel-type id="atLeastOneProbeOff" advanced="true">
+               <item-type>Switch</item-type>
+               <label>At least one probe OFF</label>
+               <description>At least one probe OFF indicator in Central Unit (read only)</description>
+               <state readOnly="true"></state>
+       </channel-type>
+
+       <channel-type id="atLeastOneProbeProtection" advanced="true">
+               <item-type>Switch</item-type>
+               <label>At least one probe in PROTECTION</label>
+               <description>At least one probe in PROTECTION (Anti Freeze/Thermal Protection) indicator in Central Unit (read only)</description>
+               <state readOnly="true"></state>
+       </channel-type>
+
+       <channel-type id="atLeastOneProbeManual" advanced="true">
+               <item-type>Switch</item-type>
+               <label>At least one probe in MANUAL</label>
+               <description>At least one probe in MANUAL indicator in Central Unit (read only)</description>
+               <state readOnly="true"></state>
+       </channel-type>
+
        <!-- Energy channels -->
        <channel-type id="power">
                <item-type>Number:Power</item-type>