mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[avmfritz] Fix incorrect state of dimmable bulb (#17685)
* [avmfritz] Fix incorrect state of dimmable bulb Fixes #17609 Signed-off-by: Fabian Girgert <fabian-github@girgert.name>
This commit is contained in:
parent
d918c20925
commit
2d72c8a8db
@ -126,6 +126,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author Ulrich Mertin - Added support for HAN-FUN blinds
|
||||
* @author Christoph Sommer - Added support for color temperature
|
||||
* @author Tobias Lange - Added abs color temperature and fixed on/off behavior of light blub
|
||||
* @author Fabian Girgert - Fixed incorrect state of dimmable bulb when switched off
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implements FritzAhaStatusListener {
|
||||
@ -207,7 +208,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
|
||||
updateColorLight(deviceModel.getColorControlModel(), deviceModel.getLevelControlModel(),
|
||||
deviceModel.getSimpleOnOffUnit());
|
||||
} else if (deviceModel.isDimmableLight() && !deviceModel.isHANFUNBlinds()) {
|
||||
updateDimmableLight(deviceModel.getLevelControlModel());
|
||||
updateDimmableLight(deviceModel.getLevelControlModel(), deviceModel.getSimpleOnOffUnit());
|
||||
} else if (deviceModel.isHANFUNUnit() && deviceModel.isHANFUNOnOff()) {
|
||||
updateSimpleOnOffUnit(deviceModel.getSimpleOnOffUnit());
|
||||
}
|
||||
@ -255,9 +256,16 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDimmableLight(@Nullable LevelControlModel levelControlModel) {
|
||||
private void updateDimmableLight(@Nullable LevelControlModel levelControlModel,
|
||||
@Nullable SimpleOnOffModel simpleOnOff) {
|
||||
if (levelControlModel != null) {
|
||||
updateThingChannelState(CHANNEL_BRIGHTNESS, new PercentType(levelControlModel.getLevelPercentage()));
|
||||
PercentType brightness;
|
||||
if (simpleOnOff == null || simpleOnOff.state) {
|
||||
brightness = new PercentType(levelControlModel.getLevelPercentage());
|
||||
} else {
|
||||
brightness = PercentType.ZERO;
|
||||
}
|
||||
updateThingChannelState(CHANNEL_BRIGHTNESS, brightness);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ import org.openhab.binding.avmfritz.internal.util.JAXBUtils;
|
||||
*
|
||||
* @author Christoph Weitkamp - Initial contribution
|
||||
* @author Ulrich Mertin - Added support for HAN-FUN blinds
|
||||
* @author Fabian Girgert - Fixed incorrect state of dimmable bulb when switched off
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class AVMFritzDeviceListModelTest {
|
||||
@ -111,7 +112,24 @@ public class AVMFritzDeviceListModelTest {
|
||||
<interfaces>512,514,513</interfaces>
|
||||
</etsiunitinfo>
|
||||
</device>\
|
||||
</devicelist>\
|
||||
<device identifier="Z001788011D4B55D30B" id="2038" functionbitmask="106500" fwversion="0.0" manufacturer="0x100b" productname="Signify Netherlands B.V. LWG004">
|
||||
<present>1</present>
|
||||
<txbusy>0</txbusy>
|
||||
<name>Zigbee dimmable bulb</name>
|
||||
<simpleonoff>
|
||||
<state>0</state>
|
||||
</simpleonoff>
|
||||
<levelcontrol>
|
||||
<level>255</level>
|
||||
<levelpercentage>100</levelpercentage>
|
||||
</levelcontrol>
|
||||
<etsiunitinfo>
|
||||
<etsideviceid>20029</etsideviceid>
|
||||
<unittype>265</unittype>
|
||||
<interfaces>512,513</interfaces>
|
||||
</etsiunitinfo>
|
||||
</device>\
|
||||
</devicelist>\
|
||||
""";
|
||||
//@formatter:on
|
||||
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
|
||||
@ -122,7 +140,7 @@ public class AVMFritzDeviceListModelTest {
|
||||
@Test
|
||||
public void validateDeviceListModel() {
|
||||
assertNotNull(devices);
|
||||
assertEquals(17, devices.getDevicelist().size());
|
||||
assertEquals(18, devices.getDevicelist().size());
|
||||
assertEquals("1", devices.getXmlApiVersion());
|
||||
}
|
||||
|
||||
@ -732,6 +750,57 @@ public class AVMFritzDeviceListModelTest {
|
||||
assertEquals(2700, colorModel.temperature);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateHANFUNDimmableLightModel() {
|
||||
Optional<AVMFritzBaseModel> optionalDevice = findModelByIdentifier("Z001788011D4B55D30B");
|
||||
assertTrue(optionalDevice.isPresent());
|
||||
assertTrue(optionalDevice.get() instanceof DeviceModel);
|
||||
|
||||
DeviceModel device = (DeviceModel) optionalDevice.get();
|
||||
assertEquals("Signify Netherlands B.V. LWG004", device.getProductName());
|
||||
assertEquals("Z001788011D4B55D30B", device.getIdentifier());
|
||||
assertEquals("2038", device.getDeviceId());
|
||||
assertEquals("0.0", device.getFirmwareVersion());
|
||||
assertEquals("0x100b", device.getManufacturer());
|
||||
|
||||
assertEquals(1, device.getPresent());
|
||||
assertEquals("Zigbee dimmable bulb", 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());
|
||||
assertFalse(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(255L), levelcontrol.getLevel());
|
||||
assertEquals(BigDecimal.valueOf(100L), levelcontrol.getLevelPercentage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateHANFUNOnOffModel() {
|
||||
Optional<AVMFritzBaseModel> optionalDevice = findModelByIdentifier("113240824499-1");
|
||||
|
Loading…
Reference in New Issue
Block a user