}
}
- private void updateTemperatureSensor(@Nullable TemperatureModel temperatureModel) {
+ protected void updateTemperatureSensor(@Nullable TemperatureModel temperatureModel) {
if (temperatureModel != null) {
updateThingChannelState(CHANNEL_TEMPERATURE,
new QuantityType<>(temperatureModel.getCelsius(), SIUnits.CELSIUS));
* @param configId ID of the configuration to be updated.
* @param value Value to be set.
*/
- private void updateThingChannelConfiguration(String channelId, String configId, Object value) {
+ protected void updateThingChannelConfiguration(String channelId, String configId, Object value) {
Channel channel = thing.getChannel(channelId);
if (channel != null) {
Configuration editConfig = channel.getConfiguration();
import static org.openhab.binding.avmfritz.internal.AVMFritzBindingConstants.*;
+import java.math.BigDecimal;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.avmfritz.internal.dto.AVMFritzBaseModel;
+import org.openhab.binding.avmfritz.internal.dto.BatteryModel;
import org.openhab.binding.avmfritz.internal.dto.ButtonModel;
import org.openhab.binding.avmfritz.internal.dto.DeviceModel;
import org.openhab.binding.avmfritz.internal.dto.HumidityModel;
+import org.openhab.binding.avmfritz.internal.dto.TemperatureModel;
import org.openhab.core.library.types.DateTimeType;
+import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.QuantityType;
+import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
}
}
+ @Override
+ protected void updateTemperatureSensor(@Nullable TemperatureModel temperatureModel) {
+ if (temperatureModel != null) {
+ String channelId = (DECT440_THING_TYPE.equals(thing.getThingTypeUID())
+ ? CHANNEL_GROUP_SENSORS + ChannelUID.CHANNEL_GROUP_SEPARATOR
+ : "") + CHANNEL_TEMPERATURE;
+ updateThingChannelState(channelId, new QuantityType<>(temperatureModel.getCelsius(), SIUnits.CELSIUS));
+ updateThingChannelConfiguration(channelId, CONFIG_CHANNEL_TEMP_OFFSET, temperatureModel.getOffset());
+ }
+ }
+
@Override
protected void updateHumiditySensor(@Nullable HumidityModel humidityModel) {
if (humidityModel != null) {
- updateThingChannelState(CHANNEL_GROUP_SENSORS + ChannelUID.CHANNEL_GROUP_SEPARATOR + CHANNEL_HUMIDITY,
- new QuantityType<>(humidityModel.getRelativeHumidity(), Units.PERCENT));
+ String channelId = (DECT440_THING_TYPE.equals(thing.getThingTypeUID())
+ ? CHANNEL_GROUP_SENSORS + ChannelUID.CHANNEL_GROUP_SEPARATOR
+ : "") + CHANNEL_HUMIDITY;
+ updateThingChannelState(channelId, new QuantityType<>(humidityModel.getRelativeHumidity(), Units.PERCENT));
+ }
+ }
+
+ @Override
+ protected void updateBattery(BatteryModel batteryModel) {
+ String batteryLevelChannelId = (DECT440_THING_TYPE.equals(thing.getThingTypeUID())
+ ? CHANNEL_GROUP_DEVICE + ChannelUID.CHANNEL_GROUP_SEPARATOR
+ : "") + CHANNEL_BATTERY;
+ BigDecimal batteryLevel = batteryModel.getBattery();
+ updateThingChannelState(batteryLevelChannelId,
+ batteryLevel == null ? UnDefType.UNDEF : new DecimalType(batteryLevel));
+ String lowBatteryChannelId = (DECT440_THING_TYPE.equals(thing.getThingTypeUID())
+ ? CHANNEL_GROUP_DEVICE + ChannelUID.CHANNEL_GROUP_SEPARATOR
+ : "") + CHANNEL_BATTERY_LOW;
+ BigDecimal lowBattery = batteryModel.getBatterylow();
+ if (lowBattery == null) {
+ updateThingChannelState(lowBatteryChannelId, UnDefType.UNDEF);
+ } else {
+ updateThingChannelState(lowBatteryChannelId,
+ BatteryModel.BATTERY_ON.equals(lowBattery) ? OnOffType.ON : OnOffType.OFF);
}
}