diff --git a/bundles/org.openhab.binding.dali/src/main/java/org/openhab/binding/dali/internal/handler/DaliDt8DeviceHandler.java b/bundles/org.openhab.binding.dali/src/main/java/org/openhab/binding/dali/internal/handler/DaliDt8DeviceHandler.java index 5fa63001cb4cf..c0b17d1c4e9a0 100644 --- a/bundles/org.openhab.binding.dali/src/main/java/org/openhab/binding/dali/internal/handler/DaliDt8DeviceHandler.java +++ b/bundles/org.openhab.binding.dali/src/main/java/org/openhab/binding/dali/internal/handler/DaliDt8DeviceHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2023 Contributors to the openHAB project + * Copyright (c) 2010-2022 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. @@ -65,18 +65,18 @@ public void handleCommand(ChannelUID channelUID, Command command) { throw new DaliException("unknown device type"); } int mirek; - if (command instanceof DecimalType decimalCommand) { + if (command instanceof DecimalType) { // Color temperature in DALI is represented in mirek ("reciprocal megakelvin") // It is one million times the reciprocal of the color temperature (in Kelvin) - mirek = (int) (1E6f / (Math.min(Math.max(decimalCommand.intValue(), 1000), 20000))); - } else if (command instanceof QuantityType quantityCommand) { + mirek = (int) (1E6f / (Math.min(Math.max(((DecimalType) command).intValue(), 1000), 20000))); + } else if (command instanceof QuantityType) { // ensure it's in the correct units - QuantityType commandQuantity = quantityCommand.toInvertibleUnit(Units.MIRED); + QuantityType commandQuantity = ((QuantityType) command).toInvertibleUnit(Units.MIRED); if (commandQuantity == null) { logger.warn("Unable to convert command {} to mireks", command); return; } - mirek = commandQuantity.intValue(); + mirek = commandQuantity.toBigDecimal().intValue(); } else { logger.warn("Unable to convert command {} to mireks", command); return; @@ -124,6 +124,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { logger.warn("Error querying device status: {}", e.getMessage()); return null; }); + } else if (CHANNEL_COLOR.equals(channelUID.getId())) { DaliAddress address; if (THING_TYPE_DEVICE_DT8.equals(this.thing.getThingTypeUID())) { @@ -133,8 +134,8 @@ public void handleCommand(ChannelUID channelUID, Command command) { } else { throw new DaliException("unknown device type"); } - if (command instanceof HSBType hsbCommand) { - PercentType[] rgb = hsbCommand.toRGB(); + if (command instanceof HSBType) { + PercentType[] rgb = ((HSBType) command).toRGB(); final int r = (int) (254 * (rgb[0].floatValue() / 100)); final int g = (int) (254 * (rgb[1].floatValue() / 100)); final int b = (int) (254 * (rgb[2].floatValue() / 100)); @@ -188,6 +189,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { logger.warn("Error querying device status: {}", e.getMessage()); return null; }); + } else { super.handleCommand(channelUID, command); }