]> git.basschouten.com Git - openhab-addons.git/commitdiff
[radiothermostat] Skip shutdown actions if thing offline (#16677)
authormlobstein <michael.lobstein@gmail.com>
Thu, 25 Apr 2024 06:08:58 +0000 (01:08 -0500)
committerGitHub <noreply@github.com>
Thu, 25 Apr 2024 06:08:58 +0000 (08:08 +0200)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
bundles/org.openhab.binding.radiothermostat/src/main/java/org/openhab/binding/radiothermostat/internal/handler/RadioThermostatHandler.java

index 197bbf76034c5efd864f1ee68bf91838a57822b1..fddf8172d445fe186269e1deba1d9f729f7d230a 100644 (file)
@@ -288,12 +288,19 @@ public class RadioThermostatHandler extends BaseThingHandler implements RadioThe
         connector.removeEventListener(this);
 
         // Disable Remote Temp and Message Area on shutdown
-        if (isLinked(REMOTE_TEMP)) {
-            connector.sendCommand("rem_mode", "0", REMOTE_TEMP_RESOURCE);
-        }
+        if (ThingStatus.ONLINE.equals(this.getThing().getStatus())) {
+            final boolean isRemoteTempLinked = isLinked(REMOTE_TEMP);
+            final boolean isMessageLinked = isLinked(MESSAGE);
+
+            scheduler.schedule(() -> {
+                if (isRemoteTempLinked) {
+                    connector.sendCommand("rem_mode", "0", REMOTE_TEMP_RESOURCE);
+                }
 
-        if (isLinked(MESSAGE)) {
-            connector.sendCommand("mode", "0", PMA_RESOURCE);
+                if (isMessageLinked) {
+                    connector.sendCommand("mode", "0", PMA_RESOURCE);
+                }
+            }, 0, TimeUnit.SECONDS);
         }
 
         ScheduledFuture<?> refreshJob = this.refreshJob;