diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/SensorState.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/SensorState.java index cf6b78e367a..f79b92fd462 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/SensorState.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/dto/SensorState.java @@ -66,6 +66,11 @@ public class SensorState { public @Nullable Float power; /** Batttery sensors provide this value */ public @Nullable Integer battery; + /** + * Some battery sensors (especially Tuya driven devices) provide this boolean + * instead of battery level + */ + public @Nullable Boolean lowbattery; /** Consumption sensors provide this value in Watts/hour. */ public @Nullable Float consumption; /** Power sensors provide this value in Volt. */ diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java index 58765a0aa1b..3669f1ee3cb 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java @@ -138,6 +138,10 @@ public abstract class SensorBaseThingHandler extends DeconzBaseThingHandler { createChannel(CHANNEL_BATTERY_LOW, ChannelKind.STATE); } + if (sensorState.lowbattery != null) { + createChannel(CHANNEL_BATTERY_LOW, ChannelKind.STATE); + } + createTypeSpecificChannels(sensorConfig, sensorState); ignoreConfigurationUpdate = false; @@ -210,6 +214,12 @@ public abstract class SensorBaseThingHandler extends DeconzBaseThingHandler { updateState(channelUID, Util.convertTimestampToDateTime(lastUpdated)); } break; + case CHANNEL_BATTERY_LOW: + Boolean lowBattery = newState.lowbattery; + if (lowBattery != null) { + updateState(channelUID, OnOffType.from(lowBattery)); + } + break; default: // other cases covered by sub-class }