]> git.basschouten.com Git - openhab-addons.git/commitdiff
[powermax] Ignore disabled things (#12684)
authorlolodomo <lg.hc@free.fr>
Thu, 5 May 2022 17:59:59 +0000 (19:59 +0200)
committerGitHub <noreply@github.com>
Thu, 5 May 2022 17:59:59 +0000 (19:59 +0200)
* [powermax] Ignore disabled things

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.powermax/src/main/java/org/openhab/binding/powermax/internal/handler/PowermaxBridgeHandler.java

index b7715502173b2fc4a39e2ccf0052c44bc1ed67fb..d711f6cdda77cef67c9084e6ee7ca5ab900b4c40 100644 (file)
@@ -49,6 +49,7 @@ import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingStatus;
 import org.openhab.core.thing.ThingStatusDetail;
 import org.openhab.core.thing.binding.BaseBridgeHandler;
+import org.openhab.core.thing.binding.ThingHandler;
 import org.openhab.core.thing.binding.ThingHandlerService;
 import org.openhab.core.types.Command;
 import org.openhab.core.types.RefreshType;
@@ -623,25 +624,27 @@ public class PowermaxBridgeHandler extends BaseBridgeHandler implements Powermax
         }
 
         for (Thing thing : getThing().getThings()) {
-            if (thing.getHandler() != null) {
-                PowermaxThingHandler handler = (PowermaxThingHandler) thing.getHandler();
-                if (handler != null) {
-                    if (thing.getThingTypeUID().equals(THING_TYPE_ZONE)) {
-                        // All of the zone state objects will have the same list of values.
-                        // The use of getZone(1) here is just to get any PowermaxZoneState
-                        // and use it to get the list of zone channels.
-
-                        for (Value<?> value : state.getZone(1).getValues()) {
-                            String channelId = value.getChannel();
-                            if ((channel == null) || channel.equals(channelId)) {
-                                handler.updateChannelFromAlarmState(channelId, state);
-                            }
-                        }
-                    } else if (thing.getThingTypeUID().equals(THING_TYPE_X10)) {
-                        if ((channel == null) || channel.equals(X10_STATUS)) {
-                            handler.updateChannelFromAlarmState(X10_STATUS, state);
+            if (!thing.isEnabled()) {
+                continue;
+            }
+            ThingHandler thingHandler = thing.getHandler();
+            if (thingHandler instanceof PowermaxThingHandler) {
+                PowermaxThingHandler handler = (PowermaxThingHandler) thingHandler;
+                if (thing.getThingTypeUID().equals(THING_TYPE_ZONE)) {
+                    // All of the zone state objects will have the same list of values.
+                    // The use of getZone(1) here is just to get any PowermaxZoneState
+                    // and use it to get the list of zone channels.
+
+                    for (Value<?> value : state.getZone(1).getValues()) {
+                        String channelId = value.getChannel();
+                        if ((channel == null) || channel.equals(channelId)) {
+                            handler.updateChannelFromAlarmState(channelId, state);
                         }
                     }
+                } else if (thing.getThingTypeUID().equals(THING_TYPE_X10)) {
+                    if ((channel == null) || channel.equals(X10_STATUS)) {
+                        handler.updateChannelFromAlarmState(X10_STATUS, state);
+                    }
                 }
             }
         }