From 01a607ac5fd1d78dbde98496248e63d79751f940 Mon Sep 17 00:00:00 2001 From: Christian Oeing Date: Wed, 18 Nov 2020 11:09:04 +0100 Subject: [PATCH] #14 Change type of channel values from DecimalType to QuantityType in BoschTwinguardHandler Signed-off-by: Christian Oeing --- .../devices/twinguard/BoschTwinguardHandler.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/twinguard/BoschTwinguardHandler.java b/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/twinguard/BoschTwinguardHandler.java index 8b4c5f2d8efb6..d3d511071a483 100644 --- a/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/twinguard/BoschTwinguardHandler.java +++ b/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/devices/twinguard/BoschTwinguardHandler.java @@ -14,11 +14,15 @@ import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.*; +import javax.measure.quantity.Dimensionless; +import javax.measure.quantity.Temperature; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.boschshc.internal.devices.BoschSHCHandler; import org.openhab.binding.boschshc.internal.devices.twinguard.dto.AirQualityLevelState; -import org.openhab.core.library.types.DecimalType; +import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; +import org.openhab.core.library.unit.SIUnits; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; @@ -30,6 +34,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonSyntaxException; +import tec.uom.se.AbstractUnit; + /** * The {@link BoschSHCHandler} is responsible for handling commands for the TwinGuard handler. * @@ -61,11 +67,11 @@ public void handleCommand(ChannelUID channelUID, Command command) { } void updateAirQualityState(AirQualityLevelState state) { - updateState(CHANNEL_TEMPERATURE, new DecimalType(state.temperature)); + updateState(CHANNEL_TEMPERATURE, new QuantityType(state.temperature, SIUnits.CELSIUS)); updateState(CHANNEL_TEMPERATURE_RATING, new StringType(state.temperatureRating)); - updateState(CHANNEL_HUMIDITY, new DecimalType(state.humidity)); + updateState(CHANNEL_HUMIDITY, new QuantityType(state.humidity, AbstractUnit.ONE)); updateState(CHANNEL_HUMIDITY_RATING, new StringType(state.humidityRating)); - updateState(CHANNEL_PURITY, new DecimalType(state.purity)); + updateState(CHANNEL_PURITY, new QuantityType(state.purity, AbstractUnit.ONE)); updateState(CHANNEL_AIR_DESCRIPTION, new StringType(state.description)); updateState(CHANNEL_PURITY_RATING, new StringType(state.purityRating)); updateState(CHANNEL_COMBINED_RATING, new StringType(state.combinedRating));