Skip to content

Commit 8e18726

Browse files
authored
[radiothermostat] Disable Remote Temp and Message Area on shutdown (openhab#15492)
Signed-off-by: Michael Lobstein <[email protected]>
1 parent d3c0734 commit 8e18726

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

bundles/org.openhab.binding.radiothermostat/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ curl http://$THERMOSTAT_IP/cloud -d '{"authkey":""}' -X POST
6666
- The `override` flag is not reported correctly on older thermostat versions (i.e. /tstat/model reports v1.09)
6767
- The 'Program Mode' command is untested and according to the published API is only available on a CT80 Rev B.
6868
- Humidity information is available only when using a CT80 thermostat.
69+
- If `remote_temp` or `message` channels are used, their values in the thermostat will be cleared during binding shutdown.
6970

7071
## Channels
7172

@@ -256,8 +257,13 @@ when
256257
then
257258
// Display up to 5 numbers in the thermostat's Price Message Area (PMA)
258259
// A decimal point can be used. CT80 can display a negative '-' number
259-
// Send null or empty string to clear the number and restore the time display
260-
var Number temp = Math.round((OutsideTemp.state as DecimalType).doubleValue).intValue
260+
// Sends empty string to clear the number and restore the time display if OutsideTemp is undefined
261+
var temp = ""
262+
263+
if (newState != null && newState != UNDEF) {
264+
temp = Math.round((newState as DecimalType).doubleValue).intValue.toString
265+
}
266+
261267
Therm_Message.sendCommand(temp)
262268
end
263269
```

bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatBindingConstants.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
package org.openhab.binding.radiothermostat.internal;
1414

15-
import java.util.Collections;
1615
import java.util.Set;
1716

1817
import javax.measure.Unit;
@@ -79,7 +78,7 @@ public class RadioThermostatBindingConstants {
7978
public static final String REMOTE_TEMP = "remote_temp";
8079
public static final String MESSAGE = "message";
8180

82-
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_RTHERM);
81+
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_RTHERM);
8382

8483
public static final Set<String> SUPPORTED_CHANNEL_IDS = Set.of(TEMPERATURE, HUMIDITY, MODE, FAN_MODE, PROGRAM_MODE,
8584
SET_POINT, OVERRIDE, HOLD, STATUS, FAN_STATUS, DAY, HOUR, MINUTE, DATE_STAMP, TODAY_HEAT_RUNTIME,

bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatHandlerFactory.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import static org.openhab.binding.radiothermostat.internal.RadioThermostatBindingConstants.THING_TYPE_RTHERM;
1616

17-
import java.util.Collections;
1817
import java.util.Set;
1918

2019
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -41,7 +40,7 @@
4140
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.radiothermostat")
4241
public class RadioThermostatHandlerFactory extends BaseThingHandlerFactory {
4342

44-
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_RTHERM);
43+
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_RTHERM);
4544
private final RadioThermostatStateDescriptionProvider stateDescriptionProvider;
4645
private final HttpClient httpClient;
4746

bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/handler/RadioThermostatHandler.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.ArrayList;
2121
import java.util.Calendar;
2222
import java.util.Collection;
23-
import java.util.Collections;
2423
import java.util.List;
2524
import java.util.concurrent.ScheduledFuture;
2625
import java.util.concurrent.TimeUnit;
@@ -185,7 +184,7 @@ public void initialize() {
185184

186185
@Override
187186
public Collection<Class<? extends ThingHandlerService>> getServices() {
188-
return Collections.singletonList(RadioThermostatThingActions.class);
187+
return List.of(RadioThermostatThingActions.class);
189188
}
190189

191190
/**
@@ -288,6 +287,15 @@ public void dispose() {
288287
logger.debug("Disposing the RadioThermostat handler.");
289288
connector.removeEventListener(this);
290289

290+
// Disable Remote Temp and Message Area on shutdown
291+
if (isLinked(REMOTE_TEMP)) {
292+
connector.sendCommand("rem_mode", "0", REMOTE_TEMP_RESOURCE);
293+
}
294+
295+
if (isLinked(MESSAGE)) {
296+
connector.sendCommand("mode", "0", PMA_RESOURCE);
297+
}
298+
291299
ScheduledFuture<?> refreshJob = this.refreshJob;
292300
if (refreshJob != null) {
293301
refreshJob.cancel(true);

0 commit comments

Comments
 (0)