[radiothermostat] Disable Remote Temp and Message Area on shutdown (#15492)

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
mlobstein
2023-08-29 11:51:44 -05:00
committed by GitHub
parent d3c07344d3
commit 8e18726399
4 changed files with 20 additions and 8 deletions

View File

@@ -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 `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. - 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. - 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 ## Channels
@@ -256,8 +257,13 @@ when
then then
// Display up to 5 numbers in the thermostat's Price Message Area (PMA) // 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 // 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 // Sends empty string to clear the number and restore the time display if OutsideTemp is undefined
var Number temp = Math.round((OutsideTemp.state as DecimalType).doubleValue).intValue var temp = ""
if (newState != null && newState != UNDEF) {
temp = Math.round((newState as DecimalType).doubleValue).intValue.toString
}
Therm_Message.sendCommand(temp) Therm_Message.sendCommand(temp)
end end
``` ```

View File

@@ -12,7 +12,6 @@
*/ */
package org.openhab.binding.radiothermostat.internal; package org.openhab.binding.radiothermostat.internal;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.measure.Unit; import javax.measure.Unit;
@@ -79,7 +78,7 @@ public class RadioThermostatBindingConstants {
public static final String REMOTE_TEMP = "remote_temp"; public static final String REMOTE_TEMP = "remote_temp";
public static final String MESSAGE = "message"; public static final String MESSAGE = "message";
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_RTHERM); public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_RTHERM);
public static final Set<String> SUPPORTED_CHANNEL_IDS = Set.of(TEMPERATURE, HUMIDITY, MODE, FAN_MODE, PROGRAM_MODE, public static final Set<String> 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, SET_POINT, OVERRIDE, HOLD, STATUS, FAN_STATUS, DAY, HOUR, MINUTE, DATE_STAMP, TODAY_HEAT_RUNTIME,

View File

@@ -14,7 +14,6 @@ package org.openhab.binding.radiothermostat.internal;
import static org.openhab.binding.radiothermostat.internal.RadioThermostatBindingConstants.THING_TYPE_RTHERM; import static org.openhab.binding.radiothermostat.internal.RadioThermostatBindingConstants.THING_TYPE_RTHERM;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -41,7 +40,7 @@ import org.osgi.service.component.annotations.Reference;
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.radiothermostat") @Component(service = ThingHandlerFactory.class, configurationPid = "binding.radiothermostat")
public class RadioThermostatHandlerFactory extends BaseThingHandlerFactory { public class RadioThermostatHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_RTHERM); private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_RTHERM);
private final RadioThermostatStateDescriptionProvider stateDescriptionProvider; private final RadioThermostatStateDescriptionProvider stateDescriptionProvider;
private final HttpClient httpClient; private final HttpClient httpClient;

View File

@@ -20,7 +20,6 @@ import java.time.ZonedDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -185,7 +184,7 @@ public class RadioThermostatHandler extends BaseThingHandler implements RadioThe
@Override @Override
public Collection<Class<? extends ThingHandlerService>> getServices() { public Collection<Class<? extends ThingHandlerService>> 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."); logger.debug("Disposing the RadioThermostat handler.");
connector.removeEventListener(this); 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; ScheduledFuture<?> refreshJob = this.refreshJob;
if (refreshJob != null) { if (refreshJob != null) {
refreshJob.cancel(true); refreshJob.cancel(true);