diff --git a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java
index c587b45ce4fa9..698f2a89de3ff 100644
--- a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java
+++ b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java
@@ -91,7 +91,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
/**
* keeps track of the current state for handling of increase/decrease
*/
- private @Nullable AVMFritzBaseModel state;
+ private AVMFritzBaseModel currentDevice = new DeviceModel();
private @Nullable String identifier;
/**
@@ -130,7 +130,7 @@ public void onDeviceUpdated(ThingUID thingUID, AVMFritzBaseModel device) {
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "Device not present");
}
- state = device;
+ currentDevice = device;
updateProperties(device, editProperties());
@@ -156,13 +156,12 @@ public void onDeviceUpdated(ThingUID thingUID, AVMFritzBaseModel device) {
}
if (deviceModel.isHANFUNBlinds()) {
updateLevelControl(deviceModel.getLevelControlModel());
- }
- if (deviceModel.isColorLight()) {
+ } else if (deviceModel.isColorLight()) {
updateColorLight(deviceModel.getColorControlModel(), deviceModel.getLevelControlModel());
} else if (deviceModel.isDimmableLight()) {
updateDimmableLight(deviceModel.getLevelControlModel());
- } else if (device.isHANFUNUnit() && device.isHANFUNOnOff()) {
- updateSimpleOnOffUnit(device.getSimpleOnOffUnit());
+ } else if (deviceModel.isHANFUNUnit() && deviceModel.isHANFUNOnOff()) {
+ updateSimpleOnOffUnit(deviceModel.getSimpleOnOffUnit());
}
}
}
@@ -438,7 +437,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
((QuantityType>) command).getUnit(), SIUnits.CELSIUS);
}
} else if (command instanceof IncreaseDecreaseType) {
- temperature = state.getHkr().getTsoll();
+ temperature = currentDevice.getHkr().getTsoll();
if (IncreaseDecreaseType.INCREASE.equals(command)) {
temperature.add(BigDecimal.ONE);
} else {
@@ -449,7 +448,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
if (temperature != null) {
fritzBox.setSetTemp(ain, fromCelsius(temperature));
- HeatingModel heatingModel = state.getHkr();
+ HeatingModel heatingModel = currentDevice.getHkr();
heatingModel.setTsoll(temperature);
updateState(CHANNEL_RADIATOR_MODE, new StringType(heatingModel.getRadiatorMode()));
}
@@ -465,10 +464,10 @@ public void handleCommand(ChannelUID channelUID, Command command) {
targetTemperature = TEMP_FRITZ_OFF;
break;
case MODE_COMFORT:
- targetTemperature = state.getHkr().getKomfort();
+ targetTemperature = currentDevice.getHkr().getKomfort();
break;
case MODE_ECO:
- targetTemperature = state.getHkr().getAbsenk();
+ targetTemperature = currentDevice.getHkr().getAbsenk();
break;
case MODE_BOOST:
targetTemperature = TEMP_FRITZ_MAX;
@@ -480,7 +479,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
if (targetTemperature != null) {
fritzBox.setSetTemp(ain, targetTemperature);
- state.getHkr().setTsoll(targetTemperature);
+ currentDevice.getHkr().setTsoll(targetTemperature);
updateState(CHANNEL_SETTEMP, new QuantityType<>(toCelsius(targetTemperature), SIUnits.CELSIUS));
}
}
diff --git a/bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/AVMFritzDeviceListModelTest.java b/bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/AVMFritzDeviceListModelTest.java
index aeb65d7b3ef21..87604e956d961 100644
--- a/bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/AVMFritzDeviceListModelTest.java
+++ b/bundles/org.openhab.binding.avmfritz/src/test/java/org/openhab/binding/avmfritz/internal/dto/AVMFritzDeviceListModelTest.java
@@ -85,6 +85,30 @@ public void setUp() throws JAXBException, XMLStreamException {
+ " 262\n"
+ " 512\n"
+ " \n"
+ + ""
+ + "\n"
+ + " 0\n"
+ + " 0\n"
+ + " SmartHome LED-Lampe #1\n"
+ + " \n"
+ + " 0\n"
+ + " \n"
+ + " \n"
+ + " 26\n"
+ + " 10\n"
+ + " \n"
+ + " \n"
+ + " 254\n"
+ + " 100\n"
+ + " \n"
+ + " \n"
+ + " 2700\n"
+ + " \n"
+ + " \n"
+ + " 407\n"
+ + " 278\n"
+ + " 512,514,513\n"
+ + " \n"
+ "" +
"";
//@formatter:on
@@ -96,7 +120,7 @@ public void setUp() throws JAXBException, XMLStreamException {
@Test
public void validateDeviceListModel() {
assertNotNull(devices);
- assertEquals(16, devices.getDevicelist().size());
+ assertEquals(17, devices.getDevicelist().size());
assertEquals("1", devices.getXmlApiVersion());
}
@@ -611,15 +635,21 @@ public void validateHANFUNBlindModel() {
assertEquals(1, device.getPresent());
assertEquals("Rollotron 1213 #1", device.getName());
- assertFalse(device.isButton());
+ assertFalse(device.isHANFUNDevice());
assertFalse(device.isHANFUNButton());
assertTrue(device.isHANFUNAlarmSensor());
- assertFalse(device.isDectRepeater());
+ assertFalse(device.isButton());
assertFalse(device.isSwitchableOutlet());
assertFalse(device.isTemperatureSensor());
assertFalse(device.isHumiditySensor());
assertFalse(device.isPowermeter());
+ assertFalse(device.isDectRepeater());
assertFalse(device.isHeatingThermostat());
+ assertFalse(device.hasMicrophone());
+ assertTrue(device.isHANFUNUnit());
+ assertTrue(device.isHANFUNOnOff());
+ assertTrue(device.isDimmableLight());
+ assertFalse(device.isColorLight());
assertTrue(device.isHANFUNBlinds());
assertTrue(device.getButtons().isEmpty());
@@ -641,6 +671,63 @@ public void validateHANFUNBlindModel() {
assertEquals(BigDecimal.valueOf(10L), levelcontrol.getLevelPercentage());
}
+ @Test
+ public void validateHANFUNColorLightModel() {
+ Optional optionalDevice = findModelByIdentifier("127010027533-1");
+ assertTrue(optionalDevice.isPresent());
+ assertTrue(optionalDevice.get() instanceof DeviceModel);
+
+ DeviceModel device = (DeviceModel) optionalDevice.get();
+ assertEquals("HAN-FUN", device.getProductName());
+ assertEquals("127010027533-1", device.getIdentifier());
+ assertEquals("2002", device.getDeviceId());
+ assertEquals("0.0", device.getFirmwareVersion());
+ assertEquals("0x319d", device.getManufacturer());
+
+ assertEquals(0, device.getPresent());
+ assertEquals("SmartHome LED-Lampe #1", device.getName());
+
+ assertFalse(device.isHANFUNDevice());
+ assertFalse(device.isHANFUNButton());
+ assertFalse(device.isHANFUNAlarmSensor());
+ assertFalse(device.isButton());
+ assertFalse(device.isSwitchableOutlet());
+ assertFalse(device.isTemperatureSensor());
+ assertFalse(device.isHumiditySensor());
+ assertFalse(device.isPowermeter());
+ assertFalse(device.isDectRepeater());
+ assertFalse(device.isHeatingThermostat());
+ assertFalse(device.hasMicrophone());
+ assertTrue(device.isHANFUNUnit());
+ assertTrue(device.isHANFUNOnOff());
+ assertTrue(device.isDimmableLight());
+ assertTrue(device.isColorLight());
+ assertFalse(device.isHANFUNBlinds());
+
+ assertTrue(device.getButtons().isEmpty());
+
+ assertNull(device.getAlert());
+
+ assertNull(device.getSwitch());
+
+ assertNull(device.getTemperature());
+
+ assertNull(device.getPowermeter());
+
+ assertNull(device.getHkr());
+
+ LevelControlModel levelcontrol = device.getLevelControlModel();
+ assertNotNull(levelcontrol);
+ assertEquals(BigDecimal.valueOf(26L), levelcontrol.getLevel());
+ assertEquals(BigDecimal.valueOf(10L), levelcontrol.getLevelPercentage());
+
+ ColorControlModel colorModel = device.getColorControlModel();
+ assertNotNull(colorModel);
+ assertEquals(254, colorModel.hue);
+ assertEquals(100, colorModel.saturation);
+ assertEquals(2700, colorModel.temperature);
+ }
+
@Test
public void validateHANFUNOnOffModel() {
Optional optionalDevice = findModelByIdentifier("113240824499-1");