diff --git a/bundles/org.openhab.binding.radiothermostat/README.md b/bundles/org.openhab.binding.radiothermostat/README.md index 7f957cd2177..eb918c40e5b 100644 --- a/bundles/org.openhab.binding.radiothermostat/README.md +++ b/bundles/org.openhab.binding.radiothermostat/README.md @@ -66,6 +66,7 @@ curl http://$THERMOSTAT_IP/cloud -d '{"authkey":""}' -X POST - The `override` flag is not reported correctly on older thermostat versions (i.e. /tstat/model reports v1.09) - The 'Program Mode' command is untested and according to the published API is only available on a CT80 Rev B. - Humidity information is available only when using a CT80 thermostat. +- If `remote_temp` or `message` channels are used, their values in the thermostat will be cleared during binding shutdown. ## Channels @@ -256,8 +257,13 @@ when then // Display up to 5 numbers in the thermostat's Price Message Area (PMA) // A decimal point can be used. CT80 can display a negative '-' number - // Send null or empty string to clear the number and restore the time display - var Number temp = Math.round((OutsideTemp.state as DecimalType).doubleValue).intValue + // Sends empty string to clear the number and restore the time display if OutsideTemp is undefined + var temp = "" + + if (newState != null && newState != UNDEF) { + temp = Math.round((newState as DecimalType).doubleValue).intValue.toString + } + Therm_Message.sendCommand(temp) end ``` diff --git a/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatBindingConstants.java b/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatBindingConstants.java index 8e043d4ade9..bcfbadce928 100644 --- a/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatBindingConstants.java +++ b/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatBindingConstants.java @@ -12,7 +12,6 @@ */ package org.openhab.binding.radiothermostat.internal; -import java.util.Collections; import java.util.Set; import javax.measure.Unit; @@ -79,7 +78,7 @@ public class RadioThermostatBindingConstants { public static final String REMOTE_TEMP = "remote_temp"; public static final String MESSAGE = "message"; - public static final Set SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_RTHERM); + public static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_RTHERM); public static final Set SUPPORTED_CHANNEL_IDS = Set.of(TEMPERATURE, HUMIDITY, MODE, FAN_MODE, PROGRAM_MODE, SET_POINT, OVERRIDE, HOLD, STATUS, FAN_STATUS, DAY, HOUR, MINUTE, DATE_STAMP, TODAY_HEAT_RUNTIME, diff --git a/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatHandlerFactory.java b/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatHandlerFactory.java index 133ec468a46..227ee7eb5d2 100644 --- a/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatHandlerFactory.java +++ b/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/RadioThermostatHandlerFactory.java @@ -14,7 +14,6 @@ package org.openhab.binding.radiothermostat.internal; import static org.openhab.binding.radiothermostat.internal.RadioThermostatBindingConstants.THING_TYPE_RTHERM; -import java.util.Collections; import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -41,7 +40,7 @@ import org.osgi.service.component.annotations.Reference; @Component(service = ThingHandlerFactory.class, configurationPid = "binding.radiothermostat") public class RadioThermostatHandlerFactory extends BaseThingHandlerFactory { - private static final Set SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_RTHERM); + private static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_RTHERM); private final RadioThermostatStateDescriptionProvider stateDescriptionProvider; private final HttpClient httpClient; diff --git a/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/handler/RadioThermostatHandler.java b/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/handler/RadioThermostatHandler.java index b1dd1e32b69..26c6569d5c7 100644 --- a/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/handler/RadioThermostatHandler.java +++ b/bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/handler/RadioThermostatHandler.java @@ -20,7 +20,6 @@ import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -185,7 +184,7 @@ public class RadioThermostatHandler extends BaseThingHandler implements RadioThe @Override public Collection> getServices() { - return Collections.singletonList(RadioThermostatThingActions.class); + return List.of(RadioThermostatThingActions.class); } /** @@ -288,6 +287,15 @@ public class RadioThermostatHandler extends BaseThingHandler implements RadioThe logger.debug("Disposing the RadioThermostat handler."); connector.removeEventListener(this); + // Disable Remote Temp and Message Area on shutdown + if (isLinked(REMOTE_TEMP)) { + connector.sendCommand("rem_mode", "0", REMOTE_TEMP_RESOURCE); + } + + if (isLinked(MESSAGE)) { + connector.sendCommand("mode", "0", PMA_RESOURCE); + } + ScheduledFuture refreshJob = this.refreshJob; if (refreshJob != null) { refreshJob.cancel(true);