Skip to content

Commit

Permalink
[openwebnet] handle Thermo Central Unit monitoring messages (openhab#…
Browse files Browse the repository at this point in the history
…12485)

* - 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>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
aconte80 authored and andrasU committed Nov 12, 2022
1 parent 8d2ec3d commit 54c0d7d
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 14 deletions.
20 changes: 14 additions & 6 deletions bundles/org.openhab.binding.openwebnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

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;
Expand All @@ -26,11 +30,13 @@
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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -284,22 +294,25 @@ protected void handleMessage(BaseOpenMessage msg) {
// 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
Expand Down Expand Up @@ -355,6 +368,39 @@ private void updateModeAndFunction(Thermoregulation tmsg) {
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()));

Expand Down Expand Up @@ -438,7 +484,33 @@ private void updateCURemoteControlStatus(String status) {

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<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"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,34 @@
</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>
Expand Down

0 comments on commit 54c0d7d

Please sign in to comment.