Skip to content

Commit

Permalink
Update to openHAB 3.4 release.
Browse files Browse the repository at this point in the history
Signed-off-by: Łukasz Dywicki <[email protected]>
  • Loading branch information
splatch committed Feb 29, 2024
1 parent a656b48 commit 67bbceb
Show file tree
Hide file tree
Showing 34 changed files with 174 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public void run() {
ValueBlock params = client.getValueBlock();
getCallback().stateUpdated(new ChannelUID(getThing().getUID(), "status"), new DecimalType(params.getStatus()));
getCallback().stateUpdated(new ChannelUID(getThing().getUID(), "load"), QuantityType.valueOf(params.getLoad(), Units.WATT));
getCallback().stateUpdated(new ChannelUID(getThing().getUID(), "temperatureLimit"), QuantityType.valueOf(params.getTemperatureLimit(), tec.uom.se.unit.Units.CELSIUS));
getCallback().stateUpdated(new ChannelUID(getThing().getUID(), "temperatureSensor0"), QuantityType.valueOf(params.getTemperatureSensor0(), tec.uom.se.unit.Units.CELSIUS));
getCallback().stateUpdated(new ChannelUID(getThing().getUID(), "maximumTemperature"), QuantityType.valueOf(params.getMaximumTemperature(), tec.uom.se.unit.Units.CELSIUS));
getCallback().stateUpdated(new ChannelUID(getThing().getUID(), "temperatureLimit"), QuantityType.valueOf(params.getTemperatureLimit(), tech.units.indriya.unit.Units.CELSIUS));
getCallback().stateUpdated(new ChannelUID(getThing().getUID(), "temperatureSensor0"), QuantityType.valueOf(params.getTemperatureSensor0(), tech.units.indriya.unit.Units.CELSIUS));
getCallback().stateUpdated(new ChannelUID(getThing().getUID(), "maximumTemperature"), QuantityType.valueOf(params.getMaximumTemperature(), tech.units.indriya.unit.Units.CELSIUS));
}
}, 1000L, getRefreshInterval(), TimeUnit.MILLISECONDS));
tasks.add(scheduler.scheduleAtFixedRate(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import javax.measure.quantity.Length;
import org.openhab.core.library.unit.MetricPrefix;
import org.openhab.core.library.unit.SIUnits;
import tec.uom.se.AbstractConverter;
import tec.uom.se.AbstractUnit;
import tec.uom.se.format.SimpleUnitFormat;
import tec.uom.se.unit.TransformedUnit;
import tech.units.indriya.AbstractUnit;
import tech.units.indriya.format.SimpleUnitFormat;
import tech.units.indriya.function.AbstractConverter;
import tech.units.indriya.unit.TransformedUnit;

public class TAUnits {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.openhab.core.library.unit.MetricPrefix;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.Units;
import tec.uom.se.AbstractUnit;
import tech.units.indriya.AbstractUnit;

public enum AnalogUnit implements TAUnit {

Expand Down Expand Up @@ -58,14 +58,14 @@ public enum AnalogUnit implements TAUnit {
/* 22 analog */ LITRE_PER_MINUTE (22, Units.LITRE_PER_MINUTE, 1),
/* 23 analog */ BAR (23, Units.BAR, 0.01),
/* 24 analog */ POWER_FACTOR(24, AbstractUnit.ONE, 0.01),
/* 25 analog */ KILO_METRE (25, MetricPrefix.KILO(tec.uom.se.unit.Units.METRE), 1),
/* 26 analog */ METRE (26, tec.uom.se.unit.Units.METRE, 1),
/* 27 analog */ MILLIMETER (27, MetricPrefix.MILLI(tec.uom.se.unit.Units.METRE), 1),
/* 28 analog */ CUBIC_METRE (28, tec.uom.se.unit.Units.CUBIC_METRE, 1),
/* 29 analog */ HERTZ_KM_HOUR (29, Units.HERTZ.divide(MetricPrefix.KILO(tec.uom.se.unit.Units.METRE).divide(Units.HOUR)), 1),
/* 30 analog */ HERTZ_M_SECOND (30, Units.HERTZ.divide(tec.uom.se.unit.Units.METRE.divide(Units.SECOND)), 1),
/* 25 analog */ KILO_METRE (25, MetricPrefix.KILO(SIUnits.METRE), 1),
/* 26 analog */ METRE (26, SIUnits.METRE, 1),
/* 27 analog */ MILLIMETER (27, MetricPrefix.MILLI(SIUnits.METRE), 1),
/* 28 analog */ CUBIC_METRE (28, SIUnits.CUBIC_METRE, 1),
/* 29 analog */ HERTZ_KM_HOUR (29, Units.HERTZ.divide(MetricPrefix.KILO(SIUnits.METRE).divide(Units.HOUR)), 1),
/* 30 analog */ HERTZ_M_SECOND (30, Units.HERTZ.divide(SIUnits.METRE.divide(Units.SECOND)), 1),
/* 31 analog */ KILOWATT_PER_IMPULSE (31, Units.KILOWATT_HOUR.divide(TAUnits.IMPULSE), 1),
/* 32 analog */ CUBICMETRE_PER_IMPULSE (32, tec.uom.se.unit.Units.CUBIC_METRE.divide(TAUnits.IMPULSE), 1),
/* 32 analog */ CUBICMETRE_PER_IMPULSE (32, SIUnits.CUBIC_METRE.divide(TAUnits.IMPULSE), 1),
/* 33 analog */ MILLIMETRE_PER_IMPULSE(33, TAUnits.MILLIMETRE.divide(TAUnits.IMPULSE), 1),
/* 34 analog */ LITER_PER_IMPULSE (34, Units.LITRE.divide(TAUnits.IMPULSE), 1),
/* 35 analog */ LITER_PER_DAY (35, Units.LITRE.divide(Units.DAY), 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.stream.Collectors;

import org.connectorio.addons.binding.canopen.ta.internal.type.TAUnit;
import tec.uom.se.quantity.Quantities;
import tec.uom.se.unit.Units;
import org.openhab.core.library.unit.SIUnits;
import tech.units.indriya.quantity.Quantities;

/**
* Compound units whcih require additional parsing. Result of computation is list and not single value.
Expand All @@ -38,7 +38,7 @@ public enum ComplexUnit implements TAUnit {

double value = 0.1 * (raw & 0x1FF) * (negative ? -1 : 1);
return Arrays.asList(
Quantities.getQuantity(value, Units.CELSIUS),
Quantities.getQuantity(value, SIUnits.CELSIUS),
(raw & 0x600) >> 9
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tec.uom.se.AbstractUnit;
import tech.units.indriya.AbstractUnit;

@Deprecated
public class TAUVR16x2ThingHandler extends PollingPlc4xThingHandler<PlcConnection, CoBridgeHandler<?>, CoNodeConfig>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.openhab.core.thing.binding.ThingHandlerCallback;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.quantity.Quantities;

public class AnalogChannelHandler extends BaseChannelHandler<AnalogValue, AnalogUnit, AnalogObjectConfig> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.openhab.core.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.quantity.Quantities;

public class RASChannelHandler extends BaseChannelHandler<RASValue, AnalogUnit, AnalogObjectConfig> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.connectorio.addons.binding.canopen.ta.internal.config.AnalogUnit;
import org.connectorio.addons.binding.canopen.ta.internal.config.ComplexUnit;
import org.connectorio.addons.binding.canopen.ta.internal.config.DigitalUnit;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.quantity.Quantities;

public class TAValue {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import javax.measure.Quantity;
import org.connectorio.addons.binding.canopen.ta.internal.config.AnalogUnit;
import org.connectorio.addons.binding.canopen.ta.internal.type.TAUnit;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.quantity.Quantities;

public abstract class BaseAnalogValue<T extends Number> implements AnalogValue {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.connectorio.addons.binding.canopen.ta.internal.config.AnalogUnit;
import org.connectorio.addons.binding.canopen.ta.internal.type.TAUnit;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.quantity.Quantities;

public class RASValue extends ShortAnalogValue {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import javax.measure.Quantity;
import org.connectorio.addons.binding.canopen.ta.internal.config.AnalogUnit;
import org.connectorio.addons.binding.canopen.ta.internal.type.TAUnit;
import tec.uom.se.quantity.Quantities;

public class ShortAnalogValue extends BaseAnalogValue<Short> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.connectorio.addons.binding.canopen.ta.internal.config.AnalogUnit;
import org.junit.jupiter.api.Test;
import org.openhab.core.library.unit.Units;
import tec.uom.se.ComparableQuantity;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.ComparableQuantity;
import tech.units.indriya.quantity.Quantities;

class AnalogValueTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.connectorio.addons.binding.canopen.ta.internal.config.AnalogUnit;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import tec.uom.se.quantity.Quantities;
import tec.uom.se.unit.Units;
import org.openhab.core.library.unit.SIUnits;
import tech.units.indriya.quantity.Quantities;

class RASValueTest {

Expand All @@ -37,7 +37,7 @@ class RASValueTest {
void verifyRasValue(Argument argument) {
RASValue rasValue = new RASValue(argument.raw, AnalogUnit.TEMPERATURE_REGULATOR);

Quantity<Temperature> quantity = Quantities.getQuantity(argument.temperature, Units.CELSIUS);
Quantity<Temperature> quantity = Quantities.getQuantity(argument.temperature, SIUnits.CELSIUS);
assertThat(rasValue.getValue().getValue().doubleValue())
.isCloseTo(quantity.getValue().doubleValue(), Percentage.withPercentage(1));
assertThat(rasValue.getMode()).isEqualTo(argument.mode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.openhab.core.library.dimension.DataAmount;
import org.openhab.core.library.dimension.DataTransferRate;
import org.openhab.core.library.unit.Units;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.quantity.Quantities;

/**
* Bit ratio calculation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.function.Supplier;
import javax.measure.Quantity;
import javax.measure.quantity.Dimensionless;
import tec.uom.se.AbstractUnit;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.AbstractUnit;
import tech.units.indriya.quantity.Quantities;

/**
* Ratio calculation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import javax.measure.Unit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.quantity.Quantities;

public class SysfsReader<Q extends Quantity<Q>> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.openhab.core.library.dimension.DataAmount;
import org.openhab.core.library.dimension.DataTransferRate;
import org.openhab.core.library.unit.Units;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.quantity.Quantities;

@ExtendWith(MockitoExtension.class)
class BandwidthStatisticCollectorTest {
Expand All @@ -52,7 +52,7 @@ protected Quantity<DataAmount> readStatistic() {
statistic.set(Quantities.getQuantity(0, Units.BYTE));
assertThat(collector.getStatistic())
.extracting(Quantity::getValue)
.isEqualTo(0.0);
.isEqualTo(0);

// one second and one byte later we expect 8 bit/s ratio.
when(clock.get()).thenReturn(2000L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import tec.uom.se.AbstractUnit;
import tec.uom.se.quantity.Quantities;
import tech.units.indriya.AbstractUnit;
import tech.units.indriya.quantity.Quantities;

@ExtendWith(MockitoExtension.class)
class RatioStatisticCollectorTest {
Expand All @@ -52,14 +52,14 @@ protected Quantity<Dimensionless> readStatistic() {
Quantity<?> collectorStatistic = collector.getStatistic();
assertThat(collectorStatistic)
.extracting(Quantity::getValue)
.isEqualTo(0.0);
.isEqualTo(0);

when(clock.get()).thenReturn(2000L);
this.statistic.set(Quantities.getQuantity(1001, AbstractUnit.ONE));
collectorStatistic = collector.getStatistic();
assertThat(collectorStatistic)
.extracting(Quantity::getValue)
.isEqualTo(1.0);
.isEqualTo(1);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.MetricPrefix;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
Expand All @@ -78,11 +79,11 @@ abstract class AbstractMeterThingHandler<B extends WeblogBridgeHandler, C extend
.toFormatter();

private final static Map<String, MappingEntry> MAPPING = Map.of(
"kW", new MappingEntry(Power.class, MetricPrefix.KILO(tec.uom.se.unit.Units.WATT)),
"kW", new MappingEntry(Power.class, MetricPrefix.KILO(Units.WATT)),
"kWh", new MappingEntry(Energy.class, Units.KILOWATT_HOUR),
"m^3", new MappingEntry(Volume.class, tec.uom.se.unit.Units.CUBIC_METRE),
"m^3", new MappingEntry(Volume.class, SIUnits.CUBIC_METRE),
"m^3/h", new MappingEntry(VolumetricFlowRate.class, Units.CUBICMETRE_PER_HOUR),
"C", new MappingEntry(Temperature.class, tec.uom.se.unit.Units.CELSIUS),
"C", new MappingEntry(Temperature.class, SIUnits.CELSIUS),
"h", new MappingEntry(Time.class, Units.HOUR),
"s", new MappingEntry(Time.class, Units.SECOND)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ public ConfigDescription getConfigDescription(ThingTypeUID thingTypeUID) {
}

@Override
public void migrateThingType(Thing thing, ThingTypeUID thingTypeUID,
Configuration configuration) {
public void migrateThingType(Thing thing, ThingTypeUID thingTypeUID, Configuration configuration) {
callback.migrateThingType(thing, thingTypeUID, configuration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ConfigMapperHack(Class<T> type) {

@Override
public T map(Map<String, Object> configuration) {
return org.openhab.core.config.core.internal.ConfigMapper.as(cleanup(configuration), type);
return org.openhab.core.config.core.ConfigParser.configurationAs(cleanup(configuration), type);
}

@Override
Expand Down
Loading

0 comments on commit 67bbceb

Please sign in to comment.