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

@@ -22,7 +22,7 @@ import org.openhab.binding.teleinfo.internal.dto.common.FrameHcOption;
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
@@ -87,28 +87,22 @@ public abstract class TeleinfoAbstractElectricityMeterHandler extends BaseThingH
}
protected void updateStatesForBaseFrameOption(FrameBaseOption frameBaseOption) {
updateState(CHANNEL_BASE_FRAME_BASE, QuantityType.valueOf(frameBaseOption.getBase(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_BASE_FRAME_BASE, QuantityType.valueOf(frameBaseOption.getBase(), Units.WATT_HOUR));
}
protected void updateStatesForHcFrameOption(FrameHcOption frameHcOption) {
updateState(CHANNEL_HC_FRAME_HCHC, QuantityType.valueOf(frameHcOption.getHchc(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_HC_FRAME_HCHP, QuantityType.valueOf(frameHcOption.getHchp(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_HC_FRAME_HCHC, QuantityType.valueOf(frameHcOption.getHchc(), Units.WATT_HOUR));
updateState(CHANNEL_HC_FRAME_HCHP, QuantityType.valueOf(frameHcOption.getHchp(), Units.WATT_HOUR));
updateState(CHANNEL_HC_FRAME_HHPHC, new StringType(frameHcOption.getHhphc().name()));
}
protected void updateStatesForTempoFrameOption(FrameTempoOption frameTempoOption) {
updateState(CHANNEL_TEMPO_FRAME_BBRHPJR,
QuantityType.valueOf(frameTempoOption.getBbrhpjr(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJR,
QuantityType.valueOf(frameTempoOption.getBbrhcjr(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHPJW,
QuantityType.valueOf(frameTempoOption.getBbrhpjw(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJW,
QuantityType.valueOf(frameTempoOption.getBbrhcjw(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHPJB,
QuantityType.valueOf(frameTempoOption.getBbrhpjb(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJB,
QuantityType.valueOf(frameTempoOption.getBbrhcjb(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHPJR, QuantityType.valueOf(frameTempoOption.getBbrhpjr(), Units.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJR, QuantityType.valueOf(frameTempoOption.getBbrhcjr(), Units.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHPJW, QuantityType.valueOf(frameTempoOption.getBbrhpjw(), Units.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJW, QuantityType.valueOf(frameTempoOption.getBbrhcjw(), Units.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHPJB, QuantityType.valueOf(frameTempoOption.getBbrhpjb(), Units.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_BBRHCJB, QuantityType.valueOf(frameTempoOption.getBbrhcjb(), Units.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_HHPHC, new StringType(frameTempoOption.getHhphc().name()));
updateState(CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_1,
new StringType(frameTempoOption.getProgrammeCircuit1().name()));
@@ -123,14 +117,13 @@ public abstract class TeleinfoAbstractElectricityMeterHandler extends BaseThingH
}
protected void updateStatesForEjpFrameOption(FrameEjpOption frameEjpOption) {
updateState(CHANNEL_EJP_FRAME_EJPHN, QuantityType.valueOf(frameEjpOption.getEjphn(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_EJP_FRAME_EJPHPM,
QuantityType.valueOf(frameEjpOption.getEjphpm(), SmartHomeUnits.WATT_HOUR));
updateState(CHANNEL_EJP_FRAME_EJPHN, QuantityType.valueOf(frameEjpOption.getEjphn(), Units.WATT_HOUR));
updateState(CHANNEL_EJP_FRAME_EJPHPM, QuantityType.valueOf(frameEjpOption.getEjphpm(), Units.WATT_HOUR));
if (frameEjpOption.getPejp() == null) {
updateState(CHANNEL_EJP_FRAME_PEJP, UnDefType.NULL);
} else {
updateState(CHANNEL_EJP_FRAME_PEJP, QuantityType.valueOf(frameEjpOption.getPejp(), SmartHomeUnits.MINUTE));
updateState(CHANNEL_EJP_FRAME_PEJP, QuantityType.valueOf(frameEjpOption.getPejp(), Units.MINUTE));
}
}

View File

@@ -20,7 +20,7 @@ import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractElectricity
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.UnDefType;
@@ -39,20 +39,20 @@ public abstract class TeleinfoAbstractCbemmElectricityMeterHandler extends Telei
protected void updateStatesForCommonCbemmChannels(FrameCbemm frame) {
// update common channels
updateState(CHANNEL_CBEMM_ISOUSC, QuantityType.valueOf(frame.getIsousc(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBEMM_ISOUSC, QuantityType.valueOf(frame.getIsousc(), Units.AMPERE));
updateState(CHANNEL_CBEMM_PTEC, new StringType(frame.getPtec().name()));
if (frame.getImax() == null) {
updateState(CHANNEL_CBEMM_IMAX, UnDefType.NULL);
} else {
updateState(CHANNEL_CBEMM_IMAX, QuantityType.valueOf(frame.getImax(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBEMM_IMAX, QuantityType.valueOf(frame.getImax(), Units.AMPERE));
}
if (frame.getAdps() == null) {
updateState(CHANNEL_CBEMM_ADPS, UnDefType.NULL);
} else {
updateState(CHANNEL_CBEMM_ADPS, QuantityType.valueOf(frame.getAdps(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBEMM_ADPS, QuantityType.valueOf(frame.getAdps(), Units.AMPERE));
}
updateState(CHANNEL_CBEMM_IINST, QuantityType.valueOf(frame.getIinst(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBEMM_IINST, QuantityType.valueOf(frame.getIinst(), Units.AMPERE));
updateState(CHANNEL_LAST_UPDATE, new DateTimeType());
}

View File

@@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIcc;
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoAbstractCbemmElectricityMeterHandler;
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;
/**
@@ -38,6 +38,6 @@ public abstract class TeleinfoAbstractCbemmEvoIccElectricityMeterHandler
protected void updateStatesForCommonCbemmEvolutionIccChannels(FrameCbemmEvolutionIcc frame) {
updateStatesForCommonCbemmChannels(frame);
updateState(CHANNEL_CBEMM_EVOLUTION_ICC_PAPP, QuantityType.valueOf(frame.getPapp(), SmartHomeUnits.WATT));
updateState(CHANNEL_CBEMM_EVOLUTION_ICC_PAPP, QuantityType.valueOf(frame.getPapp(), Units.WATT));
}
}

View File

@@ -22,7 +22,7 @@ import org.openhab.binding.teleinfo.internal.handler.TeleinfoAbstractElectricity
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.UnDefType;
@@ -40,39 +40,35 @@ public abstract class TeleinfoAbstractCbetmElectricityMeterHandler extends Telei
}
protected void updateStatesForCommonCbetmChannels(FrameCbetm frameCbetm) {
updateState(CHANNEL_CBETM_IINST1, QuantityType.valueOf(frameCbetm.getIinst1(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_IINST2, QuantityType.valueOf(frameCbetm.getIinst2(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_IINST3, QuantityType.valueOf(frameCbetm.getIinst3(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_IINST1, QuantityType.valueOf(frameCbetm.getIinst1(), Units.AMPERE));
updateState(CHANNEL_CBETM_IINST2, QuantityType.valueOf(frameCbetm.getIinst2(), Units.AMPERE));
updateState(CHANNEL_CBETM_IINST3, QuantityType.valueOf(frameCbetm.getIinst3(), Units.AMPERE));
if (frameCbetm instanceof FrameCbetmLong) {
FrameCbetmLong frameCbetmLong = (FrameCbetmLong) frameCbetm;
updateState(CHANNEL_CBETM_FRAME_TYPE, new StringType("LONG"));
updateState(CHANNEL_CBETM_LONG_ISOUSC,
QuantityType.valueOf(frameCbetmLong.getIsousc(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_LONG_ISOUSC, QuantityType.valueOf(frameCbetmLong.getIsousc(), Units.AMPERE));
updateState(CHANNEL_CBETM_LONG_PTEC, new StringType(frameCbetmLong.getPtec().name()));
if (frameCbetmLong.getImax1() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX1, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_LONG_IMAX1,
QuantityType.valueOf(frameCbetmLong.getImax1(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_LONG_IMAX1, QuantityType.valueOf(frameCbetmLong.getImax1(), Units.AMPERE));
}
if (frameCbetmLong.getImax2() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX2, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_LONG_IMAX2,
QuantityType.valueOf(frameCbetmLong.getImax2(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_LONG_IMAX2, QuantityType.valueOf(frameCbetmLong.getImax2(), Units.AMPERE));
}
if (frameCbetmLong.getImax3() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX3, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_LONG_IMAX3,
QuantityType.valueOf(frameCbetmLong.getImax3(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_LONG_IMAX3, QuantityType.valueOf(frameCbetmLong.getImax3(), Units.AMPERE));
}
updateState(CHANNEL_CBETM_LONG_PMAX, QuantityType.valueOf(frameCbetmLong.getPmax(), SmartHomeUnits.WATT));
updateState(CHANNEL_CBETM_LONG_PAPP, QuantityType.valueOf(frameCbetmLong.getPapp(), SmartHomeUnits.WATT));
updateState(CHANNEL_CBETM_LONG_PMAX, QuantityType.valueOf(frameCbetmLong.getPmax(), Units.WATT));
updateState(CHANNEL_CBETM_LONG_PAPP, QuantityType.valueOf(frameCbetmLong.getPapp(), Units.WATT));
updateState(CHANNEL_CBETM_LONG_PPOT, new StringType(frameCbetmLong.getPpot()));
updateState(CHANNEL_CBETM_SHORT_ADIR1, UnDefType.NULL);
@@ -86,22 +82,19 @@ public abstract class TeleinfoAbstractCbetmElectricityMeterHandler extends Telei
if (frameCbetmShort.getAdir1() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR1, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_SHORT_ADIR1,
QuantityType.valueOf(frameCbetmShort.getAdir1(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_SHORT_ADIR1, QuantityType.valueOf(frameCbetmShort.getAdir1(), Units.AMPERE));
}
if (frameCbetmShort.getAdir2() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR2, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_SHORT_ADIR2,
QuantityType.valueOf(frameCbetmShort.getAdir2(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_SHORT_ADIR2, QuantityType.valueOf(frameCbetmShort.getAdir2(), Units.AMPERE));
}
if (frameCbetmShort.getAdir3() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR3, UnDefType.NULL);
} else {
updateState(CHANNEL_CBETM_SHORT_ADIR3,
QuantityType.valueOf(frameCbetmShort.getAdir3(), SmartHomeUnits.AMPERE));
updateState(CHANNEL_CBETM_SHORT_ADIR3, QuantityType.valueOf(frameCbetmShort.getAdir3(), Units.AMPERE));
}
updateState(CHANNEL_CBETM_LONG_ISOUSC, UnDefType.NULL);