Skip to content

Commit

Permalink
openhab#14 Change type of channel values from DecimalType to Quantity…
Browse files Browse the repository at this point in the history
…Type in BoschTwinguardHandler

Signed-off-by: Christian Oeing <[email protected]>
  • Loading branch information
coeing committed Nov 18, 2020
1 parent c879e86 commit 01a607a
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*
Expand Down Expand Up @@ -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<Temperature>(state.temperature, SIUnits.CELSIUS));
updateState(CHANNEL_TEMPERATURE_RATING, new StringType(state.temperatureRating));
updateState(CHANNEL_HUMIDITY, new DecimalType(state.humidity));
updateState(CHANNEL_HUMIDITY, new QuantityType<Dimensionless>(state.humidity, AbstractUnit.ONE));
updateState(CHANNEL_HUMIDITY_RATING, new StringType(state.humidityRating));
updateState(CHANNEL_PURITY, new DecimalType(state.purity));
updateState(CHANNEL_PURITY, new QuantityType<Dimensionless>(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));
Expand Down

0 comments on commit 01a607a

Please sign in to comment.