[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;
|
public @Nullable Float power;
|
||||||
/** Batttery sensors provide this value */
|
/** Batttery sensors provide this value */
|
||||||
public @Nullable Integer battery;
|
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. */
|
/** Consumption sensors provide this value in Watts/hour. */
|
||||||
public @Nullable Float consumption;
|
public @Nullable Float consumption;
|
||||||
/** Power sensors provide this value in Volt. */
|
/** Power sensors provide this value in Volt. */
|
||||||
|
|
|
@ -138,6 +138,10 @@ public abstract class SensorBaseThingHandler extends DeconzBaseThingHandler {
|
||||||
createChannel(CHANNEL_BATTERY_LOW, ChannelKind.STATE);
|
createChannel(CHANNEL_BATTERY_LOW, ChannelKind.STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sensorState.lowbattery != null) {
|
||||||
|
createChannel(CHANNEL_BATTERY_LOW, ChannelKind.STATE);
|
||||||
|
}
|
||||||
|
|
||||||
createTypeSpecificChannels(sensorConfig, sensorState);
|
createTypeSpecificChannels(sensorConfig, sensorState);
|
||||||
|
|
||||||
ignoreConfigurationUpdate = false;
|
ignoreConfigurationUpdate = false;
|
||||||
|
@ -210,6 +214,12 @@ public abstract class SensorBaseThingHandler extends DeconzBaseThingHandler {
|
||||||
updateState(channelUID, Util.convertTimestampToDateTime(lastUpdated));
|
updateState(channelUID, Util.convertTimestampToDateTime(lastUpdated));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CHANNEL_BATTERY_LOW:
|
||||||
|
Boolean lowBattery = newState.lowbattery;
|
||||||
|
if (lowBattery != null) {
|
||||||
|
updateState(channelUID, OnOffType.from(lowBattery));
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// other cases covered by sub-class
|
// other cases covered by sub-class
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue