Use renamed Units class (#9267)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2020-12-07 10:34:02 +01:00
committed by GitHub
parent d0480d0f2e
commit ac6f08908f
208 changed files with 1087 additions and 1169 deletions

View File

@@ -19,7 +19,7 @@ import java.util.function.Function;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.types.State;
/**
@@ -37,7 +37,7 @@ public class A5_04_02_Eltako extends A5_04_02 {
Function<String, State> getCurrentStateFunc, Configuration config) {
if (channelId.equals(CHANNEL_BATTERY_VOLTAGE)) {
double voltage = getDB_3Value() * 6.58 / 255.0; // not sure if this is right
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
return new QuantityType<>(voltage, Units.VOLT);
}
return super.convertToStateImpl(channelId, channelTypeId, getCurrentStateFunc, config);

View File

@@ -20,7 +20,7 @@ import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -39,7 +39,7 @@ public class A5_06_01 extends _4BSMessage {
double voltage = db3 / 50.0; // 0..255 = 0.0..5.1V
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
return new QuantityType<>(voltage, Units.VOLT);
}
private State getIllumination() {
@@ -47,7 +47,7 @@ public class A5_06_01 extends _4BSMessage {
double illumination = rs ? getDB_2Value() * 116.48 + 300.0 : getDB_1Value() * 232.94 + 600.0;
return new QuantityType<>(illumination, SmartHomeUnits.LUX);
return new QuantityType<>(illumination, Units.LUX);
}
@Override

View File

@@ -20,7 +20,7 @@ import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -39,9 +39,9 @@ public class A5_06_01_ELTAKO extends _4BSMessage {
if (db2 == 0) {
int db3 = getDB_3Value();
return new QuantityType<>(db3 * 0.5, SmartHomeUnits.LUX);
return new QuantityType<>(db3 * 0.5, Units.LUX);
} else {
return new QuantityType<>(db2 * 116.48 + 300.0, SmartHomeUnits.LUX);
return new QuantityType<>(db2 * 116.48 + 300.0, Units.LUX);
}
}

View File

@@ -20,7 +20,7 @@ import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -47,7 +47,7 @@ public abstract class A5_07 extends _4BSMessage {
}
double voltage = value / 50.0; // 0..250 = 0.0..5.0V
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
return new QuantityType<>(voltage, Units.VOLT);
}
@Override

View File

@@ -14,7 +14,7 @@ package org.openhab.binding.enocean.internal.eep.A5_07;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
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.types.State;
/**
@@ -29,6 +29,6 @@ public class A5_07_03 extends A5_07_02 {
@Override
protected State getIllumination() {
return new QuantityType<>((getDB_2Value() << 8) + ((getDB_1Value() & 0b11000000) >>> 6), SmartHomeUnits.LUX);
return new QuantityType<>((getDB_2Value() << 8) + ((getDB_1Value() & 0b11000000) >>> 6), Units.LUX);
}
}

View File

@@ -22,7 +22,7 @@ import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.OnOffType;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -84,7 +84,7 @@ public abstract class A5_08 extends _4BSMessage {
double scaledIllumination = getScaledIlluminationMin()
+ ((getUnscaledIlluminationValue() * (getScaledIlluminationMax() - getScaledIlluminationMin()))
/ (getUnscaledIlluminationMax() - getUnscaledIlluminationMin()));
return new QuantityType<>(scaledIllumination, SmartHomeUnits.LUX);
return new QuantityType<>(scaledIllumination, Units.LUX);
} else if (channelId.equals(CHANNEL_MOTIONDETECTION)) {
return getBit(getDB_0(), 1) ? OnOffType.OFF : OnOffType.ON;
} else if (channelId.equals(CHANNEL_OCCUPANCY)) {

View File

@@ -21,7 +21,7 @@ import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.PercentType;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -77,7 +77,7 @@ public class A5_11_03 extends _4BSMessage {
int an = (db2 & 0x7F) * 2;
if ((an >= 0) && (an <= 180)) {
return new QuantityType<>(as ? an * -1 : an, SmartHomeUnits.DEGREE_ANGLE);
return new QuantityType<>(as ? an * -1 : an, Units.DEGREE_ANGLE);
}
}

View File

@@ -24,7 +24,7 @@ import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
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.types.State;
import org.openhab.core.types.UnDefType;
import org.openhab.core.util.HexUtils;
@@ -135,7 +135,7 @@ public class A5_11_04 extends _4BSMessage {
return new QuantityType<>(
Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2() }), 16) * factor,
SmartHomeUnits.KILOWATT_HOUR);
Units.KILOWATT_HOUR);
}
return UnDefType.UNDEF;
@@ -163,8 +163,7 @@ public class A5_11_04 extends _4BSMessage {
}
return new QuantityType<>(
Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2() }), 16) * factor,
SmartHomeUnits.WATT);
Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2() }), 16) * factor, Units.WATT);
}
return UnDefType.UNDEF;

View File

@@ -21,7 +21,7 @@ import org.openhab.binding.enocean.internal.eep.EEPHelper;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.types.State;
import org.openhab.core.types.UnDefType;
import org.openhab.core.util.HexUtils;
@@ -36,11 +36,11 @@ public abstract class A5_12 extends _4BSMessage {
}
protected State calcCumulativeValue(float value) {
return new QuantityType<>(value, SmartHomeUnits.ONE);
return new QuantityType<>(value, Units.ONE);
}
protected State calcCurrentValue(float value) {
return new QuantityType<>(value, SmartHomeUnits.ONE);
return new QuantityType<>(value, Units.ONE);
}
protected State getCumulativeValue() {

View File

@@ -14,7 +14,7 @@ package org.openhab.binding.enocean.internal.eep.A5_12;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
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.types.State;
/**
@@ -29,11 +29,11 @@ public class A5_12_00 extends A5_12 {
@Override
protected State calcCumulativeValue(float value) {
return new QuantityType<>(value, SmartHomeUnits.ONE);
return new QuantityType<>(value, Units.ONE);
}
@Override
protected State calcCurrentValue(float value) {
return new QuantityType<>(value, SmartHomeUnits.ONE);
return new QuantityType<>(value, Units.ONE);
}
}

View File

@@ -14,7 +14,7 @@ package org.openhab.binding.enocean.internal.eep.A5_12;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
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.types.State;
/**
@@ -29,11 +29,11 @@ public class A5_12_01 extends A5_12 {
@Override
protected State calcCumulativeValue(float value) {
return new QuantityType<>(value, SmartHomeUnits.KILOWATT_HOUR);
return new QuantityType<>(value, Units.KILOWATT_HOUR);
}
@Override
protected State calcCurrentValue(float value) {
return new QuantityType<>(value, SmartHomeUnits.WATT);
return new QuantityType<>(value, Units.WATT);
}
}

View File

@@ -15,7 +15,7 @@ package org.openhab.binding.enocean.internal.eep.A5_12;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
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.types.State;
/**
@@ -36,6 +36,6 @@ public class A5_12_02 extends A5_12 {
@Override
protected State calcCurrentValue(float value) {
// value is given in litre/second, hence multiply by 60
return new QuantityType<>(value * 60, SmartHomeUnits.LITRE_PER_MINUTE);
return new QuantityType<>(value * 60, Units.LITRE_PER_MINUTE);
}
}

View File

@@ -15,7 +15,7 @@ package org.openhab.binding.enocean.internal.eep.A5_12;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
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.types.State;
/**
@@ -36,6 +36,6 @@ public class A5_12_03 extends A5_12 {
@Override
protected State calcCurrentValue(float value) {
// value is given in litre/second, hence multiply by 60
return new QuantityType<>(value * 60, SmartHomeUnits.LITRE_PER_MINUTE);
return new QuantityType<>(value * 60, Units.LITRE_PER_MINUTE);
}
}

View File

@@ -21,7 +21,7 @@ import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.OnOffType;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -37,11 +37,11 @@ public class A5_13_01 extends A5_13 {
}
protected State getIllumination() {
return new QuantityType<>(((getDB_3Value() * 1000.0) / 255.0), SmartHomeUnits.LUX);
return new QuantityType<>(((getDB_3Value() * 1000.0) / 255.0), Units.LUX);
}
protected State getIllumination(double value) {
return new QuantityType<>(((value * 1000.0 * 150.0) / 255.0), SmartHomeUnits.LUX);
return new QuantityType<>(((value * 1000.0 * 150.0) / 255.0), Units.LUX);
}
protected State getIlluminationWest() {
@@ -61,7 +61,7 @@ public class A5_13_01 extends A5_13 {
}
protected State getWindSpeed() {
return new QuantityType<>(((getDB_1Value() * 70.0) / 255.0), SmartHomeUnits.METRE_PER_SECOND);
return new QuantityType<>(((getDB_1Value() * 70.0) / 255.0), Units.METRE_PER_SECOND);
}
protected State getRainStatus() {

View File

@@ -20,7 +20,7 @@ import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -43,7 +43,7 @@ public abstract class A5_14 extends _4BSMessage {
double voltage = db3 / 50.0; // 0..250 = 0.0..5.0V
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
return new QuantityType<>(voltage, Units.VOLT);
}
@Override

View File

@@ -20,7 +20,7 @@ import org.openhab.binding.enocean.internal.eep.Base._4BSMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -39,7 +39,7 @@ public class A5_14_01_ELTAKO extends _4BSMessage {
double voltage = db3 / 51.0; // 0..255 = 0.0..5.0V
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
return new QuantityType<>(voltage, Units.VOLT);
}
private State getBatteryVoltage() {
@@ -47,7 +47,7 @@ public class A5_14_01_ELTAKO extends _4BSMessage {
double voltage = db2 / 51.0; // 0..255 = 0.0..5.0V
return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
return new QuantityType<>(voltage, Units.VOLT);
}
@Override

View File

@@ -24,7 +24,7 @@ import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
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.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
@@ -222,10 +222,10 @@ public class A5_20_04 extends A5_20 {
boolean fl = getBit(getDB_0Value(), 0);
if (!fl) {
return new QuantityType<>(-1, SmartHomeUnits.ONE);
return new QuantityType<>(-1, Units.ONE);
}
return new QuantityType<>(getDB_1Value(), SmartHomeUnits.ONE);
return new QuantityType<>(getDB_1Value(), Units.ONE);
}
private State getMeasurementControl() {
@@ -262,6 +262,6 @@ public class A5_20_04 extends A5_20 {
}
private State getValvePosition() {
return new QuantityType<>(getDB_3Value(), SmartHomeUnits.PERCENT);
return new QuantityType<>(getDB_3Value(), Units.PERCENT);
}
}

View File

@@ -25,7 +25,7 @@ import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StopMoveType;
import org.openhab.core.library.types.UpDownType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
@@ -139,7 +139,7 @@ public class A5_38_08_Blinds extends _4BSMessage {
int an = (db1 & 0x7F) * 2;
if ((an >= 0) && (an <= 180)) {
return new QuantityType<>(as ? an * -1 : an, SmartHomeUnits.DEGREE_ANGLE);
return new QuantityType<>(as ? an * -1 : an, Units.DEGREE_ANGLE);
}
}

View File

@@ -20,7 +20,7 @@ import org.openhab.binding.enocean.internal.eep.Base._SIGMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -42,7 +42,7 @@ public class D0_06 extends _SIGMessage {
public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc,
Configuration config) {
if (CHANNEL_BATTERY_LEVEL.equals(channelId)) {
return new QuantityType<>(bytes[1] & 0xFF, SmartHomeUnits.PERCENT);
return new QuantityType<>(bytes[1] & 0xFF, Units.PERCENT);
}
return UnDefType.UNDEF;

View File

@@ -26,7 +26,7 @@ import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
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.types.Command;
import org.openhab.core.types.RefreshType;
import org.openhab.core.types.State;
@@ -159,7 +159,7 @@ public abstract class D2_01 extends _VLDMessage {
float energy = Long.parseLong(HexUtils.bytesToHex(new byte[] { bytes[2], bytes[3], bytes[4], bytes[5] }),
16) * factor;
return new QuantityType<>(energy, SmartHomeUnits.KILOWATT_HOUR);
return new QuantityType<>(energy, Units.KILOWATT_HOUR);
}
return UnDefType.UNDEF;
@@ -183,7 +183,7 @@ public abstract class D2_01 extends _VLDMessage {
float power = Long.parseLong(HexUtils.bytesToHex(new byte[] { bytes[2], bytes[3], bytes[4], bytes[5] }), 16)
* factor;
return new QuantityType<>(power, SmartHomeUnits.WATT);
return new QuantityType<>(power, Units.WATT);
}
return UnDefType.UNDEF;

View File

@@ -20,7 +20,7 @@ import org.openhab.binding.enocean.internal.eep.Base._VLDMessage;
import org.openhab.binding.enocean.internal.messages.ERP1Message;
import org.openhab.core.config.core.Configuration;
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.CommonTriggerEvents;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
@@ -64,7 +64,7 @@ public class D2_03_0A extends _VLDMessage {
public State convertToStateImpl(String channelId, String channelTypeId, Function<String, State> getCurrentStateFunc,
Configuration config) {
if (CHANNEL_BATTERY_LEVEL.equals(channelId)) {
return new QuantityType<>(bytes[0] & 0xFF, SmartHomeUnits.PERCENT);
return new QuantityType<>(bytes[0] & 0xFF, Units.PERCENT);
}
return UnDefType.UNDEF;

View File

@@ -24,7 +24,7 @@ import org.openhab.core.library.types.OnOffType;
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.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
@@ -49,13 +49,13 @@ public class D2_14_30 extends _VLDMessage {
protected State getBatteryLevel() {
switch ((bytes[1] & 0b110) >>> 1) {
case 0:
return new QuantityType<>(100, SmartHomeUnits.PERCENT); // High
return new QuantityType<>(100, Units.PERCENT); // High
case 1:
return new QuantityType<>(50, SmartHomeUnits.PERCENT); // Medium
return new QuantityType<>(50, Units.PERCENT); // Medium
case 2:
return new QuantityType<>(25, SmartHomeUnits.PERCENT); // Low
return new QuantityType<>(25, Units.PERCENT); // Low
case 3:
return new QuantityType<>(5, SmartHomeUnits.PERCENT); // Critical
return new QuantityType<>(5, Units.PERCENT); // Critical
}
return UnDefType.UNDEF;
@@ -76,12 +76,12 @@ public class D2_14_30 extends _VLDMessage {
case CHANNEL_SENSORANALYSISTEMPERATURRANGE:
return getBit(bytes[0], 3) ? OnOffType.ON : OnOffType.OFF;
case CHANNEL_TIMESINCELASTMAINTENANCE:
return new QuantityType<>(((bytes[0] << 5) + (bytes[0] >>> 3)) & 0xFF, SmartHomeUnits.WEEK);
return new QuantityType<>(((bytes[0] << 5) + (bytes[0] >>> 3)) & 0xFF, Units.WEEK);
case CHANNEL_BATTERY_LEVEL:
return getBatteryLevel();
case CHANNEL_REMAININGPLT: {
int months = ((bytes[1] << 7) + (bytes[2] >>> 1)) & 0xFF;
return months < 121 ? new QuantityType<>(months * 4, SmartHomeUnits.WEEK) : UnDefType.NULL;
return months < 121 ? new QuantityType<>(months * 4, Units.WEEK) : UnDefType.NULL;
}
case CHANNEL_TEMPERATURE: {
int unscaledValue = ((bytes[2] << 7) + (bytes[3] >>> 1)) & 0xFF;

View File

@@ -17,7 +17,7 @@ import javax.measure.quantity.Energy;
import org.openhab.binding.enocean.internal.config.EnOceanChannelTotalusageConfig;
import org.openhab.core.config.core.Configuration;
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.types.State;
import org.openhab.core.types.UnDefType;
@@ -35,14 +35,14 @@ public abstract class EEPHelper {
QuantityType<Energy> newValue = value.as(QuantityType.class);
if (newValue != null) {
newValue = newValue.toUnit(SmartHomeUnits.KILOWATT_HOUR);
newValue = newValue.toUnit(Units.KILOWATT_HOUR);
}
@SuppressWarnings("unchecked")
QuantityType<Energy> oldValue = currentState.as(QuantityType.class);
if (oldValue != null) {
oldValue = oldValue.toUnit(SmartHomeUnits.KILOWATT_HOUR);
oldValue = oldValue.toUnit(Units.KILOWATT_HOUR);
}
if ((newValue != null) && (oldValue != null)) {