[avmfritz] Fixed channel update for DECT440 rocker (#9753)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
7e28fbb3c5
commit
43b5e79d78
@ -90,6 +90,7 @@ public class AVMFritzBindingConstants {
|
|||||||
public static final String PRODUCT_NAME = "productName";
|
public static final String PRODUCT_NAME = "productName";
|
||||||
|
|
||||||
// List of all channel groups
|
// List of all channel groups
|
||||||
|
public static final String CHANNEL_GROUP_DEVICE = "device";
|
||||||
public static final String CHANNEL_GROUP_SENSORS = "sensors";
|
public static final String CHANNEL_GROUP_SENSORS = "sensors";
|
||||||
public static final String CHANNEL_GROUP_TOP_LEFT = "top-left";
|
public static final String CHANNEL_GROUP_TOP_LEFT = "top-left";
|
||||||
public static final String CHANNEL_GROUP_BOTTOM_LEFT = "bottom-left";
|
public static final String CHANNEL_GROUP_BOTTOM_LEFT = "bottom-left";
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class DeviceModel extends AVMFritzBaseModel {
|
|||||||
return humidity;
|
return humidity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTemperature(HumidityModel humidityModel) {
|
public void setHumidity(HumidityModel humidityModel) {
|
||||||
this.humidity = humidityModel;
|
this.humidity = humidityModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -156,7 +156,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTemperatureSensor(@Nullable TemperatureModel temperatureModel) {
|
protected void updateTemperatureSensor(@Nullable TemperatureModel temperatureModel) {
|
||||||
if (temperatureModel != null) {
|
if (temperatureModel != null) {
|
||||||
updateThingChannelState(CHANNEL_TEMPERATURE,
|
updateThingChannelState(CHANNEL_TEMPERATURE,
|
||||||
new QuantityType<>(temperatureModel.getCelsius(), SIUnits.CELSIUS));
|
new QuantityType<>(temperatureModel.getCelsius(), SIUnits.CELSIUS));
|
||||||
@ -301,7 +301,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
|
|||||||
* @param configId ID of the configuration to be updated.
|
* @param configId ID of the configuration to be updated.
|
||||||
* @param value Value to be set.
|
* @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);
|
Channel channel = thing.getChannel(channelId);
|
||||||
if (channel != null) {
|
if (channel != null) {
|
||||||
Configuration editConfig = channel.getConfiguration();
|
Configuration editConfig = channel.getConfiguration();
|
||||||
|
|||||||
@ -14,6 +14,7 @@ package org.openhab.binding.avmfritz.internal.handler;
|
|||||||
|
|
||||||
import static org.openhab.binding.avmfritz.internal.AVMFritzBindingConstants.*;
|
import static org.openhab.binding.avmfritz.internal.AVMFritzBindingConstants.*;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
@ -23,11 +24,16 @@ import java.util.Optional;
|
|||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.avmfritz.internal.dto.AVMFritzBaseModel;
|
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.ButtonModel;
|
||||||
import org.openhab.binding.avmfritz.internal.dto.DeviceModel;
|
import org.openhab.binding.avmfritz.internal.dto.DeviceModel;
|
||||||
import org.openhab.binding.avmfritz.internal.dto.HumidityModel;
|
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.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.types.QuantityType;
|
||||||
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
import org.openhab.core.library.unit.Units;
|
import org.openhab.core.library.unit.Units;
|
||||||
import org.openhab.core.thing.Channel;
|
import org.openhab.core.thing.Channel;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
@ -89,11 +95,44 @@ public class AVMFritzButtonHandler extends DeviceHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
protected void updateHumiditySensor(@Nullable HumidityModel humidityModel) {
|
protected void updateHumiditySensor(@Nullable HumidityModel humidityModel) {
|
||||||
if (humidityModel != null) {
|
if (humidityModel != null) {
|
||||||
updateThingChannelState(CHANNEL_GROUP_SENSORS + ChannelUID.CHANNEL_GROUP_SEPARATOR + CHANNEL_HUMIDITY,
|
String channelId = (DECT440_THING_TYPE.equals(thing.getThingTypeUID())
|
||||||
new QuantityType<>(humidityModel.getRelativeHumidity(), Units.PERCENT));
|
? 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user