diff --git a/bundles/org.connectorio.addons.binding.askoheat/src/main/java/org/connectorio/addons/binding/askoheat/internal/handler/AskoheatBridgeHandler.java b/bundles/org.connectorio.addons.binding.askoheat/src/main/java/org/connectorio/addons/binding/askoheat/internal/handler/AskoheatBridgeHandler.java index e049e83d..4442fc1b 100644 --- a/bundles/org.connectorio.addons.binding.askoheat/src/main/java/org/connectorio/addons/binding/askoheat/internal/handler/AskoheatBridgeHandler.java +++ b/bundles/org.connectorio.addons.binding.askoheat/src/main/java/org/connectorio/addons/binding/askoheat/internal/handler/AskoheatBridgeHandler.java @@ -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() { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/TAUnits.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/TAUnits.java index 04631953..924d0f7f 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/TAUnits.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/TAUnits.java @@ -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 { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/config/AnalogUnit.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/config/AnalogUnit.java index bf18e6c1..8705e0ed 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/config/AnalogUnit.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/config/AnalogUnit.java @@ -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 { @@ -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), diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/config/ComplexUnit.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/config/ComplexUnit.java index f68b4243..78bf0b11 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/config/ComplexUnit.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/config/ComplexUnit.java @@ -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. @@ -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 ); }); diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/channel/AnalogChannelHandler.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/channel/AnalogChannelHandler.java index 7e0bd8d6..4221de49 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/channel/AnalogChannelHandler.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/channel/AnalogChannelHandler.java @@ -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 { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/channel/RASChannelHandler.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/channel/RASChannelHandler.java index 1ce47ed2..943297e9 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/channel/RASChannelHandler.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/handler/channel/RASChannelHandler.java @@ -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 { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/type/TAValue.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/type/TAValue.java index d1fb3330..0eae88c7 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/type/TAValue.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/internal/type/TAValue.java @@ -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 { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/BaseAnalogValue.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/BaseAnalogValue.java index 626982b2..9817865c 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/BaseAnalogValue.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/BaseAnalogValue.java @@ -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 implements AnalogValue { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/RASValue.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/RASValue.java index d23a0d0d..d4701c7c 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/RASValue.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/RASValue.java @@ -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 { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/ShortAnalogValue.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/ShortAnalogValue.java index 0ec44a10..ea437401 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/ShortAnalogValue.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/main/java/org/connectorio/addons/binding/canopen/ta/tapi/val/ShortAnalogValue.java @@ -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 { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/test/java/org/connectorio/addons/binding/canopen/ta/tapi/val/AnalogValueTest.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/test/java/org/connectorio/addons/binding/canopen/ta/tapi/val/AnalogValueTest.java index d680afb8..ea94775e 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/test/java/org/connectorio/addons/binding/canopen/ta/tapi/val/AnalogValueTest.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/test/java/org/connectorio/addons/binding/canopen/ta/tapi/val/AnalogValueTest.java @@ -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 { diff --git a/bundles/org.connectorio.addons.binding.canopen.ta/src/test/java/org/connectorio/addons/binding/canopen/ta/tapi/val/RASValueTest.java b/bundles/org.connectorio.addons.binding.canopen.ta/src/test/java/org/connectorio/addons/binding/canopen/ta/tapi/val/RASValueTest.java index ac86680d..00db7e7b 100644 --- a/bundles/org.connectorio.addons.binding.canopen.ta/src/test/java/org/connectorio/addons/binding/canopen/ta/tapi/val/RASValueTest.java +++ b/bundles/org.connectorio.addons.binding.canopen.ta/src/test/java/org/connectorio/addons/binding/canopen/ta/tapi/val/RASValueTest.java @@ -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 { @@ -37,7 +37,7 @@ class RASValueTest { void verifyRasValue(Argument argument) { RASValue rasValue = new RASValue(argument.raw, AnalogUnit.TEMPERATURE_REGULATOR); - Quantity quantity = Quantities.getQuantity(argument.temperature, Units.CELSIUS); + Quantity 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); diff --git a/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/BandwidthStatisticCollector.java b/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/BandwidthStatisticCollector.java index 0e7ecc53..47d032c1 100644 --- a/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/BandwidthStatisticCollector.java +++ b/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/BandwidthStatisticCollector.java @@ -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. diff --git a/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/RatioStatisticCollector.java b/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/RatioStatisticCollector.java index 414b0f6e..88e4df53 100644 --- a/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/RatioStatisticCollector.java +++ b/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/RatioStatisticCollector.java @@ -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. diff --git a/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/SysfsReader.java b/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/SysfsReader.java index 882fc0d0..0c6f51e9 100644 --- a/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/SysfsReader.java +++ b/bundles/org.connectorio.addons.binding.canopen/src/main/java/org/connectorio/addons/binding/canopen/internal/statistics/SysfsReader.java @@ -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> { diff --git a/bundles/org.connectorio.addons.binding.canopen/src/test/java/org/connectorio/addons/binding/canopen/internal/statistics/BandwidthStatisticCollectorTest.java b/bundles/org.connectorio.addons.binding.canopen/src/test/java/org/connectorio/addons/binding/canopen/internal/statistics/BandwidthStatisticCollectorTest.java index e9bc69b2..8b023dce 100644 --- a/bundles/org.connectorio.addons.binding.canopen/src/test/java/org/connectorio/addons/binding/canopen/internal/statistics/BandwidthStatisticCollectorTest.java +++ b/bundles/org.connectorio.addons.binding.canopen/src/test/java/org/connectorio/addons/binding/canopen/internal/statistics/BandwidthStatisticCollectorTest.java @@ -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 { @@ -52,8 +52,8 @@ protected Quantity readStatistic() { statistic.set(Quantities.getQuantity(0, Units.BYTE)); assertThat(collector.getStatistic()) .extracting(Quantity::getValue) - .extracting(Number::intValue) - .isEqualTo(0); + .extracting(Number::doubleValue) + .isEqualTo(0.0); // one second and one byte later we expect 8 bit/s ratio. when(clock.get()).thenReturn(2000L); diff --git a/bundles/org.connectorio.addons.binding.canopen/src/test/java/org/connectorio/addons/binding/canopen/internal/statistics/RatioStatisticCollectorTest.java b/bundles/org.connectorio.addons.binding.canopen/src/test/java/org/connectorio/addons/binding/canopen/internal/statistics/RatioStatisticCollectorTest.java index f7eab5f8..6acd2d15 100644 --- a/bundles/org.connectorio.addons.binding.canopen/src/test/java/org/connectorio/addons/binding/canopen/internal/statistics/RatioStatisticCollectorTest.java +++ b/bundles/org.connectorio.addons.binding.canopen/src/test/java/org/connectorio/addons/binding/canopen/internal/statistics/RatioStatisticCollectorTest.java @@ -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 { diff --git a/bundles/org.connectorio.addons.binding.relayweblog/src/main/java/org/connectorio/addons/binding/relayweblog/internal/handler/AbstractMeterThingHandler.java b/bundles/org.connectorio.addons.binding.relayweblog/src/main/java/org/connectorio/addons/binding/relayweblog/internal/handler/AbstractMeterThingHandler.java index 09dae412..83a5df42 100644 --- a/bundles/org.connectorio.addons.binding.relayweblog/src/main/java/org/connectorio/addons/binding/relayweblog/internal/handler/AbstractMeterThingHandler.java +++ b/bundles/org.connectorio.addons.binding.relayweblog/src/main/java/org/connectorio/addons/binding/relayweblog/internal/handler/AbstractMeterThingHandler.java @@ -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; @@ -78,11 +79,11 @@ abstract class AbstractMeterThingHandler 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) ); diff --git a/bundles/org.connectorio.addons.communication.watchdog/src/main/java/org/connectorio/addons/communication/watchdog/internal/ThingCallbackWrapper.java b/bundles/org.connectorio.addons.communication.watchdog/src/main/java/org/connectorio/addons/communication/watchdog/internal/ThingCallbackWrapper.java index 84648498..2e80354c 100644 --- a/bundles/org.connectorio.addons.communication.watchdog/src/main/java/org/connectorio/addons/communication/watchdog/internal/ThingCallbackWrapper.java +++ b/bundles/org.connectorio.addons.communication.watchdog/src/main/java/org/connectorio/addons/communication/watchdog/internal/ThingCallbackWrapper.java @@ -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); } diff --git a/bundles/org.connectorio.addons.config/src/main/java/org/connectorio/addons/config/internal/ConfigMapperHack.java b/bundles/org.connectorio.addons.config/src/main/java/org/connectorio/addons/config/internal/ConfigMapperHack.java index 25148eac..e41c2b5e 100644 --- a/bundles/org.connectorio.addons.config/src/main/java/org/connectorio/addons/config/internal/ConfigMapperHack.java +++ b/bundles/org.connectorio.addons.config/src/main/java/org/connectorio/addons/config/internal/ConfigMapperHack.java @@ -20,7 +20,7 @@ public ConfigMapperHack(Class type) { @Override public T map(Map 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 diff --git a/bundles/org.connectorio.addons.io.transport.serial.purejavacomm/src/main/java/org/connectorio/addons/io/transport/serial/purejavacomm/internal/PureJavaCommSerialPort.java b/bundles/org.connectorio.addons.io.transport.serial.purejavacomm/src/main/java/org/connectorio/addons/io/transport/serial/purejavacomm/internal/PureJavaCommSerialPort.java index c2794a89..a38cc6b5 100644 --- a/bundles/org.connectorio.addons.io.transport.serial.purejavacomm/src/main/java/org/connectorio/addons/io/transport/serial/purejavacomm/internal/PureJavaCommSerialPort.java +++ b/bundles/org.connectorio.addons.io.transport.serial.purejavacomm/src/main/java/org/connectorio/addons/io/transport/serial/purejavacomm/internal/PureJavaCommSerialPort.java @@ -49,6 +49,26 @@ public void setSerialPortParams(int baudrate, int dataBits, int stopBits, int pa } } + @Override + public int getBaudRate() { + return port.getBaudRate(); + } + + @Override + public int getDataBits() { + return port.getDataBits(); + } + + @Override + public int getStopBits() { + return port.getStopBits(); + } + + @Override + public int getParity() { + return port.getParity(); + } + @Override public InputStream getInputStream() throws IOException { return port.getInputStream(); @@ -114,6 +134,31 @@ public void notifyOnParityError(boolean enable) { port.notifyOnParityError(enable); } + @Override + public void notifyOnOutputEmpty(boolean enable) { + port.notifyOnOutputEmpty(enable); + } + + @Override + public void notifyOnCTS(boolean enable) { + port.notifyOnCTS(enable); + } + + @Override + public void notifyOnDSR(boolean enable) { + port.notifyOnDSR(enable); + } + + @Override + public void notifyOnRingIndicator(boolean enable) { + port.notifyOnRingIndicator(enable); + } + + @Override + public void notifyOnCarrierDetect(boolean enable) { + port.notifyOnCarrierDetect(enable); + } + @Override public void enableReceiveTimeout(int timeout) throws UnsupportedCommOperationException, IllegalArgumentException { try { @@ -137,6 +182,11 @@ public void setFlowControlMode(int flowcontrolRtsctsOut) throws UnsupportedCommO } } + @Override + public int getFlowControlMode() { + return port.getFlowControlMode(); + } + @Override public void enableReceiveThreshold(int i) throws UnsupportedCommOperationException { try { @@ -151,4 +201,44 @@ public void setRTS(boolean rts) { port.setRTS(rts); } + @Override + public boolean isRTS() { + return port.isRTS(); + } + + @Override + public void setDTR(boolean enable) { + port.setDTR(enable); + } + + @Override + public boolean isDTR() { + return port.isDTR(); + } + + @Override + public boolean isCTS() { + return port.isCTS(); + } + + @Override + public boolean isDSR() { + return port.isDSR(); + } + + @Override + public boolean isCD() { + return port.isCD(); + } + + @Override + public boolean isRI() { + return port.isRI(); + } + + @Override + public void sendBreak(int duration) { + port.sendBreak(duration); + } + } diff --git a/bundles/org.connectorio.addons.io.transport.serial.purejavacomm/src/main/java/org/connectorio/addons/io/transport/serial/purejavacomm/internal/PureJavaCommSerialPortIdentifier.java b/bundles/org.connectorio.addons.io.transport.serial.purejavacomm/src/main/java/org/connectorio/addons/io/transport/serial/purejavacomm/internal/PureJavaCommSerialPortIdentifier.java index 76323e11..c63b8a23 100644 --- a/bundles/org.connectorio.addons.io.transport.serial.purejavacomm/src/main/java/org/connectorio/addons/io/transport/serial/purejavacomm/internal/PureJavaCommSerialPortIdentifier.java +++ b/bundles/org.connectorio.addons.io.transport.serial.purejavacomm/src/main/java/org/connectorio/addons/io/transport/serial/purejavacomm/internal/PureJavaCommSerialPortIdentifier.java @@ -43,9 +43,7 @@ public SerialPort open(String owner, int timeout) throws PortInUseException { try { return new PureJavaCommSerialPort((purejavacomm.SerialPort) identifier.open(owner, timeout)); } catch (purejavacomm.PortInUseException e) { - PortInUseException exception = new PortInUseException(); - exception.initCause(e); - throw exception; + throw new PortInUseException(e); } } diff --git a/bundles/org.connectorio.addons.norule/src/test/java/org/connectorio/addons/norule/internal/TestBasicRule.java b/bundles/org.connectorio.addons.norule/src/test/java/org/connectorio/addons/norule/internal/TestBasicRule.java index 93ff953c..03fa9df3 100644 --- a/bundles/org.connectorio.addons.norule/src/test/java/org/connectorio/addons/norule/internal/TestBasicRule.java +++ b/bundles/org.connectorio.addons.norule/src/test/java/org/connectorio/addons/norule/internal/TestBasicRule.java @@ -33,6 +33,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.openhab.core.internal.service.ReadyServiceImpl; import org.openhab.core.library.items.NumberItem; +import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.unit.Units; import org.openhab.core.thing.ThingRegistry; @@ -66,7 +67,7 @@ void checkBasicRule() throws InterruptedException { ).build(launcher).fire(); rule.getLatch().await(); - assertThat(efficiency.getState()).isEqualTo(new QuantityType<>(5, Units.ONE)); + assertThat(efficiency.getState()).isEqualTo(new DecimalType(5)); } } diff --git a/bundles/org.connectorio.addons.persistence.memory/src/main/java/org/connectorio/addons/persistence/memory/internal/MemoryPersistenceService.java b/bundles/org.connectorio.addons.persistence.memory/src/main/java/org/connectorio/addons/persistence/memory/internal/MemoryPersistenceService.java index 93034feb..9eb0b2b8 100644 --- a/bundles/org.connectorio.addons.persistence.memory/src/main/java/org/connectorio/addons/persistence/memory/internal/MemoryPersistenceService.java +++ b/bundles/org.connectorio.addons.persistence.memory/src/main/java/org/connectorio/addons/persistence/memory/internal/MemoryPersistenceService.java @@ -144,8 +144,7 @@ public void store(Item item, String alias) { } @Override - public void store(Item item, Date date, State state) { - ZonedDateTime time = ZonedDateTime.ofInstant(date.toInstant(), timeZoneProvider.getTimeZone()); + public void store(Item item, ZonedDateTime time, State state) { memorize(item.getName(), time, state); } diff --git a/bundles/org.connectorio.addons.persistence.memory/src/test/java/org/connectorio/addons/persistence/memory/internal/MemoryPersistenceServiceTest.java b/bundles/org.connectorio.addons.persistence.memory/src/test/java/org/connectorio/addons/persistence/memory/internal/MemoryPersistenceServiceTest.java index df346930..21dabeff 100644 --- a/bundles/org.connectorio.addons.persistence.memory/src/test/java/org/connectorio/addons/persistence/memory/internal/MemoryPersistenceServiceTest.java +++ b/bundles/org.connectorio.addons.persistence.memory/src/test/java/org/connectorio/addons/persistence/memory/internal/MemoryPersistenceServiceTest.java @@ -149,8 +149,8 @@ void testPaging() { void testWriteSameDate() { ZonedDateTime dateTime = createInstant(2024, 2, 22, 19, 7, 30); MemoryPersistenceService service = new MemoryPersistenceService(tz); - service.store(item2, Date.from(dateTime.toInstant()), new DecimalType(10)); - service.store(item2, Date.from(dateTime.toInstant()), new DecimalType(20)); + service.store(item2, dateTime, new DecimalType(10)); + service.store(item2, dateTime, new DecimalType(20)); assertThat(service.getItemInfo()) .hasSize(1) @@ -175,8 +175,8 @@ void testDateFilters( Integer firstValue, Integer secondValue ) { MemoryPersistenceService service = new MemoryPersistenceService(tz); - service.store(item2, Date.from(firstTimestamp.toInstant()), new DecimalType(10)); - service.store(item2, Date.from(secondTimestamp.toInstant()), new DecimalType(20)); + service.store(item2, firstTimestamp, new DecimalType(10)); + service.store(item2, secondTimestamp, new DecimalType(20)); assertThat(service.getItemInfo()) .hasSize(1) diff --git a/bundles/org.connectorio.addons.persistence.migrator/src/main/java/org/connectorio/addons/persistence/migrator/internal/operation/CopyHelper.java b/bundles/org.connectorio.addons.persistence.migrator/src/main/java/org/connectorio/addons/persistence/migrator/internal/operation/CopyHelper.java index db3413b4..5a0ded0e 100644 --- a/bundles/org.connectorio.addons.persistence.migrator/src/main/java/org/connectorio/addons/persistence/migrator/internal/operation/CopyHelper.java +++ b/bundles/org.connectorio.addons.persistence.migrator/src/main/java/org/connectorio/addons/persistence/migrator/internal/operation/CopyHelper.java @@ -36,7 +36,7 @@ public static void copy(ModifiablePersistenceService sourceService, Item sourceI continue; } ZonedDateTime timestamp = historic.getTimestamp(); - targetService.store(new StubItem(targetItem, state), Date.from(timestamp.toInstant()), state); + targetService.store(new StubItem(targetItem, state), timestamp, state); amount++; if (amount == pageSize) { page++; diff --git a/bundles/org.connectorio.addons.persistence.shell/src/main/java/org/connectorio/addons/persistence/shell/internal/PersistenceCopyItemCommand.java b/bundles/org.connectorio.addons.persistence.shell/src/main/java/org/connectorio/addons/persistence/shell/internal/PersistenceCopyItemCommand.java index 9e52239d..1db36e27 100755 --- a/bundles/org.connectorio.addons.persistence.shell/src/main/java/org/connectorio/addons/persistence/shell/internal/PersistenceCopyItemCommand.java +++ b/bundles/org.connectorio.addons.persistence.shell/src/main/java/org/connectorio/addons/persistence/shell/internal/PersistenceCopyItemCommand.java @@ -114,7 +114,7 @@ private void copy(Console console, Item from, Item to, PersistenceService servic HistoricItem historicItem = result.get(result.size() - 1); latest = historicItem.getTimestamp(); for (HistoricItem item : result) { - persistence.store(createStub(to, item.getState()), Date.from(item.getTimestamp().toInstant()), item.getState()); + persistence.store(createStub(to, item.getState()), item.getTimestamp(), item.getState()); } sum += result.size(); } while (result.size() == pageSize); diff --git a/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitBottomQuantityProfileTest.java b/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitBottomQuantityProfileTest.java index a6208aae..82672658 100644 --- a/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitBottomQuantityProfileTest.java +++ b/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitBottomQuantityProfileTest.java @@ -20,6 +20,7 @@ import static org.mockito.Mockito.when; import java.util.HashMap; +import javax.measure.MetricPrefix; import javax.measure.Unit; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -31,8 +32,9 @@ import org.openhab.core.library.types.QuantityType; import org.openhab.core.thing.profiles.ProfileCallback; import org.openhab.core.thing.profiles.ProfileContext; -import tec.uom.se.unit.MetricPrefix; -import tec.uom.se.unit.Units; +import tech.units.indriya.unit.Units; +import javax.measure.MetricPrefix; +import javax.measure.Unit; @ExtendWith(MockitoExtension.class) public class LimitBottomQuantityProfileTest { diff --git a/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitRangeQuantityProfileTest.java b/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitRangeQuantityProfileTest.java index bbe9aec1..22405b8d 100644 --- a/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitRangeQuantityProfileTest.java +++ b/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitRangeQuantityProfileTest.java @@ -31,8 +31,8 @@ import org.openhab.core.library.types.QuantityType; import org.openhab.core.thing.profiles.ProfileCallback; import org.openhab.core.thing.profiles.ProfileContext; -import tec.uom.se.unit.MetricPrefix; -import tec.uom.se.unit.Units; +import javax.measure.MetricPrefix; +import tech.units.indriya.unit.Units; @ExtendWith(MockitoExtension.class) public class LimitRangeQuantityProfileTest { diff --git a/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitTopQuantityProfileTest.java b/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitTopQuantityProfileTest.java index 220ad38a..072c81ee 100644 --- a/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitTopQuantityProfileTest.java +++ b/bundles/org.connectorio.addons.profile.boundary/src/test/java/org/connectorio/addons/profile/boundary/internal/LimitTopQuantityProfileTest.java @@ -30,7 +30,7 @@ import org.openhab.core.library.types.QuantityType; import org.openhab.core.thing.profiles.ProfileCallback; import org.openhab.core.thing.profiles.ProfileContext; -import tec.uom.se.unit.Units; +import tech.units.indriya.unit.Units; @ExtendWith(MockitoExtension.class) public class LimitTopQuantityProfileTest { diff --git a/bundles/org.connectorio.addons.profile.counter/src/main/java/org/connectorio/addons/profile/counter/internal/EnergyCounterProfile.java b/bundles/org.connectorio.addons.profile.counter/src/main/java/org/connectorio/addons/profile/counter/internal/EnergyCounterProfile.java index 57be9ec4..ec07e247 100644 --- a/bundles/org.connectorio.addons.profile.counter/src/main/java/org/connectorio/addons/profile/counter/internal/EnergyCounterProfile.java +++ b/bundles/org.connectorio.addons.profile.counter/src/main/java/org/connectorio/addons/profile/counter/internal/EnergyCounterProfile.java @@ -27,13 +27,13 @@ import org.connectorio.addons.profile.counter.internal.state.DummyStateRetriever; 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.Units; import org.openhab.core.thing.profiles.ProfileCallback; import org.openhab.core.thing.profiles.ProfileContext; import org.openhab.core.thing.profiles.ProfileTypeUID; import org.openhab.core.types.Type; -import tec.uom.se.unit.MetricPrefix; -import tec.uom.se.unit.ProductUnit; +import tech.units.indriya.unit.ProductUnit; /** * Little utility profile which, based on power reading will calculate energy consumption. diff --git a/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/ChainedProfileCallback.java b/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/ChainedProfileCallback.java new file mode 100644 index 00000000..51ff181a --- /dev/null +++ b/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/ChainedProfileCallback.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2019-2021 ConnectorIO Sp. z o.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +package org.connectorio.addons.profile.internal; + +import java.util.Iterator; +import org.openhab.core.thing.link.ItemChannelLink; +import org.openhab.core.thing.profiles.ProfileCallback; +import org.openhab.core.thing.profiles.StateProfile; +import org.openhab.core.types.Command; +import org.openhab.core.types.State; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ChainedProfileCallback implements ProfileCallback { + + private final Logger logger = LoggerFactory.getLogger(ChainedProfileCallback.class); + private final ItemChannelLink itemChannelLink; + private final Iterator profiles; + private final ProfileCallback delegate; + + public ChainedProfileCallback(ItemChannelLink itemChannelLink, Iterator profiles, ProfileCallback delegate) { + this.itemChannelLink = itemChannelLink; + this.profiles = profiles; + this.delegate = delegate; + } + + @Override + public ItemChannelLink getItemChannelLink() { + return itemChannelLink; + } + + @Override + public void handleCommand(Command command) { + if (profiles.hasNext()) { + StateProfile next = profiles.next(); + logger.trace("Passing command {} to next profile {}", command, next); + next.onCommandFromItem(command); + } else { + logger.trace("Passing command {} final callback", command); + delegate.handleCommand(command); + } + } + + @Override + public void sendCommand(Command command) { + if (profiles.hasNext()) { + StateProfile next = profiles.next(); + logger.trace("Sending command {} to next profile {}", command, next); + next.onCommandFromHandler(command); + } else { + logger.trace("Sending command {} to final callback", command); + delegate.sendCommand(command); + } + } + + @Override + public void sendUpdate(State state) { + if (profiles.hasNext()) { + StateProfile next = profiles.next(); + logger.trace("Sending state {} to next profile {}", state, next); + next.onStateUpdateFromHandler(state); + } else { + logger.trace("Sending state {} to final callback", state); + delegate.sendUpdate(state); + } + } + + public String toString() { + return "ChainedProfileCallback [" + profiles + ", " + delegate + "]"; + } +} diff --git a/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/ConnectorioProfile.java b/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/ConnectorioProfile.java index 5b4e3e74..a090d5f8 100644 --- a/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/ConnectorioProfile.java +++ b/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/ConnectorioProfile.java @@ -17,7 +17,6 @@ */ package org.connectorio.addons.profile.internal; -import java.lang.reflect.Field; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; @@ -69,7 +68,7 @@ class ConnectorioProfile implements StateProfile { throw new IllegalArgumentException("Invalid configuration"); } - ItemChannelLink link = determnineLink(callback); + ItemChannelLink link = callback.getItemChannelLink(); this.callback = new StackedProfileCallback(callback, callbackChain); for (Entry entry : config.entrySet()) { @@ -99,36 +98,6 @@ class ConnectorioProfile implements StateProfile { } } - private ItemChannelLink determnineLink(ProfileCallback callback) { - Class clazz = callback.getClass(); - - Field linkField = null; - do { - try { - linkField = clazz.getDeclaredField("link"); - } catch (NoSuchFieldException e) { - clazz = clazz.getSuperclass(); - } - } while (linkField == null && clazz != Object.class); - - if (linkField == null) { - return null; - } - - if (ItemChannelLink.class.equals(linkField.getType())) { - try { - linkField.setAccessible(true); - ItemChannelLink link = (ItemChannelLink) linkField.get(callback); - if (link != null && link.getItemName() != null) { - return link; - } - } catch (IllegalAccessException e) { - logger.warn("Could not extract link information from profile callback {}.", callback, e); - } - } - return null; - } - @Override public ProfileTypeUID getProfileTypeUID() { return ConnectorioProfiles.PROFILE; diff --git a/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/NavigableCallback.java b/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/NavigableCallback.java index 9159e1e4..47daba1a 100644 --- a/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/NavigableCallback.java +++ b/bundles/org.connectorio.addons.profile/src/main/java/org/connectorio/addons/profile/internal/NavigableCallback.java @@ -57,6 +57,11 @@ public void sendUpdate(State state) { stack.sendUpdate(index + 1, state); } + @Override + public ItemChannelLink getItemChannelLink() { + return link; + } + @Override public String toString() { return "Chained Callback [" + link + " at index " + index + "]";