Use renamed Units class (#9267)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -27,7 +27,7 @@ import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.utils.NumberUtils;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SIUnits;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
import org.openhab.core.thing.Thing;
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ import org.openhab.core.thing.Thing;
|
||||
public class ConditionHandler extends BaseSensorHandler {
|
||||
|
||||
protected QuantityType<Temperature> temperatureCache = QuantityType.valueOf(-1, SIUnits.CELSIUS);
|
||||
protected QuantityType<Dimensionless> humidityCache = QuantityType.valueOf(-1, SmartHomeUnits.PERCENT);
|
||||
protected QuantityType<Dimensionless> humidityCache = QuantityType.valueOf(-1, Units.PERCENT);
|
||||
protected QuantityType<Pressure> pressureCache = QuantityType.valueOf(-1, SIUnits.PASCAL);
|
||||
protected QuantityType<Pressure> pressureSeaCache = QuantityType.valueOf(-1, SIUnits.PASCAL);
|
||||
|
||||
@@ -60,8 +60,7 @@ public class ConditionHandler extends BaseSensorHandler {
|
||||
SIUnits.CELSIUS);
|
||||
updateState(TEMPERATURE_CHANNEL, temperatureCache);
|
||||
} else if (v.getValueType().equals(HUMIDITY)) {
|
||||
humidityCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1),
|
||||
SmartHomeUnits.PERCENT);
|
||||
humidityCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1), Units.PERCENT);
|
||||
updateState(HUMIDITY_CHANNEL, humidityCache);
|
||||
} else if (v.getValueType().equals(PRESSURE)) {
|
||||
pressureCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1), SIUnits.PASCAL);
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.utils.NumberUtils;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
import org.openhab.core.thing.Thing;
|
||||
|
||||
/**
|
||||
@@ -35,9 +35,9 @@ import org.openhab.core.thing.Thing;
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class NoiseHandler extends BaseSensorHandler {
|
||||
protected QuantityType<Dimensionless> noiseEQCache = QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL);
|
||||
protected QuantityType<Dimensionless> noiseMinCache = QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL);
|
||||
protected QuantityType<Dimensionless> noiseMaxCache = QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL);
|
||||
protected QuantityType<Dimensionless> noiseEQCache = QuantityType.valueOf(-1, Units.DECIBEL);
|
||||
protected QuantityType<Dimensionless> noiseMinCache = QuantityType.valueOf(-1, Units.DECIBEL);
|
||||
protected QuantityType<Dimensionless> noiseMaxCache = QuantityType.valueOf(-1, Units.DECIBEL);
|
||||
|
||||
public NoiseHandler(Thing thing) {
|
||||
super(thing);
|
||||
@@ -51,16 +51,13 @@ public class NoiseHandler extends BaseSensorHandler {
|
||||
if (HTTPHandler.getHandler().isNoise(valueList)) {
|
||||
valueList.forEach(v -> {
|
||||
if (v.getValueType().equals(NOISE_EQ)) {
|
||||
noiseEQCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1),
|
||||
SmartHomeUnits.DECIBEL);
|
||||
noiseEQCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1), Units.DECIBEL);
|
||||
updateState(NOISE_EQ_CHANNEL, noiseEQCache);
|
||||
} else if (v.getValueType().equals(NOISE_MIN)) {
|
||||
noiseMinCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1),
|
||||
SmartHomeUnits.DECIBEL);
|
||||
noiseMinCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1), Units.DECIBEL);
|
||||
updateState(NOISE_MIN_CHANNEL, noiseMinCache);
|
||||
} else if (v.getValueType().equals(NOISE_MAX)) {
|
||||
noiseMaxCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1),
|
||||
SmartHomeUnits.DECIBEL);
|
||||
noiseMaxCache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1), Units.DECIBEL);
|
||||
updateState(NOISE_MAX_CHANNEL, noiseMaxCache);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.utils.NumberUtils;
|
||||
import org.openhab.core.library.dimension.Density;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
import org.openhab.core.thing.Thing;
|
||||
|
||||
/**
|
||||
@@ -35,8 +35,8 @@ import org.openhab.core.thing.Thing;
|
||||
@NonNullByDefault
|
||||
public class PMHandler extends BaseSensorHandler {
|
||||
|
||||
protected QuantityType<Density> pm25Cache = QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
|
||||
protected QuantityType<Density> pm100Cache = QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
|
||||
protected QuantityType<Density> pm25Cache = QuantityType.valueOf(-1, Units.MICROGRAM_PER_CUBICMETRE);
|
||||
protected QuantityType<Density> pm100Cache = QuantityType.valueOf(-1, Units.MICROGRAM_PER_CUBICMETRE);
|
||||
|
||||
public PMHandler(Thing thing) {
|
||||
super(thing);
|
||||
@@ -51,11 +51,11 @@ public class PMHandler extends BaseSensorHandler {
|
||||
valueList.forEach(v -> {
|
||||
if (v.getValueType().equals(P1)) {
|
||||
pm100Cache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1),
|
||||
SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
|
||||
Units.MICROGRAM_PER_CUBICMETRE);
|
||||
updateState(PM100_CHANNEL, pm100Cache);
|
||||
} else if (v.getValueType().equals(P2)) {
|
||||
pm25Cache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1),
|
||||
SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
|
||||
Units.MICROGRAM_PER_CUBICMETRE);
|
||||
updateState(PM25_CHANNEL, pm25Cache);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SIUnits;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
|
||||
/**
|
||||
* The {@link ConditionHandlerTest} Test Condition Handler updates
|
||||
@@ -49,7 +49,7 @@ public class ConditionHandlerTest {
|
||||
UpdateStatus result = condHandler.updateChannels(pmJson);
|
||||
assertEquals(UpdateStatus.OK, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(22.7, SIUnits.CELSIUS), condHandler.getTemperature(), "Temperature");
|
||||
assertEquals(QuantityType.valueOf(61.0, SmartHomeUnits.PERCENT), condHandler.getHumidity(), "Humidity");
|
||||
assertEquals(QuantityType.valueOf(61.0, Units.PERCENT), condHandler.getHumidity(), "Humidity");
|
||||
assertEquals(QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressure(), "Pressure");
|
||||
assertEquals(QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressureSea(), "Pressure Sea");
|
||||
} else {
|
||||
@@ -72,7 +72,7 @@ public class ConditionHandlerTest {
|
||||
UpdateStatus result = condHandler.updateChannels(pmJson);
|
||||
assertEquals(UpdateStatus.OK, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(21.5, SIUnits.CELSIUS), condHandler.getTemperature(), "Temperature");
|
||||
assertEquals(QuantityType.valueOf(58.5, SmartHomeUnits.PERCENT), condHandler.getHumidity(), "Humidity");
|
||||
assertEquals(QuantityType.valueOf(58.5, Units.PERCENT), condHandler.getHumidity(), "Humidity");
|
||||
assertEquals(QuantityType.valueOf(100200.0, SIUnits.PASCAL), condHandler.getPressure(), "Pressure");
|
||||
assertEquals(QuantityType.valueOf(101968.7, SIUnits.PASCAL), condHandler.getPressureSea(), "Pressure Sea");
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.openhab.binding.luftdateninfo.internal.mock.NoiseHandlerExtension;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
|
||||
/**
|
||||
* The {@link NoiseHandlerTest} Test Noise Handler updates
|
||||
@@ -47,12 +47,9 @@ public class NoiseHandlerTest {
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = noiseHandler.updateChannels(pmJson);
|
||||
assertEquals(UpdateStatus.OK, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(51.0, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseEQCache(),
|
||||
"Noise EQ");
|
||||
assertEquals(QuantityType.valueOf(47.2, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMinCache(),
|
||||
"Noise Min");
|
||||
assertEquals(QuantityType.valueOf(57.0, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMaxCache(),
|
||||
"Noise Max");
|
||||
assertEquals(QuantityType.valueOf(51.0, Units.DECIBEL), noiseHandler.getNoiseEQCache(), "Noise EQ");
|
||||
assertEquals(QuantityType.valueOf(47.2, Units.DECIBEL), noiseHandler.getNoiseMinCache(), "Noise Min");
|
||||
assertEquals(QuantityType.valueOf(57.0, Units.DECIBEL), noiseHandler.getNoiseMaxCache(), "Noise Max");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -72,12 +69,9 @@ public class NoiseHandlerTest {
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = noiseHandler.updateChannels(pmJson);
|
||||
assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseEQCache(),
|
||||
"Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMinCache(),
|
||||
"Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMaxCache(),
|
||||
"Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, Units.DECIBEL), noiseHandler.getNoiseEQCache(), "Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, Units.DECIBEL), noiseHandler.getNoiseMinCache(), "Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, Units.DECIBEL), noiseHandler.getNoiseMaxCache(), "Values undefined");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.openhab.binding.luftdateninfo.internal.mock.PMHandlerExtension;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
import org.openhab.core.library.unit.Units;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -111,10 +111,8 @@ public class PMHandlerTest {
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = pmHandler.updateChannels(pmJson);
|
||||
assertEquals(UpdateStatus.OK, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(2.9, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
|
||||
"PM25");
|
||||
assertEquals(QuantityType.valueOf(5.2, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
|
||||
"PM100");
|
||||
assertEquals(QuantityType.valueOf(2.9, Units.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(), "PM25");
|
||||
assertEquals(QuantityType.valueOf(5.2, Units.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(), "PM100");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -134,9 +132,9 @@ public class PMHandlerTest {
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = pmHandler.updateChannels(pmJson);
|
||||
assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
|
||||
assertEquals(QuantityType.valueOf(-1, Units.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
|
||||
"Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
|
||||
assertEquals(QuantityType.valueOf(-1, Units.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
|
||||
"Values undefined");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
|
||||
Reference in New Issue
Block a user