mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 23:22:02 +01:00
[deconz] Add support for lowbattery flag from state response (#12422)
* Add support for lowbattery flag from state response Signed-off-by: Johannes Ott <mail@johannes-ott.net>
This commit is contained in:
parent
52c21a35a3
commit
8a394c6427
@ -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. */
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user