Use core unit classes (#9261)
Add-ons should not depend on tec.uom.se classes but use core unit classes instead so they are less impacted when this library is replaced or upgraded. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
4fafb06251
commit
ac18da7fc3
|
@ -24,13 +24,12 @@ import org.openhab.core.library.types.DecimalType;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
import org.openhab.core.library.unit.ImperialUnits;
|
import org.openhab.core.library.unit.ImperialUnits;
|
||||||
import org.openhab.core.library.unit.SIUnits;
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
import org.openhab.core.types.UnDefType;
|
import org.openhab.core.types.UnDefType;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code Measure} class defines the dto for Smarther API measure object.
|
* The {@code Measure} class defines the dto for Smarther API measure object.
|
||||||
*
|
*
|
||||||
|
@ -101,7 +100,8 @@ public class Measure {
|
||||||
.orElse(UnDefType.UNDEF);
|
.orElse(UnDefType.UNDEF);
|
||||||
break;
|
break;
|
||||||
case PERCENTAGE:
|
case PERCENTAGE:
|
||||||
state = optValue.<State> map(t -> new QuantityType<Dimensionless>(new DecimalType(t), Units.PERCENT))
|
state = optValue
|
||||||
|
.<State> map(t -> new QuantityType<Dimensionless>(new DecimalType(t), SmartHomeUnits.PERCENT))
|
||||||
.orElse(UnDefType.UNDEF);
|
.orElse(UnDefType.UNDEF);
|
||||||
break;
|
break;
|
||||||
case DIMENSIONLESS:
|
case DIMENSIONLESS:
|
||||||
|
|
|
@ -21,11 +21,10 @@ import javax.measure.quantity.Dimensionless;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
import org.openhab.core.types.UnDefType;
|
import org.openhab.core.types.UnDefType;
|
||||||
|
|
||||||
import tec.uom.se.AbstractUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link CoronaStatsCountry} class holds the internal data representation of each Country
|
* The {@link CoronaStatsCountry} class holds the internal data representation of each Country
|
||||||
*
|
*
|
||||||
|
@ -59,7 +58,7 @@ public class CoronaStatsCases {
|
||||||
if (count == -1) {
|
if (count == -1) {
|
||||||
return UnDefType.NULL;
|
return UnDefType.NULL;
|
||||||
} else {
|
} else {
|
||||||
return new QuantityType<Dimensionless>(count, AbstractUnit.ONE);
|
return new QuantityType<Dimensionless>(count, SmartHomeUnits.ONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,13 @@ import org.openhab.core.library.types.DecimalType;
|
||||||
import org.openhab.core.library.types.IncreaseDecreaseType;
|
import org.openhab.core.library.types.IncreaseDecreaseType;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
import org.openhab.core.library.types.UpDownType;
|
import org.openhab.core.library.types.UpDownType;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
import org.openhab.core.types.StateDescriptionFragmentBuilder;
|
import org.openhab.core.types.StateDescriptionFragmentBuilder;
|
||||||
import org.openhab.core.types.UnDefType;
|
import org.openhab.core.types.UnDefType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import tec.uom.se.AbstractUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a number value.
|
* Implements a number value.
|
||||||
*
|
*
|
||||||
|
@ -111,7 +110,7 @@ public class NumberValue extends Value {
|
||||||
} else if (command instanceof QuantityType<?>) {
|
} else if (command instanceof QuantityType<?>) {
|
||||||
QuantityType<?> qType = (QuantityType<?>) command;
|
QuantityType<?> qType = (QuantityType<?>) command;
|
||||||
|
|
||||||
if (qType.getUnit().isCompatible(AbstractUnit.ONE)) {
|
if (qType.getUnit().isCompatible(SmartHomeUnits.ONE)) {
|
||||||
newValue = qType.toBigDecimal();
|
newValue = qType.toBigDecimal();
|
||||||
} else {
|
} else {
|
||||||
qType = qType.toUnit(unit);
|
qType = qType.toUnit(unit);
|
||||||
|
|
|
@ -27,12 +27,11 @@ import org.openhab.core.library.types.PercentType;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
import org.openhab.core.library.types.StringType;
|
import org.openhab.core.library.types.StringType;
|
||||||
import org.openhab.core.library.types.UpDownType;
|
import org.openhab.core.library.types.UpDownType;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
import org.openhab.core.types.StateDescriptionFragmentBuilder;
|
import org.openhab.core.types.StateDescriptionFragmentBuilder;
|
||||||
import org.openhab.core.types.UnDefType;
|
import org.openhab.core.types.UnDefType;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a percentage value. Minimum and maximum are definable.
|
* Implements a percentage value. Minimum and maximum are definable.
|
||||||
*
|
*
|
||||||
|
@ -88,7 +87,7 @@ public class PercentageValue extends Value {
|
||||||
} else //
|
} else //
|
||||||
// A quantity type need to be converted according to the current min/max values
|
// A quantity type need to be converted according to the current min/max values
|
||||||
if (command instanceof QuantityType) {
|
if (command instanceof QuantityType) {
|
||||||
QuantityType<?> qty = ((QuantityType<?>) command).toUnit(Units.PERCENT);
|
QuantityType<?> qty = ((QuantityType<?>) command).toUnit(SmartHomeUnits.PERCENT);
|
||||||
if (qty != null) {
|
if (qty != null) {
|
||||||
BigDecimal v = qty.toBigDecimal();
|
BigDecimal v = qty.toBigDecimal();
|
||||||
v = v.subtract(min).multiply(HUNDRED).divide(max.subtract(min), MathContext.DECIMAL128);
|
v = v.subtract(min).multiply(HUNDRED).divide(max.subtract(min), MathContext.DECIMAL128);
|
||||||
|
|
|
@ -29,8 +29,10 @@ import javax.measure.Unit;
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.neohub.internal.NeoHubAbstractDeviceData.AbstractRecord;
|
import org.openhab.binding.neohub.internal.NeoHubAbstractDeviceData.AbstractRecord;
|
||||||
|
import org.openhab.binding.neohub.internal.NeoHubBindingConstants.NeoHubReturnResult;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
import org.openhab.core.library.unit.SIUnits;
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.thing.Bridge;
|
import org.openhab.core.thing.Bridge;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -46,8 +48,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link NeoHubHandler} is the openHAB Handler for NeoHub devices
|
* The {@link NeoHubHandler} is the openHAB Handler for NeoHub devices
|
||||||
*
|
*
|
||||||
|
@ -369,7 +369,7 @@ public class NeoHubHandler extends BaseBridgeHandler {
|
||||||
onlineDeviceCount++;
|
onlineDeviceCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state = new QuantityType<>((100.0 * onlineDeviceCount) / totalDeviceCount, Units.PERCENT);
|
state = new QuantityType<>((100.0 * onlineDeviceCount) / totalDeviceCount, SmartHomeUnits.PERCENT);
|
||||||
}
|
}
|
||||||
updateState(CHAN_MESH_NETWORK_QOS, state);
|
updateState(CHAN_MESH_NETWORK_QOS, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.openhab.binding.opensprinkler.internal.api.exception.GeneralApiExcept
|
||||||
import org.openhab.binding.opensprinkler.internal.config.OpenSprinklerStationConfig;
|
import org.openhab.binding.opensprinkler.internal.config.OpenSprinklerStationConfig;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.thing.Channel;
|
import org.openhab.core.thing.Channel;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -37,8 +38,6 @@ import org.openhab.core.types.RefreshType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Florian Schmidt - Refactoring
|
* @author Florian Schmidt - Refactoring
|
||||||
*/
|
*/
|
||||||
|
@ -91,7 +90,7 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QuantityType<?> quantity = (QuantityType<?>) command;
|
QuantityType<?> quantity = (QuantityType<?>) command;
|
||||||
this.nextDurationTime = quantity.toUnit(Units.SECOND).toBigDecimal();
|
this.nextDurationTime = quantity.toUnit(SmartHomeUnits.SECOND).toBigDecimal();
|
||||||
updateState(channelUID, quantity);
|
updateState(channelUID, quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +182,7 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler {
|
||||||
+ " for the OpenSprinkler device. Exception received: " + exp);
|
+ " for the OpenSprinkler device. Exception received: " + exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QuantityType<>(remainingWaterTime, Units.SECOND);
|
return new QuantityType<>(remainingWaterTime, SmartHomeUnits.SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -204,7 +203,7 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler {
|
||||||
case NEXT_DURATION:
|
case NEXT_DURATION:
|
||||||
BigDecimal duration = nextDurationValue();
|
BigDecimal duration = nextDurationValue();
|
||||||
if (duration != null) {
|
if (duration != null) {
|
||||||
updateState(channel, new QuantityType<>(duration, Units.SECOND));
|
updateState(channel, new QuantityType<>(duration, SmartHomeUnits.SECOND));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATION_QUEUED:
|
case STATION_QUEUED:
|
||||||
|
|
|
@ -12,14 +12,7 @@
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.sensibo.internal.handler;
|
package org.openhab.binding.sensibo.internal.handler;
|
||||||
|
|
||||||
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.CHANNEL_CURRENT_HUMIDITY;
|
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.*;
|
||||||
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.CHANNEL_CURRENT_TEMPERATURE;
|
|
||||||
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.CHANNEL_FAN_LEVEL;
|
|
||||||
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.CHANNEL_MASTER_SWITCH;
|
|
||||||
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.CHANNEL_MODE;
|
|
||||||
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.CHANNEL_SWING_MODE;
|
|
||||||
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.CHANNEL_TARGET_TEMPERATURE;
|
|
||||||
import static org.openhab.binding.sensibo.internal.SensiboBindingConstants.CHANNEL_TIMER;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -55,6 +48,7 @@ import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
import org.openhab.core.library.types.StringType;
|
import org.openhab.core.library.types.StringType;
|
||||||
import org.openhab.core.library.unit.SIUnits;
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.thing.Channel;
|
import org.openhab.core.thing.Channel;
|
||||||
import org.openhab.core.thing.ChannelUID;
|
import org.openhab.core.thing.ChannelUID;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
|
@ -75,8 +69,6 @@ import org.openhab.core.types.UnDefType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link SensiboSkyHandler} is responsible for handling commands, which are
|
* The {@link SensiboSkyHandler} is responsible for handling commands, which are
|
||||||
* sent to one of the channels.
|
* sent to one of the channels.
|
||||||
|
@ -300,7 +292,7 @@ public class SensiboSkyHandler extends SensiboBaseThingHandler implements Channe
|
||||||
|
|
||||||
private void handleCurrentHumidityCommand(ChannelUID channelUID, Command command, SensiboSky sensiboSky) {
|
private void handleCurrentHumidityCommand(ChannelUID channelUID, Command command, SensiboSky sensiboSky) {
|
||||||
if (command instanceof RefreshType) {
|
if (command instanceof RefreshType) {
|
||||||
updateState(channelUID, new QuantityType<>(sensiboSky.getHumidity(), Units.PERCENT));
|
updateState(channelUID, new QuantityType<>(sensiboSky.getHumidity(), SmartHomeUnits.PERCENT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,14 +43,13 @@ import org.openhab.binding.shelly.internal.api.ShellyApiJsonDTO.ShellyStatusRela
|
||||||
import org.openhab.binding.shelly.internal.api.ShellyApiJsonDTO.ShellyStatusSensor;
|
import org.openhab.binding.shelly.internal.api.ShellyApiJsonDTO.ShellyStatusSensor;
|
||||||
import org.openhab.binding.shelly.internal.config.ShellyThingConfiguration;
|
import org.openhab.binding.shelly.internal.config.ShellyThingConfiguration;
|
||||||
import org.openhab.core.library.unit.ImperialUnits;
|
import org.openhab.core.library.unit.ImperialUnits;
|
||||||
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ShellyHttpApi} wraps the Shelly REST API and provides various low level function to access the device api (not
|
* {@link ShellyHttpApi} wraps the Shelly REST API and provides various low level function to access the device api (not
|
||||||
* cloud api).
|
* cloud api).
|
||||||
|
@ -187,10 +186,10 @@ public class ShellyHttpApi {
|
||||||
if (profile.isSense) {
|
if (profile.isSense) {
|
||||||
// complete reported data, map C to F or vice versa: C=(F - 32) * 0.5556;
|
// complete reported data, map C to F or vice versa: C=(F - 32) * 0.5556;
|
||||||
status.tmp.tC = status.tmp.units.equals(SHELLY_TEMP_CELSIUS) ? status.tmp.value
|
status.tmp.tC = status.tmp.units.equals(SHELLY_TEMP_CELSIUS) ? status.tmp.value
|
||||||
: ImperialUnits.FAHRENHEIT.getConverterTo(Units.CELSIUS).convert(getDouble(status.tmp.value))
|
: ImperialUnits.FAHRENHEIT.getConverterTo(SIUnits.CELSIUS).convert(getDouble(status.tmp.value))
|
||||||
.doubleValue();
|
.doubleValue();
|
||||||
status.tmp.tF = status.tmp.units.equals(SHELLY_TEMP_FAHRENHEIT) ? status.tmp.value
|
status.tmp.tF = status.tmp.units.equals(SHELLY_TEMP_FAHRENHEIT) ? status.tmp.value
|
||||||
: Units.CELSIUS.getConverterTo(ImperialUnits.FAHRENHEIT).convert(getDouble(status.tmp.value))
|
: SIUnits.CELSIUS.getConverterTo(ImperialUnits.FAHRENHEIT).convert(getDouble(status.tmp.value))
|
||||||
.doubleValue();
|
.doubleValue();
|
||||||
}
|
}
|
||||||
if ((status.charger == null) && (status.externalPower != null)) {
|
if ((status.charger == null) && (status.externalPower != null)) {
|
||||||
|
|
|
@ -33,8 +33,6 @@ import org.openhab.core.types.State;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link ShellyCoIoTVersion1} implements the parsing for CoIoT version 1
|
* The {@link ShellyCoIoTVersion1} implements the parsing for CoIoT version 1
|
||||||
*
|
*
|
||||||
|
@ -84,7 +82,7 @@ public class ShellyCoIoTVersion1 extends ShellyCoIoTProtocol implements ShellyCo
|
||||||
case "temperature": // Sensor Temp
|
case "temperature": // Sensor Temp
|
||||||
if (getString(getProfile().settings.temperatureUnits)
|
if (getString(getProfile().settings.temperatureUnits)
|
||||||
.equalsIgnoreCase(SHELLY_TEMP_FAHRENHEIT)) {
|
.equalsIgnoreCase(SHELLY_TEMP_FAHRENHEIT)) {
|
||||||
value = ImperialUnits.FAHRENHEIT.getConverterTo(Units.CELSIUS).convert(getDouble(s.value))
|
value = ImperialUnits.FAHRENHEIT.getConverterTo(SIUnits.CELSIUS).convert(getDouble(s.value))
|
||||||
.doubleValue();
|
.doubleValue();
|
||||||
}
|
}
|
||||||
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_TEMP,
|
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_TEMP,
|
||||||
|
|
|
@ -31,8 +31,6 @@ import org.openhab.core.library.unit.ImperialUnits;
|
||||||
import org.openhab.core.library.unit.SIUnits;
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* The{@link ShellyComponents} implements updates for supplemental components
|
* The{@link ShellyComponents} implements updates for supplemental components
|
||||||
* Meter will be used by Relay + Light; Sensor is part of H&T, Flood, Door Window, Sense
|
* Meter will be used by Relay + Light; Sensor is part of H&T, Flood, Door Window, Sense
|
||||||
|
@ -276,7 +274,7 @@ public class ShellyComponents {
|
||||||
: getDouble(sdata.tmp.tF);
|
: getDouble(sdata.tmp.tF);
|
||||||
if (getString(sdata.tmp.units).toUpperCase().equals(SHELLY_TEMP_FAHRENHEIT)) {
|
if (getString(sdata.tmp.units).toUpperCase().equals(SHELLY_TEMP_FAHRENHEIT)) {
|
||||||
// convert Fahrenheit to Celsius
|
// convert Fahrenheit to Celsius
|
||||||
temp = ImperialUnits.FAHRENHEIT.getConverterTo(Units.CELSIUS).convert(temp).doubleValue();
|
temp = ImperialUnits.FAHRENHEIT.getConverterTo(SIUnits.CELSIUS).convert(temp).doubleValue();
|
||||||
}
|
}
|
||||||
updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_TEMP,
|
updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_TEMP,
|
||||||
toQuantityType(temp.doubleValue(), DIGITS_TEMP, SIUnits.CELSIUS));
|
toQuantityType(temp.doubleValue(), DIGITS_TEMP, SIUnits.CELSIUS));
|
||||||
|
|
|
@ -19,14 +19,12 @@ import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.core.library.types.StringType;
|
import org.openhab.core.library.types.StringType;
|
||||||
import org.openhab.core.library.unit.ImperialUnits;
|
import org.openhab.core.library.unit.ImperialUnits;
|
||||||
import org.openhab.core.library.unit.SIUnits;
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
import org.openhab.core.types.UnDefType;
|
import org.openhab.core.types.UnDefType;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import tec.uom.se.AbstractUnit;
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* private class: a generic data point
|
* private class: a generic data point
|
||||||
*
|
*
|
||||||
|
@ -142,14 +140,14 @@ public abstract class BasePoint {
|
||||||
return ImperialUnits.FAHRENHEIT;
|
return ImperialUnits.FAHRENHEIT;
|
||||||
}
|
}
|
||||||
case DEGREES_KELVIN: {
|
case DEGREES_KELVIN: {
|
||||||
return Units.KELVIN;
|
return SmartHomeUnits.KELVIN;
|
||||||
}
|
}
|
||||||
case PERCENT_RELATIVE_HUMIDITY: {
|
case PERCENT_RELATIVE_HUMIDITY: {
|
||||||
return Units.PERCENT;
|
return SmartHomeUnits.PERCENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AbstractUnit.ONE;
|
return SmartHomeUnits.ONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -36,10 +36,9 @@ import org.openhab.core.library.types.QuantityType;
|
||||||
import org.openhab.core.library.types.StringType;
|
import org.openhab.core.library.types.StringType;
|
||||||
import org.openhab.core.library.unit.ImperialUnits;
|
import org.openhab.core.library.unit.ImperialUnits;
|
||||||
import org.openhab.core.library.unit.SIUnits;
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
|
|
||||||
import tec.uom.se.unit.Units;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test suite
|
* test suite
|
||||||
*
|
*
|
||||||
|
@ -295,13 +294,13 @@ public class RdsTestData {
|
||||||
|
|
||||||
state = dataPoints.getPointByClass("'SpTRShft").getState();
|
state = dataPoints.getPointByClass("'SpTRShft").getState();
|
||||||
assertTrue(state instanceof QuantityType<?>);
|
assertTrue(state instanceof QuantityType<?>);
|
||||||
QuantityType<?> kelvin = ((QuantityType<?>) state).toUnit(Units.KELVIN);
|
QuantityType<?> kelvin = ((QuantityType<?>) state).toUnit(SmartHomeUnits.KELVIN);
|
||||||
assertNotNull(kelvin);
|
assertNotNull(kelvin);
|
||||||
assertEquals(0, kelvin.floatValue(), 0.01);
|
assertEquals(0, kelvin.floatValue(), 0.01);
|
||||||
|
|
||||||
state = dataPoints.getPointByClass("'RHuRel").getState();
|
state = dataPoints.getPointByClass("'RHuRel").getState();
|
||||||
assertTrue(state instanceof QuantityType<?>);
|
assertTrue(state instanceof QuantityType<?>);
|
||||||
QuantityType<?> relativeHumidity = ((QuantityType<?>) state).toUnit(Units.PERCENT);
|
QuantityType<?> relativeHumidity = ((QuantityType<?>) state).toUnit(SmartHomeUnits.PERCENT);
|
||||||
assertNotNull(relativeHumidity);
|
assertNotNull(relativeHumidity);
|
||||||
assertEquals(46.86865, relativeHumidity.floatValue(), 0.1);
|
assertEquals(46.86865, relativeHumidity.floatValue(), 0.1);
|
||||||
|
|
||||||
|
@ -321,7 +320,7 @@ public class RdsTestData {
|
||||||
|
|
||||||
state = dataPoints.getPointByClass("'TRBltnMsvAdj").getState();
|
state = dataPoints.getPointByClass("'TRBltnMsvAdj").getState();
|
||||||
assertTrue(state instanceof QuantityType<?>);
|
assertTrue(state instanceof QuantityType<?>);
|
||||||
kelvin = ((QuantityType<?>) state).toUnit(Units.KELVIN);
|
kelvin = ((QuantityType<?>) state).toUnit(SmartHomeUnits.KELVIN);
|
||||||
assertNotNull(kelvin);
|
assertNotNull(kelvin);
|
||||||
assertEquals(35.0, celsius.floatValue(), 0.01);
|
assertEquals(35.0, celsius.floatValue(), 0.01);
|
||||||
|
|
||||||
|
@ -377,7 +376,7 @@ public class RdsTestData {
|
||||||
@Nullable
|
@Nullable
|
||||||
String x = entry.getKey();
|
String x = entry.getKey();
|
||||||
assertNotNull(x);
|
assertNotNull(x);
|
||||||
String y = ((BasePoint) point).getPointClass();
|
String y = point.getPointClass();
|
||||||
String z = dataPoints.pointClassToId(y);
|
String z = dataPoints.pointClassToId(y);
|
||||||
assertEquals(x, z);
|
assertEquals(x, z);
|
||||||
}
|
}
|
||||||
|
@ -469,21 +468,21 @@ public class RdsTestData {
|
||||||
// test temperature units code (C)
|
// test temperature units code (C)
|
||||||
BasePoint tempPoint = dataPoints.getPointByClass("'SpTR");
|
BasePoint tempPoint = dataPoints.getPointByClass("'SpTR");
|
||||||
assertTrue(tempPoint instanceof BasePoint);
|
assertTrue(tempPoint instanceof BasePoint);
|
||||||
assertEquals(SIUnits.CELSIUS, ((BasePoint) tempPoint).getUnit());
|
assertEquals(SIUnits.CELSIUS, tempPoint.getUnit());
|
||||||
|
|
||||||
// test temperature units code (F)
|
// test temperature units code (F)
|
||||||
tempPoint = dataPoints.getPointByClass("'SpHPcf");
|
tempPoint = dataPoints.getPointByClass("'SpHPcf");
|
||||||
assertTrue(tempPoint instanceof BasePoint);
|
assertTrue(tempPoint instanceof BasePoint);
|
||||||
assertEquals(ImperialUnits.FAHRENHEIT, ((BasePoint) tempPoint).getUnit());
|
assertEquals(ImperialUnits.FAHRENHEIT, tempPoint.getUnit());
|
||||||
|
|
||||||
// test temperature units code (K)
|
// test temperature units code (K)
|
||||||
tempPoint = dataPoints.getPointByClass("'SpHPcf");
|
tempPoint = dataPoints.getPointByClass("'SpHPcf");
|
||||||
assertTrue(tempPoint instanceof BasePoint);
|
assertTrue(tempPoint instanceof BasePoint);
|
||||||
assertEquals(ImperialUnits.FAHRENHEIT, ((BasePoint) tempPoint).getUnit());
|
assertEquals(ImperialUnits.FAHRENHEIT, tempPoint.getUnit());
|
||||||
|
|
||||||
tempPoint = dataPoints.getPointByClass("'SpTRShft");
|
tempPoint = dataPoints.getPointByClass("'SpTRShft");
|
||||||
assertTrue(tempPoint instanceof BasePoint);
|
assertTrue(tempPoint instanceof BasePoint);
|
||||||
assertEquals(Units.KELVIN, ((BasePoint) tempPoint).getUnit());
|
assertEquals(SmartHomeUnits.KELVIN, tempPoint.getUnit());
|
||||||
} catch (RdsCloudException e) {
|
} catch (RdsCloudException e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -503,13 +502,13 @@ public class RdsTestData {
|
||||||
PlantInfo plant;
|
PlantInfo plant;
|
||||||
plant = plantList.get(0);
|
plant = plantList.get(0);
|
||||||
assertTrue(plant instanceof PlantInfo);
|
assertTrue(plant instanceof PlantInfo);
|
||||||
assertEquals("Pd1774247-7de7-4896-ac76-b7e0dd943c40", ((PlantInfo) plant).getId());
|
assertEquals("Pd1774247-7de7-4896-ac76-b7e0dd943c40", plant.getId());
|
||||||
assertTrue(plant.isOnline());
|
assertTrue(plant.isOnline());
|
||||||
|
|
||||||
plant = plantList.get(1);
|
plant = plantList.get(1);
|
||||||
assertTrue(plant instanceof PlantInfo);
|
assertTrue(plant instanceof PlantInfo);
|
||||||
assertEquals("Pfaf770c8-abeb-4742-ad65-ead39030d369", ((PlantInfo) plant).getId());
|
assertEquals("Pfaf770c8-abeb-4742-ad65-ead39030d369", plant.getId());
|
||||||
assertTrue(((PlantInfo) plant).isOnline());
|
assertTrue(plant.isOnline());
|
||||||
} catch (RdsCloudException e) {
|
} catch (RdsCloudException e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,12 @@ import org.openhab.core.library.types.PointType;
|
||||||
import org.openhab.core.library.types.QuantityType;
|
import org.openhab.core.library.types.QuantityType;
|
||||||
import org.openhab.core.library.types.StringType;
|
import org.openhab.core.library.types.StringType;
|
||||||
import org.openhab.core.library.unit.ImperialUnits;
|
import org.openhab.core.library.unit.ImperialUnits;
|
||||||
|
import org.openhab.core.library.unit.MetricPrefix;
|
||||||
import org.openhab.core.library.unit.SIUnits;
|
import org.openhab.core.library.unit.SIUnits;
|
||||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
import org.openhab.core.types.Type;
|
import org.openhab.core.types.Type;
|
||||||
|
|
||||||
import tec.uom.se.unit.MetricPrefix;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link TeslaChannelSelectorProxy} class is a helper class to instantiate
|
* The {@link TeslaChannelSelectorProxy} class is a helper class to instantiate
|
||||||
* and parameterize the {@link TeslaChannelSelector} Enum
|
* and parameterize the {@link TeslaChannelSelector} Enum
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
checkstyle.headerCheck.content=^/\\*\\*$\\n^ \\* Copyright \\(c\\) {0}-{1} Contributors to the openHAB project$\\n^ \\*$\\n^ \\* See the NOTICE file\\(s\\) distributed with this work for additional$\\n^ \\* information.$\\n^ \\*$\\n^ \\* This program and the accompanying materials are made available under the$\\n^ \\* terms of the Eclipse Public License 2\\.0 which is available at$\\n^ \\* http://www.eclipse.org/legal/epl\\-2\\.0$\\n^ \\*$\\n^ \\* SPDX-License-Identifier: EPL-2.0$
|
checkstyle.headerCheck.content=^/\\*\\*$\\n^ \\* Copyright \\(c\\) {0}-{1} Contributors to the openHAB project$\\n^ \\*$\\n^ \\* See the NOTICE file\\(s\\) distributed with this work for additional$\\n^ \\* information.$\\n^ \\*$\\n^ \\* This program and the accompanying materials are made available under the$\\n^ \\* terms of the Eclipse Public License 2\\.0 which is available at$\\n^ \\* http://www.eclipse.org/legal/epl\\-2\\.0$\\n^ \\*$\\n^ \\* SPDX-License-Identifier: EPL-2.0$
|
||||||
checkstyle.headerCheck.values=2010,2020
|
checkstyle.headerCheck.values=2010,2020
|
||||||
checkstyle.forbiddenPackageUsageCheck.forbiddenPackages=com.google.common,gnu.io,javax.comm,org.apache.commons,org.joda.time
|
checkstyle.forbiddenPackageUsageCheck.forbiddenPackages=com.google.common,gnu.io,javax.comm,org.apache.commons,org.joda.time,tec.uom.se
|
||||||
checkstyle.forbiddenPackageUsageCheck.exceptions=
|
checkstyle.forbiddenPackageUsageCheck.exceptions=
|
||||||
checkstyle.requiredFilesCheck.files=pom.xml
|
checkstyle.requiredFilesCheck.files=pom.xml
|
||||||
|
|
Loading…
Reference in New Issue