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 @@ - +