From 9565894181c0b7261a7469c325027347a75f00b9 Mon Sep 17 00:00:00 2001 From: Benjamin Hahn Date: Fri, 12 Jun 2020 02:33:37 +0200 Subject: [PATCH 01/17] Add property for ct colormode upper and lower limit Signed-off-by: Benajmin Hahn --- .../deconz/internal/BindingConstants.java | 3 +++ .../discovery/ThingDiscoveryService.java | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java index 76f761456bbbe..642516724d4ef 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java @@ -107,4 +107,7 @@ public class BindingConstants { public static final String CONFIG_APIKEY = "apikey"; public static final String UNIQUE_ID = "uid"; + + public static final String PROPERTY_CT_MIN = "ctmin"; + public static final String PROPERTY_CT_MAX = "ctmax"; } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index d275f7955da84..1f609b552dbf0 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -14,6 +14,8 @@ import static org.openhab.binding.deconz.internal.BindingConstants.*; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -109,11 +111,17 @@ private void addLight(String lightID, LightMessage light) { return; } + Map properties = new HashMap<>(); if (light.uniqueid.isEmpty()) { logger.warn("No unique id reported for light {} ({})", light.modelid, light.name); return; } + if (light.ctmax != null) + properties.put(PROPERTY_CT_MAX, Integer.toString(light.ctmax)); + if (light.ctmin != null) + properties.put(PROPERTY_CT_MIN, Integer.toString(light.ctmin)); + switch (lightType) { case ON_OFF_LIGHT: case ON_OFF_PLUGIN_UNIT: @@ -147,8 +155,12 @@ private void addLight(String lightID, LightMessage light) { ThingUID uid = new ThingUID(thingTypeUID, bridgeUID, light.uniqueid.replaceAll("[^a-z0-9\\[\\]]", "")); DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(uid).withBridge(bridgeUID) - .withLabel(light.name + " (" + light.manufacturername + ")").withProperty("id", lightID) - .withProperty(UNIQUE_ID, light.uniqueid).withRepresentationProperty(UNIQUE_ID).build(); + .withLabel(light.name + " (" + light.manufacturername + ")") + .withProperty("id", lightID) + .withProperty(UNIQUE_ID, light.uniqueid) + .withProperties(properties) + .withRepresentationProperty(UNIQUE_ID) + .build(); thingDiscovered(discoveryResult); } From 6ce0cc84cd3eddf385137a16a187a58caa37fc1d Mon Sep 17 00:00:00 2001 From: Benjamin Hahn Date: Fri, 12 Jun 2020 02:36:37 +0200 Subject: [PATCH 02/17] Expose generic bulb information as properties Signed-off-by: Benajmin Hahn --- .../deconz/internal/discovery/ThingDiscoveryService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index 1f609b552dbf0..637b6d027a39a 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -28,6 +28,7 @@ import org.eclipse.smarthome.config.discovery.DiscoveryResult; import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder; import org.eclipse.smarthome.config.discovery.DiscoveryService; +import org.eclipse.smarthome.core.thing.Thing; import org.eclipse.smarthome.core.thing.ThingTypeUID; import org.eclipse.smarthome.core.thing.ThingUID; import org.eclipse.smarthome.core.thing.binding.ThingHandler; @@ -112,10 +113,9 @@ private void addLight(String lightID, LightMessage light) { } Map properties = new HashMap<>(); - if (light.uniqueid.isEmpty()) { - logger.warn("No unique id reported for light {} ({})", light.modelid, light.name); - return; - } + properties.put(Thing.PROPERTY_FIRMWARE_VERSION, light.swversion); + properties.put(Thing.PROPERTY_VENDOR, light.manufacturername); + properties.put(Thing.PROPERTY_MODEL_ID, light.modelid); if (light.ctmax != null) properties.put(PROPERTY_CT_MAX, Integer.toString(light.ctmax)); From 937d3ad862092dd6948b123e85545fbacb9ce56d Mon Sep 17 00:00:00 2001 From: Benjamin Hahn Date: Fri, 12 Jun 2020 02:44:23 +0200 Subject: [PATCH 03/17] Adjust scaling of color temp range to bulb limits Signed-off-by: Benajmin Hahn --- .../deconz/internal/handler/LightThingHandler.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index ca1fdba4b1d87..dfeaf96a293eb 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -19,6 +19,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.commons.lang.math.NumberUtils; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.smarthome.core.library.types.DecimalType; @@ -78,8 +79,13 @@ public class LightThingHandler extends DeconzBaseThingHandler { private LightState lightStateCache = new LightState(); private LightState lastCommand = new LightState(); + private final int CT_MAX; + private final int CT_MIN; + public LightThingHandler(Thing thing, Gson gson) { super(thing, gson); + CT_MAX = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MAX), 500); + CT_MIN = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MIN), 153); } @Override @@ -315,12 +321,12 @@ public void messageReceived(String sensorID, DeconzBaseMessage message) { } } - private int unscaleColorTemperature(double ct) { - return (int) (ct / 100.0 * (500 - 153) + 153); + private int unscaleColorTemperature(final double ct) { + return (int) (ct / 100.0 * (CT_MAX - CT_MIN) + CT_MIN); } - private double scaleColorTemperature(int ct) { - return 100.0 * (ct - 153) / (500 - 153); + private double scaleColorTemperature (final int ct) { + return 100.0 * (ct - CT_MIN) / (CT_MAX - CT_MIN); } private PercentType toPercentType(int val) { From dd93435e53595e23a5a44b08219a4608c0b8e052 Mon Sep 17 00:00:00 2001 From: Benjamin Hahn Date: Fri, 12 Jun 2020 02:46:20 +0200 Subject: [PATCH 04/17] Adjust indention Signed-off-by: Benajmin Hahn --- .../deconz/internal/discovery/ThingDiscoveryService.java | 3 ++- .../deconz/internal/handler/LightThingHandler.java | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index 637b6d027a39a..543a851f424fa 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -53,7 +53,8 @@ @NonNullByDefault public class ThingDiscoveryService extends AbstractDiscoveryService implements DiscoveryService, ThingHandlerService { private static final Set SUPPORTED_THING_TYPES_UIDS = Stream - .of(LightThingHandler.SUPPORTED_THING_TYPE_UIDS, SensorThingHandler.SUPPORTED_THING_TYPES, + .of(LightThingHandler.SUPPORTED_THING_TYPE_UIDS, + SensorThingHandler.SUPPORTED_THING_TYPES, SensorThermostatThingHandler.SUPPORTED_THING_TYPES) .flatMap(Set::stream).collect(Collectors.toSet()); private final Logger logger = LoggerFactory.getLogger(ThingDiscoveryService.class); diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index dfeaf96a293eb..8e103df68c5fd 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -61,8 +61,12 @@ @NonNullByDefault public class LightThingHandler extends DeconzBaseThingHandler { public static final Set SUPPORTED_THING_TYPE_UIDS = Stream - .of(THING_TYPE_COLOR_TEMPERATURE_LIGHT, THING_TYPE_DIMMABLE_LIGHT, THING_TYPE_COLOR_LIGHT, - THING_TYPE_EXTENDED_COLOR_LIGHT, THING_TYPE_ONOFF_LIGHT, THING_TYPE_WINDOW_COVERING) + .of(THING_TYPE_COLOR_TEMPERATURE_LIGHT, + THING_TYPE_DIMMABLE_LIGHT, + THING_TYPE_COLOR_LIGHT, + THING_TYPE_EXTENDED_COLOR_LIGHT, + THING_TYPE_ONOFF_LIGHT, + THING_TYPE_WINDOW_COVERING) .collect(Collectors.toSet()); private static final double HUE_FACTOR = 65535 / 360.0; From 14bcfef1d78d4a80c647b18945e3cd1f6ba47baf Mon Sep 17 00:00:00 2001 From: Benjamin Hahn Date: Fri, 12 Jun 2020 02:47:35 +0200 Subject: [PATCH 05/17] Add support for IKEA CWS bulb Signed-off-by: Benajmin Hahn --- .../discovery/ThingDiscoveryService.java | 3 +++ .../internal/handler/LightThingHandler.java | 18 +++++++++--------- .../deconz/internal/types/LightType.java | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index 543a851f424fa..6c17917758a49 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -138,6 +138,9 @@ private void addLight(String lightID, LightMessage light) { case COLOR_DIMMABLE_LIGHT: thingTypeUID = THING_TYPE_COLOR_LIGHT; break; + case COLOR_LIGHT: + thingTypeUID = (light.ctmin != null) ?THING_TYPE_EXTENDED_COLOR_LIGHT :THING_TYPE_COLOR_LIGHT; + break; case EXTENDED_COLOR_LIGHT: thingTypeUID = THING_TYPE_EXTENDED_COLOR_LIGHT; break; diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index 8e103df68c5fd..b858b9b0c0359 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -273,16 +273,16 @@ private void valueUpdated(String channelId, LightState newState) { case CHANNEL_COLOR: if (on != null && on == false) { updateState(channelId, OnOffType.OFF); - } else { - double @Nullable [] xy = newState.xy; - Integer hue = newState.hue; - Integer sat = newState.sat; - if (hue != null && sat != null && bri != null) { - updateState(channelId, - new HSBType(new DecimalType(hue / HUE_FACTOR), toPercentType(sat), toPercentType(bri))); - } else if (xy != null && xy.length == 2) { - updateState(channelId, HSBType.fromXY((float) xy[0], (float) xy[1])); + } else if (bri != null && newState.colormode != null && newState.colormode.equals("xy")) { + final double @Nullable [] xy = newState.xy; + if (xy != null && xy.length == 2) { + HSBType color = HSBType.fromXY((float) xy[0], (float) xy[1]); + updateState(channelId, new HSBType(color.getHue(), color.getSaturation(), toPercentType(bri))); } + } else if (bri != null && newState.hue != null && newState.sat != null) { + final Integer hue = newState.hue; + final Integer sat = newState.sat; + updateState(channelId, new HSBType(new DecimalType(hue / HUE_FACTOR), toPercentType(sat), toPercentType(bri))); } break; case CHANNEL_BRIGHTNESS: diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java index 3d979ef6fd143..578e069c0784b 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java @@ -30,6 +30,7 @@ public enum LightType { ON_OFF_LIGHT("On/Off light"), ON_OFF_PLUGIN_UNIT("On/Off plug-in unit"), EXTENDED_COLOR_LIGHT("Extended color light"), + COLOR_LIGHT("Color light"), COLOR_DIMMABLE_LIGHT("Color dimmable light"), COLOR_TEMPERATURE_LIGHT("Color temperature light"), DIMMABLE_LIGHT("Dimmable light"), From 0879f4dd89c61cd1a77fd33b2f1badadbd8b0829 Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Tue, 16 Jun 2020 00:23:53 +0200 Subject: [PATCH 06/17] Apply codestyle Signed-off-by: Benajmin Hahn --- .../deconz/internal/handler/LightThingHandler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index b858b9b0c0359..ef269825e1900 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -83,13 +83,13 @@ public class LightThingHandler extends DeconzBaseThingHandler { private LightState lightStateCache = new LightState(); private LightState lastCommand = new LightState(); - private final int CT_MAX; - private final int CT_MIN; + private final int ct_max; + private final int ct_min; public LightThingHandler(Thing thing, Gson gson) { super(thing, gson); - CT_MAX = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MAX), 500); - CT_MIN = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MIN), 153); + ct_max = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MAX), 500); + ct_min = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MIN), 153); } @Override @@ -326,11 +326,11 @@ public void messageReceived(String sensorID, DeconzBaseMessage message) { } private int unscaleColorTemperature(final double ct) { - return (int) (ct / 100.0 * (CT_MAX - CT_MIN) + CT_MIN); + return (int) (ct / 100.0 * (ct_max - ct_min) + ct_min); } private double scaleColorTemperature (final int ct) { - return 100.0 * (ct - CT_MIN) / (CT_MAX - CT_MIN); + return 100.0 * (ct - ct_min) / (ct_max - ct_min); } private PercentType toPercentType(int val) { From 0d8942cf7c322d700c0a253a00e2246fcf659b38 Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Tue, 16 Jun 2020 00:34:08 +0200 Subject: [PATCH 07/17] Consolidate property handling Signed-off-by: Benajmin Hahn --- .../deconz/internal/discovery/ThingDiscoveryService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index 6c17917758a49..998373595ff31 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -114,14 +114,17 @@ private void addLight(String lightID, LightMessage light) { } Map properties = new HashMap<>(); + properties.put("id", lightType); + properties.put(UNIQUE_ID, light.uniqueid); + properties.put(Thing.PROPERTY_FIRMWARE_VERSION, light.swversion); properties.put(Thing.PROPERTY_FIRMWARE_VERSION, light.swversion); properties.put(Thing.PROPERTY_VENDOR, light.manufacturername); properties.put(Thing.PROPERTY_MODEL_ID, light.modelid); - if (light.ctmax != null) + if (light.ctmax != null && light.ctmin != null) { properties.put(PROPERTY_CT_MAX, Integer.toString(light.ctmax)); - if (light.ctmin != null) properties.put(PROPERTY_CT_MIN, Integer.toString(light.ctmin)); + } switch (lightType) { case ON_OFF_LIGHT: @@ -160,8 +163,6 @@ private void addLight(String lightID, LightMessage light) { ThingUID uid = new ThingUID(thingTypeUID, bridgeUID, light.uniqueid.replaceAll("[^a-z0-9\\[\\]]", "")); DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(uid).withBridge(bridgeUID) .withLabel(light.name + " (" + light.manufacturername + ")") - .withProperty("id", lightID) - .withProperty(UNIQUE_ID, light.uniqueid) .withProperties(properties) .withRepresentationProperty(UNIQUE_ID) .build(); From 54e063b1f1b7286d53a6f1ce0b0384ee616515ab Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Tue, 16 Jun 2020 00:37:49 +0200 Subject: [PATCH 08/17] Apply correct type for "Color lights" Signed-off-by: Benajmin Hahn --- .../deconz/internal/discovery/ThingDiscoveryService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index 998373595ff31..84c9f0cef640b 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -139,11 +139,9 @@ private void addLight(String lightID, LightMessage light) { thingTypeUID = THING_TYPE_COLOR_TEMPERATURE_LIGHT; break; case COLOR_DIMMABLE_LIGHT: - thingTypeUID = THING_TYPE_COLOR_LIGHT; - break; case COLOR_LIGHT: - thingTypeUID = (light.ctmin != null) ?THING_TYPE_EXTENDED_COLOR_LIGHT :THING_TYPE_COLOR_LIGHT; - break; + thingTypeUID = THING_TYPE_COLOR_LIGHT; + break; case EXTENDED_COLOR_LIGHT: thingTypeUID = THING_TYPE_EXTENDED_COLOR_LIGHT; break; From f4b62c05f7c0e92a4840be461d207c2d9f6db88f Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Wed, 17 Jun 2020 21:53:56 +0200 Subject: [PATCH 09/17] Define CT Constants according to ZCL Spec See ZigBee Cluster Library Specification Page 5-5 - 327 Signed-off-by: Benajmin Hahn --- .../openhab/binding/deconz/internal/BindingConstants.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java index 642516724d4ef..7a1e8135a6c46 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java @@ -110,4 +110,10 @@ public class BindingConstants { public static final String PROPERTY_CT_MIN = "ctmin"; public static final String PROPERTY_CT_MAX = "ctmax"; + + // CT value range according to ZCL Spec + public static final int ZCL_CT_UNDEFINED = 0; // 0x0000 + public static final int ZCL_CT_MIN = 1; + public static final int ZCL_CT_MAX = 65279; // 0xFEFF + public static final int ZCL_CT_INVALID = 65535; //0xFFFF } From 393905b8121fda883c8e2ce49f3a50c1a22a2103 Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Thu, 18 Jun 2020 01:17:29 +0200 Subject: [PATCH 10/17] Fix property handling Signed-off-by: Benajmin Hahn --- .../internal/discovery/ThingDiscoveryService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index 84c9f0cef640b..1ad274c3ee113 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -114,16 +114,18 @@ private void addLight(String lightID, LightMessage light) { } Map properties = new HashMap<>(); - properties.put("id", lightType); + properties.put("id", lightID); properties.put(UNIQUE_ID, light.uniqueid); properties.put(Thing.PROPERTY_FIRMWARE_VERSION, light.swversion); - properties.put(Thing.PROPERTY_FIRMWARE_VERSION, light.swversion); properties.put(Thing.PROPERTY_VENDOR, light.manufacturername); properties.put(Thing.PROPERTY_MODEL_ID, light.modelid); if (light.ctmax != null && light.ctmin != null) { - properties.put(PROPERTY_CT_MAX, Integer.toString(light.ctmax)); - properties.put(PROPERTY_CT_MIN, Integer.toString(light.ctmin)); + int ctmax = (light.ctmax > ZCL_CT_MAX) ? ZCL_CT_MAX : light.ctmax; + properties.put(PROPERTY_CT_MAX, Integer.toString(ctmax)); + + int ctmin = (light.ctmin < ZCL_CT_MIN) ? ZCL_CT_MIN : light.ctmin; + properties.put(PROPERTY_CT_MIN, Integer.toString(ctmin)); } switch (lightType) { @@ -141,7 +143,7 @@ private void addLight(String lightID, LightMessage light) { case COLOR_DIMMABLE_LIGHT: case COLOR_LIGHT: thingTypeUID = THING_TYPE_COLOR_LIGHT; - break; + break; case EXTENDED_COLOR_LIGHT: thingTypeUID = THING_TYPE_EXTENDED_COLOR_LIGHT; break; From c869c4167ec5fc848734a91b064d3e5fa9ffe9ce Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Thu, 18 Jun 2020 01:20:53 +0200 Subject: [PATCH 11/17] Use Kelvin for color temperature channel Signed-off-by: Benajmin Hahn --- .../openhab/binding/deconz/internal/Util.java | 12 +++++++++++ .../internal/handler/LightThingHandler.java | 20 +++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/Util.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/Util.java index f087470cb5cbf..ecf5508e0f87a 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/Util.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/Util.java @@ -35,4 +35,16 @@ public static String buildUrl(String host, int port, String... urlParts) { return url.toString(); } + + public static int miredToKelvin(int miredValue) { + return (int) (1000000.0 / miredValue); + } + + public static int kelvinToMired(int kelvinValue) { + return (int) (1000000.0 / kelvinValue); + } + + public static int constrainToRange(int intValue, int min, int max) { + return Math.max(min, Math.min(intValue, max)); + } } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index ef269825e1900..8a2acc23ff279 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -13,7 +13,7 @@ package org.openhab.binding.deconz.internal.handler; import static org.openhab.binding.deconz.internal.BindingConstants.*; -import static org.openhab.binding.deconz.internal.Util.buildUrl; +import static org.openhab.binding.deconz.internal.Util.*; import java.util.Set; import java.util.stream.Collectors; @@ -88,8 +88,8 @@ public class LightThingHandler extends DeconzBaseThingHandler { public LightThingHandler(Thing thing, Gson gson) { super(thing, gson); - ct_max = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MAX), 500); - ct_min = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MIN), 153); + ct_max = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MAX), ZCL_CT_MAX); + ct_min = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MIN), ZCL_CT_MIN); } @Override @@ -179,7 +179,8 @@ public void handleCommand(ChannelUID channelUID, Command command) { break; case CHANNEL_COLOR_TEMPERATURE: if (command instanceof DecimalType) { - newLightState.ct = unscaleColorTemperature(((DecimalType) command).doubleValue()); + int miredValue = kelvinToMired(((DecimalType) command).intValue()); + newLightState.ct = constrainToRange(miredValue,ct_min, ct_max); if (currentOn != null && !currentOn) { // sending new color temperature is only allowed when light is on @@ -294,8 +295,8 @@ private void valueUpdated(String channelId, LightState newState) { break; case CHANNEL_COLOR_TEMPERATURE: Integer ct = newState.ct; - if (ct != null) { - updateState(channelId, new DecimalType(scaleColorTemperature(ct))); + if (ct != null && ct >= ct_min && ct <= ct_max) { + updateState(channelId, new DecimalType(miredToKelvin(ct))); } break; case CHANNEL_POSITION: @@ -325,13 +326,6 @@ public void messageReceived(String sensorID, DeconzBaseMessage message) { } } - private int unscaleColorTemperature(final double ct) { - return (int) (ct / 100.0 * (ct_max - ct_min) + ct_min); - } - - private double scaleColorTemperature (final int ct) { - return 100.0 * (ct - ct_min) / (ct_max - ct_min); - } private PercentType toPercentType(int val) { int scaledValue = (int) Math.ceil(val / BRIGHTNESS_FACTOR); From 902ddc392d4d505dce72f145b8a36899266684ca Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Thu, 18 Jun 2020 01:22:26 +0200 Subject: [PATCH 12/17] Adjust thing type limits Signed-off-by: Benajmin Hahn --- .../src/main/resources/ESH-INF/thing/light-thing-types.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/light-thing-types.xml b/bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/light-thing-types.xml index 4aa8cba1d0206..6d4005e2687cf 100644 --- a/bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/light-thing-types.xml +++ b/bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/light-thing-types.xml @@ -121,7 +121,7 @@ Number - + From e64256c9543df13b6f08311c49fcab3f9cd54e20 Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Thu, 18 Jun 2020 01:24:20 +0200 Subject: [PATCH 13/17] Fix tests for CT value in kelvin Signed-off-by: Benajmin Hahn --- .../src/test/java/org/openhab/binding/deconz/LightsTest.java | 2 +- .../resources/org/openhab/binding/deconz/colortemperature.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/test/java/org/openhab/binding/deconz/LightsTest.java b/bundles/org.openhab.binding.deconz/src/test/java/org/openhab/binding/deconz/LightsTest.java index 57657cc144bc4..0366f51c4f271 100644 --- a/bundles/org.openhab.binding.deconz/src/test/java/org/openhab/binding/deconz/LightsTest.java +++ b/bundles/org.openhab.binding.deconz/src/test/java/org/openhab/binding/deconz/LightsTest.java @@ -81,7 +81,7 @@ public void colorTemperatureLightUpdateTest() throws IOException { lightThingHandler.messageReceived("", lightMessage); Mockito.verify(thingHandlerCallback).stateUpdated(eq(channelUID_bri), eq(new PercentType("21"))); - Mockito.verify(thingHandlerCallback).stateUpdated(eq(channelUID_ct), eq(new DecimalType("87.03170028818444"))); + Mockito.verify(thingHandlerCallback).stateUpdated(eq(channelUID_ct), eq(new DecimalType("2500"))); } @Test diff --git a/bundles/org.openhab.binding.deconz/src/test/resources/org/openhab/binding/deconz/colortemperature.json b/bundles/org.openhab.binding.deconz/src/test/resources/org/openhab/binding/deconz/colortemperature.json index 0af4a94c5ca0c..0e690d172dc0f 100644 --- a/bundles/org.openhab.binding.deconz/src/test/resources/org/openhab/binding/deconz/colortemperature.json +++ b/bundles/org.openhab.binding.deconz/src/test/resources/org/openhab/binding/deconz/colortemperature.json @@ -6,7 +6,7 @@ "alert": null, "bri": 51, "colormode": "ct", - "ct": 455, + "ct": 400, "on": true, "reachable": true }, From 7797697deef693362a5d333ea633dccfe6da57b5 Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Thu, 18 Jun 2020 01:35:32 +0200 Subject: [PATCH 14/17] Apply spotless fixes Signed-off-by: Benajmin Hahn --- .../binding/deconz/internal/BindingConstants.java | 2 +- .../internal/discovery/ThingDiscoveryService.java | 11 ++++------- .../deconz/internal/handler/LightThingHandler.java | 14 +++++--------- .../internal/handler/SensorThingHandler.java | 1 - .../types/ThermostatModeGsonTypeAdapter.java | 1 - .../resources/ESH-INF/thing/sensor-thing-types.xml | 2 +- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java index 7a1e8135a6c46..85df47e81470d 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java @@ -115,5 +115,5 @@ public class BindingConstants { public static final int ZCL_CT_UNDEFINED = 0; // 0x0000 public static final int ZCL_CT_MIN = 1; public static final int ZCL_CT_MAX = 65279; // 0xFEFF - public static final int ZCL_CT_INVALID = 65535; //0xFFFF + public static final int ZCL_CT_INVALID = 65535; // 0xFFFF } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index 1ad274c3ee113..4fbcfc18fdeca 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -53,8 +53,7 @@ @NonNullByDefault public class ThingDiscoveryService extends AbstractDiscoveryService implements DiscoveryService, ThingHandlerService { private static final Set SUPPORTED_THING_TYPES_UIDS = Stream - .of(LightThingHandler.SUPPORTED_THING_TYPE_UIDS, - SensorThingHandler.SUPPORTED_THING_TYPES, + .of(LightThingHandler.SUPPORTED_THING_TYPE_UIDS, SensorThingHandler.SUPPORTED_THING_TYPES, SensorThermostatThingHandler.SUPPORTED_THING_TYPES) .flatMap(Set::stream).collect(Collectors.toSet()); private final Logger logger = LoggerFactory.getLogger(ThingDiscoveryService.class); @@ -123,7 +122,7 @@ private void addLight(String lightID, LightMessage light) { if (light.ctmax != null && light.ctmin != null) { int ctmax = (light.ctmax > ZCL_CT_MAX) ? ZCL_CT_MAX : light.ctmax; properties.put(PROPERTY_CT_MAX, Integer.toString(ctmax)); - + int ctmin = (light.ctmin < ZCL_CT_MIN) ? ZCL_CT_MIN : light.ctmin; properties.put(PROPERTY_CT_MIN, Integer.toString(ctmin)); } @@ -162,10 +161,8 @@ private void addLight(String lightID, LightMessage light) { ThingUID uid = new ThingUID(thingTypeUID, bridgeUID, light.uniqueid.replaceAll("[^a-z0-9\\[\\]]", "")); DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(uid).withBridge(bridgeUID) - .withLabel(light.name + " (" + light.manufacturername + ")") - .withProperties(properties) - .withRepresentationProperty(UNIQUE_ID) - .build(); + .withLabel(light.name + " (" + light.manufacturername + ")").withProperties(properties) + .withRepresentationProperty(UNIQUE_ID).build(); thingDiscovered(discoveryResult); } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index 8a2acc23ff279..a692a91a7f451 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -61,12 +61,8 @@ @NonNullByDefault public class LightThingHandler extends DeconzBaseThingHandler { public static final Set SUPPORTED_THING_TYPE_UIDS = Stream - .of(THING_TYPE_COLOR_TEMPERATURE_LIGHT, - THING_TYPE_DIMMABLE_LIGHT, - THING_TYPE_COLOR_LIGHT, - THING_TYPE_EXTENDED_COLOR_LIGHT, - THING_TYPE_ONOFF_LIGHT, - THING_TYPE_WINDOW_COVERING) + .of(THING_TYPE_COLOR_TEMPERATURE_LIGHT, THING_TYPE_DIMMABLE_LIGHT, THING_TYPE_COLOR_LIGHT, + THING_TYPE_EXTENDED_COLOR_LIGHT, THING_TYPE_ONOFF_LIGHT, THING_TYPE_WINDOW_COVERING) .collect(Collectors.toSet()); private static final double HUE_FACTOR = 65535 / 360.0; @@ -280,10 +276,11 @@ private void valueUpdated(String channelId, LightState newState) { HSBType color = HSBType.fromXY((float) xy[0], (float) xy[1]); updateState(channelId, new HSBType(color.getHue(), color.getSaturation(), toPercentType(bri))); } - } else if (bri != null && newState.hue != null && newState.sat != null) { + } else if (bri != null && newState.hue != null && newState.sat != null) { final Integer hue = newState.hue; final Integer sat = newState.sat; - updateState(channelId, new HSBType(new DecimalType(hue / HUE_FACTOR), toPercentType(sat), toPercentType(bri))); + updateState(channelId, + new HSBType(new DecimalType(hue / HUE_FACTOR), toPercentType(sat), toPercentType(bri))); } break; case CHANNEL_BRIGHTNESS: @@ -326,7 +323,6 @@ public void messageReceived(String sensorID, DeconzBaseMessage message) { } } - private PercentType toPercentType(int val) { int scaledValue = (int) Math.ceil(val / BRIGHTNESS_FACTOR); if (scaledValue < 0 || scaledValue > 100) { diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThingHandler.java index 1f06155bbc6c4..bf3e1d00faafa 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThingHandler.java @@ -238,7 +238,6 @@ protected void createTypeSpecificChannels(SensorConfig sensorConfig, SensorState createChannel(CHANNEL_GESTURE, ChannelKind.STATE); createChannel(CHANNEL_GESTUREEVENT, ChannelKind.TRIGGER); } - } @Override diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/ThermostatModeGsonTypeAdapter.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/ThermostatModeGsonTypeAdapter.java index 2b727f2117cdc..652a2e13d751c 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/ThermostatModeGsonTypeAdapter.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/ThermostatModeGsonTypeAdapter.java @@ -48,6 +48,5 @@ public ThermostatMode deserialize(@Nullable JsonElement json, @Nullable Type typ public JsonElement serialize(ThermostatMode src, @Nullable Type typeOfSrc, @Nullable JsonSerializationContext context) throws JsonParseException { return src != ThermostatMode.UNKNOWN ? new JsonPrimitive(src.getDeconzValue()) : JsonNull.INSTANCE; - } } diff --git a/bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/sensor-thing-types.xml b/bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/sensor-thing-types.xml index 8c3ac5b38e3a7..5e049e650ddbd 100644 --- a/bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/sensor-thing-types.xml +++ b/bundles/org.openhab.binding.deconz/src/main/resources/ESH-INF/thing/sensor-thing-types.xml @@ -508,7 +508,7 @@ - + From 935e304b084391a1438880324f515f99e876788e Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Thu, 18 Jun 2020 01:46:14 +0200 Subject: [PATCH 15/17] Adjust documentation Signed-off-by: Benajmin Hahn --- bundles/org.openhab.binding.deconz/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index 26d27b74d31fe..40f354cc26055 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -147,7 +147,7 @@ Other devices support | brightness | Dimmer | R/W | Brightness of the light | `dimmablelight` | | switch | Switch | R/W | State of a ON/OFF device | `onofflight` | | color | Color | R/W | Color of an multi-color light | `colorlight`, `extendedcolorlight` | -| color_temperature | Number | R/W | `0`->`100` represents cold -> warm | `colortemperaturelight`, `extendedcolorlight` | +| color_temperature | Number | R/W | Color temperature in kelvin | `colortemperaturelight`, `extendedcolorlight` | | position | Rollershutter | R/W | Position of the blind | `windowcovering` | | heatsetpoint | Number:Temperature | R/W | Target Temperature in °C | `thermostat` | | valve | Number:Dimensionless | R | Valve position in % | `thermostat` | From 1a295433f45fc910c730958e5a2aef786f8da8d2 Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Thu, 18 Jun 2020 21:05:13 +0200 Subject: [PATCH 16/17] Update Readme Signed-off-by: Benajmin Hahn --- bundles/org.openhab.binding.deconz/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index 40f354cc26055..7546554cc5c88 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -147,7 +147,7 @@ Other devices support | brightness | Dimmer | R/W | Brightness of the light | `dimmablelight` | | switch | Switch | R/W | State of a ON/OFF device | `onofflight` | | color | Color | R/W | Color of an multi-color light | `colorlight`, `extendedcolorlight` | -| color_temperature | Number | R/W | Color temperature in kelvin | `colortemperaturelight`, `extendedcolorlight` | +| color_temperature | Number | R/W | Color temperature in kelvin. The value range is determined by each individual light | `colortemperaturelight`, `extendedcolorlight` | | position | Rollershutter | R/W | Position of the blind | `windowcovering` | | heatsetpoint | Number:Temperature | R/W | Target Temperature in °C | `thermostat` | | valve | Number:Dimensionless | R | Valve position in % | `thermostat` | From 774f750cc2f1fa1b85a944d9935f53bd496e3e97 Mon Sep 17 00:00:00 2001 From: Benajmin Hahn Date: Thu, 18 Jun 2020 21:30:01 +0200 Subject: [PATCH 17/17] Remove apache.commons dependency Signed-off-by: Benajmin Hahn --- .../org/openhab/binding/deconz/internal/Util.java | 11 +++++++++++ .../deconz/internal/handler/LightThingHandler.java | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/Util.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/Util.java index ecf5508e0f87a..b49b513995835 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/Util.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/Util.java @@ -47,4 +47,15 @@ public static int kelvinToMired(int kelvinValue) { public static int constrainToRange(int intValue, int min, int max) { return Math.max(min, Math.min(intValue, max)); } + + public static int parseIntWithFallback(String text, int defaultValue) { + if (text == null || text.isEmpty()) { + return defaultValue; + } + try { + return Integer.parseInt(text); + } catch (NumberFormatException e) { + return defaultValue; + } + } } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index a692a91a7f451..14dc8994d3d3a 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -19,7 +19,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.commons.lang.math.NumberUtils; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.smarthome.core.library.types.DecimalType; @@ -84,8 +83,8 @@ public class LightThingHandler extends DeconzBaseThingHandler { public LightThingHandler(Thing thing, Gson gson) { super(thing, gson); - ct_max = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MAX), ZCL_CT_MAX); - ct_min = NumberUtils.toInt(thing.getProperties().get(PROPERTY_CT_MIN), ZCL_CT_MIN); + ct_max = parseIntWithFallback(thing.getProperties().get(PROPERTY_CT_MAX), ZCL_CT_MAX); + ct_min = parseIntWithFallback(thing.getProperties().get(PROPERTY_CT_MIN), ZCL_CT_MIN); } @Override