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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
208 changed files with 1087 additions and 1169 deletions

View File

@ -27,7 +27,7 @@ import javax.measure.quantity.Temperature;
import org.eclipse.jdt.annotation.NonNullByDefault;
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.thing.ThingTypeUID;
import org.openhab.core.types.State;
@ -80,6 +80,6 @@ public class AirQualityBindingConstants {
// Units of measurement of the data delivered by the API
public static final Unit<Temperature> API_TEMPERATURE_UNIT = SIUnits.CELSIUS;
public static final Unit<Dimensionless> API_HUMIDITY_UNIT = SmartHomeUnits.PERCENT;
public static final Unit<Dimensionless> API_HUMIDITY_UNIT = Units.PERCENT;
public static final Unit<Pressure> API_PRESSURE_UNIT = HECTO(SIUnits.PASCAL);
}

View File

@ -17,9 +17,9 @@ import static org.openhab.core.library.unit.MetricPrefix.MICRO;
import static org.openhab.core.library.unit.SIUnits.CELSIUS;
import static org.openhab.core.library.unit.SIUnits.CUBIC_METRE;
import static org.openhab.core.library.unit.SIUnits.GRAM;
import static org.openhab.core.library.unit.SmartHomeUnits.ONE;
import static org.openhab.core.library.unit.SmartHomeUnits.PARTS_PER_MILLION;
import static org.openhab.core.library.unit.SmartHomeUnits.PERCENT;
import static org.openhab.core.library.unit.Units.ONE;
import static org.openhab.core.library.unit.Units.PARTS_PER_MILLION;
import static org.openhab.core.library.unit.Units.PERCENT;
import java.io.IOException;
import java.math.BigDecimal;

View File

@ -68,7 +68,7 @@ import org.openhab.core.library.types.PlayPauseType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.RewindFastforwardType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
@ -330,7 +330,7 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
if (command instanceof QuantityType<?>) {
QuantityType<?> value = (QuantityType<?>) command;
@Nullable
QuantityType<?> seconds = value.toUnit(SmartHomeUnits.SECOND);
QuantityType<?> seconds = value.toUnit(Units.SECOND);
if (seconds != null) {
mediaPosition = seconds.longValue();
}
@ -1183,10 +1183,9 @@ public class EchoHandler extends BaseThingHandler implements IEchoThingHandler {
} else {
updateState(CHANNEL_MEDIA_PROGRESS, UnDefType.UNDEF);
}
updateState(CHANNEL_MEDIA_PROGRESS_TIME,
new QuantityType<>(currentPlayTimeMs / 1000, SmartHomeUnits.SECOND));
updateState(CHANNEL_MEDIA_PROGRESS_TIME, new QuantityType<>(currentPlayTimeMs / 1000, Units.SECOND));
if (updateMediaLength) {
updateState(CHANNEL_MEDIA_LENGTH, new QuantityType<>(mediaLengthMs / 1000, SmartHomeUnits.SECOND));
updateState(CHANNEL_MEDIA_LENGTH, new QuantityType<>(mediaLengthMs / 1000, Units.SECOND));
}
} else {
updateState(CHANNEL_MEDIA_PROGRESS, UnDefType.UNDEF);

View File

@ -22,7 +22,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.ambientweather.internal.handler.AmbientWeatherStationHandler;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -94,14 +94,14 @@ public class RemoteSensor {
reader.nextDouble(), ImperialUnits.FAHRENHEIT);
} else if (("humidity" + sensorNumber).equals(name)) {
handler.updateQuantity(CHGRP_REMOTE_SENSOR + sensorNumber, CH_HUMIDITY, reader.nextDouble(),
SmartHomeUnits.PERCENT);
Units.PERCENT);
} else if (("soiltemp" + sensorNumber).equals(name)) {
handler.updateQuantity(CHGRP_REMOTE_SENSOR + sensorNumber, CH_SOIL_TEMPERATURE, reader.nextDouble(),
ImperialUnits.FAHRENHEIT);
} else if (("soilhum" + sensorNumber).equals(name)) {
Double soilMoisture = reader.nextDouble();
handler.updateQuantity(CHGRP_REMOTE_SENSOR + sensorNumber, CH_SOIL_MOISTURE, soilMoisture,
SmartHomeUnits.PERCENT);
Units.PERCENT);
handler.updateString(CHGRP_REMOTE_SENSOR + sensorNumber, CH_SOIL_MOISTURE_LEVEL,
convertSoilMoistureToString(soilMoisture));
} else if (("batt" + sensorNumber).equals(name)) {

View File

@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ambientweather.internal.handler.AmbientWeatherStationHandler;
import org.openhab.binding.ambientweather.internal.model.EventDataJson;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* The {@link Ws0900ipProcessor} is responsible for updating
@ -60,14 +60,14 @@ public class Ws0900ipProcessor extends AbstractProcessor {
handler.updateString(channelGroupId, CH_BATTERY_INDICATOR, NOT_APPLICABLE);
handler.updateQuantity(channelGroupId, CH_TEMPERATURE, data.tempf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_DEW_POINT, data.dewPoint, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, SmartHomeUnits.PERCENT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, Units.PERCENT);
handler.updateQuantity(channelGroupId, CH_PRESSURE_ABSOLUTE, data.baromabsin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_PRESSURE_RELATIVE, data.baromrelin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_WIND_SPEED, data.windspeedmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, SmartHomeUnits.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, Units.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_GUST, data.windgustmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_GUST_MAX_DAILY, data.maxdailygust, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, SmartHomeUnits.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, Units.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_DAY, data.dailyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_WEEK, data.weeklyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_MONTH, data.monthlyrainin, ImperialUnits.INCH);
@ -86,7 +86,7 @@ public class Ws0900ipProcessor extends AbstractProcessor {
// Update indoor sensor channels
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_TEMPERATURE, data.tempinf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, SmartHomeUnits.PERCENT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, Units.PERCENT);
handler.updateString(CHGRP_INDOOR_SENSOR, CH_BATTERY_INDICATOR, NOT_APPLICABLE);
}
}

View File

@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ambientweather.internal.handler.AmbientWeatherStationHandler;
import org.openhab.binding.ambientweather.internal.model.EventDataJson;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* The {@link Ws1400ipProcessor} is responsible for updating
@ -61,16 +61,16 @@ public class Ws1400ipProcessor extends AbstractProcessor {
handler.updateQuantity(channelGroupId, CH_TEMPERATURE, data.tempf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_FEELING_TEMPERATURE, data.feelsLike, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_DEW_POINT, data.dewPoint, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, SmartHomeUnits.PERCENT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, Units.PERCENT);
handler.updateQuantity(channelGroupId, CH_PRESSURE_ABSOLUTE, data.baromabsin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_PRESSURE_RELATIVE, data.baromrelin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_WIND_SPEED, data.windspeedmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, SmartHomeUnits.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, Units.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_GUST, data.windgustmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_GUST_MAX_DAILY, data.maxdailygust, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_SOLAR_RADIATION, data.solarradiation, SmartHomeUnits.IRRADIANCE);
handler.updateQuantity(channelGroupId, CH_SOLAR_RADIATION, data.solarradiation, Units.IRRADIANCE);
handler.updateNumber(channelGroupId, CH_UV_INDEX, data.uv);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, SmartHomeUnits.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, Units.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_DAY, data.dailyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_WEEK, data.weeklyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_MONTH, data.monthlyrainin, ImperialUnits.INCH);
@ -93,7 +93,7 @@ public class Ws1400ipProcessor extends AbstractProcessor {
// Update indoor sensor channels
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_TEMPERATURE, data.tempinf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, SmartHomeUnits.PERCENT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, Units.PERCENT);
handler.updateString(CHGRP_INDOOR_SENSOR, CH_BATTERY_INDICATOR, data.battin);
// Update channels for the remote sensors

View File

@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ambientweather.internal.handler.AmbientWeatherStationHandler;
import org.openhab.binding.ambientweather.internal.model.EventDataJson;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* The {@link Ws2902aProcessor} is responsible for updating
@ -61,16 +61,16 @@ public class Ws2902aProcessor extends AbstractProcessor {
handler.updateQuantity(channelGroupId, CH_TEMPERATURE, data.tempf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_FEELING_TEMPERATURE, data.feelsLike, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_DEW_POINT, data.dewPoint, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, SmartHomeUnits.PERCENT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, Units.PERCENT);
handler.updateQuantity(channelGroupId, CH_PRESSURE_ABSOLUTE, data.baromabsin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_PRESSURE_RELATIVE, data.baromrelin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_WIND_SPEED, data.windspeedmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, SmartHomeUnits.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, Units.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_GUST, data.windgustmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_GUST_MAX_DAILY, data.maxdailygust, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_SOLAR_RADIATION, data.solarradiation, SmartHomeUnits.IRRADIANCE);
handler.updateQuantity(channelGroupId, CH_SOLAR_RADIATION, data.solarradiation, Units.IRRADIANCE);
handler.updateNumber(channelGroupId, CH_UV_INDEX, data.uv);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, SmartHomeUnits.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, Units.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_DAY, data.dailyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_WEEK, data.weeklyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_MONTH, data.monthlyrainin, ImperialUnits.INCH);
@ -93,7 +93,7 @@ public class Ws2902aProcessor extends AbstractProcessor {
// Update indoor sensor channels
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_TEMPERATURE, data.tempinf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, SmartHomeUnits.PERCENT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, Units.PERCENT);
handler.updateString(CHGRP_INDOOR_SENSOR, CH_BATTERY_INDICATOR, NOT_APPLICABLE);
}
}

View File

@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ambientweather.internal.handler.AmbientWeatherStationHandler;
import org.openhab.binding.ambientweather.internal.model.EventDataJson;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* The {@link Ws2902bProcessor} is responsible for updating
@ -61,16 +61,16 @@ public class Ws2902bProcessor extends AbstractProcessor {
handler.updateQuantity(channelGroupId, CH_TEMPERATURE, data.tempf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_FEELING_TEMPERATURE, data.feelsLike, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_DEW_POINT, data.dewPoint, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, SmartHomeUnits.PERCENT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidity, Units.PERCENT);
handler.updateQuantity(channelGroupId, CH_PRESSURE_ABSOLUTE, data.baromabsin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_PRESSURE_RELATIVE, data.baromrelin, ImperialUnits.INCH_OF_MERCURY);
handler.updateQuantity(channelGroupId, CH_WIND_SPEED, data.windspeedmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, SmartHomeUnits.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_DIRECTION_DEGREES, data.winddir, Units.DEGREE_ANGLE);
handler.updateQuantity(channelGroupId, CH_WIND_GUST, data.windgustmph, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_WIND_GUST_MAX_DAILY, data.maxdailygust, ImperialUnits.MILES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_SOLAR_RADIATION, data.solarradiation, SmartHomeUnits.IRRADIANCE);
handler.updateQuantity(channelGroupId, CH_SOLAR_RADIATION, data.solarradiation, Units.IRRADIANCE);
handler.updateNumber(channelGroupId, CH_UV_INDEX, data.uv);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, SmartHomeUnits.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_HOURLY_RATE, data.hourlyrainin, Units.INCHES_PER_HOUR);
handler.updateQuantity(channelGroupId, CH_RAIN_DAY, data.dailyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_WEEK, data.weeklyrainin, ImperialUnits.INCH);
handler.updateQuantity(channelGroupId, CH_RAIN_MONTH, data.monthlyrainin, ImperialUnits.INCH);
@ -93,7 +93,7 @@ public class Ws2902bProcessor extends AbstractProcessor {
// Update indoor sensor channels
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_TEMPERATURE, data.tempinf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, SmartHomeUnits.PERCENT);
handler.updateQuantity(CHGRP_INDOOR_SENSOR, CH_HUMIDITY, data.humidityin, Units.PERCENT);
handler.updateString(CHGRP_INDOOR_SENSOR, CH_BATTERY_INDICATOR, NOT_APPLICABLE);
// Update channels for the remote sensors

View File

@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ambientweather.internal.handler.AmbientWeatherStationHandler;
import org.openhab.binding.ambientweather.internal.model.EventDataJson;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* The {@link Ws8482Processor} is responsible for updating
@ -59,7 +59,7 @@ public class Ws8482Processor extends AbstractProcessor {
handler.updateDate(channelGroupId, CH_OBSERVATION_TIME, data.date);
handler.updateString(channelGroupId, CH_BATTERY_INDICATOR, data.battout);
handler.updateQuantity(channelGroupId, CH_TEMPERATURE, data.tempinf, ImperialUnits.FAHRENHEIT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidityin, SmartHomeUnits.PERCENT);
handler.updateQuantity(channelGroupId, CH_HUMIDITY, data.humidityin, Units.PERCENT);
// Update the remote sensor channels
remoteSensor.updateChannels(handler, jsonData);

View File

@ -19,7 +19,7 @@ import javax.measure.quantity.Dimensionless;
import javax.measure.quantity.Time;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* Holds the calculates moon phase informations.
@ -99,7 +99,7 @@ public class MoonPhase {
* Returns the age in days.
*/
public QuantityType<Time> getAge() {
return new QuantityType<>(age, SmartHomeUnits.DAY);
return new QuantityType<>(age, Units.DAY);
}
/**
@ -113,7 +113,7 @@ public class MoonPhase {
* Returns the illumination.
*/
public QuantityType<Dimensionless> getIllumination() {
return new QuantityType<>(illumination, SmartHomeUnits.PERCENT);
return new QuantityType<>(illumination, Units.PERCENT);
}
/**
@ -141,7 +141,7 @@ public class MoonPhase {
* Returns the age in degree.
*/
public QuantityType<Angle> getAgeDegree() {
return new QuantityType<>(ageDegree, SmartHomeUnits.DEGREE_ANGLE);
return new QuantityType<>(ageDegree, Units.DEGREE_ANGLE);
}
/**
@ -155,7 +155,7 @@ public class MoonPhase {
* Returns the age in percent.
*/
public QuantityType<Dimensionless> getAgePercent() {
return new QuantityType<>(agePercent, SmartHomeUnits.PERCENT);
return new QuantityType<>(agePercent, Units.PERCENT);
}
/**

View File

@ -15,7 +15,7 @@ package org.openhab.binding.astro.internal.model;
import javax.measure.quantity.Angle;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* Holds the calculated azimuth and elevation.
@ -43,7 +43,7 @@ public class Position {
* Returns the azimuth.
*/
public QuantityType<Angle> getAzimuth() {
return new QuantityType<>(azimuth, SmartHomeUnits.DEGREE_ANGLE);
return new QuantityType<>(azimuth, Units.DEGREE_ANGLE);
}
/**
@ -57,7 +57,7 @@ public class Position {
* Returns the elevation.
*/
public QuantityType<Angle> getElevation() {
return new QuantityType<>(elevation, SmartHomeUnits.DEGREE_ANGLE);
return new QuantityType<>(elevation, Units.DEGREE_ANGLE);
}
public double getElevationAsDouble() {

View File

@ -14,7 +14,7 @@ package org.openhab.binding.astro.internal.model;
import org.openhab.core.library.dimension.Intensity;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* Holds the calculated direct, diffuse and total
@ -62,20 +62,20 @@ public class Radiation {
* Returns the total radiation.
*/
public QuantityType<Intensity> getTotal() {
return new QuantityType<>(total, SmartHomeUnits.IRRADIANCE);
return new QuantityType<>(total, Units.IRRADIANCE);
}
/**
* Returns the direct radiation.
*/
public QuantityType<Intensity> getDirect() {
return new QuantityType<>(direct, SmartHomeUnits.IRRADIANCE);
return new QuantityType<>(direct, Units.IRRADIANCE);
}
/**
* Returns the diffuse radiation.
*/
public QuantityType<Intensity> getDiffuse() {
return new QuantityType<>(diffuse, SmartHomeUnits.IRRADIANCE);
return new QuantityType<>(diffuse, Units.IRRADIANCE);
}
}

View File

@ -20,7 +20,7 @@ import javax.measure.quantity.Time;
import org.openhab.binding.astro.internal.util.DateTimeUtils;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* Range class which holds a start and a end calendar object.
@ -63,10 +63,10 @@ public class Range {
return null;
}
if (start.after(end)) {
return new QuantityType<>(0, SmartHomeUnits.MINUTE);
return new QuantityType<>(0, Units.MINUTE);
}
return new QuantityType<>(end.getTimeInMillis() - start.getTimeInMillis(), MILLI(SmartHomeUnits.SECOND))
.toUnit(SmartHomeUnits.MINUTE);
return new QuantityType<>(end.getTimeInMillis() - start.getTimeInMillis(), MILLI(Units.SECOND))
.toUnit(Units.MINUTE);
}
/**

View File

@ -20,7 +20,7 @@ import javax.measure.quantity.Time;
import org.openhab.binding.astro.internal.util.DateTimeUtils;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* Holds the season dates of the year and the current name.
@ -129,7 +129,7 @@ public class Season {
public QuantityType<Time> getTimeLeft() {
Calendar now = Calendar.getInstance();
Calendar next = getNextSeason();
return new QuantityType<>(next.getTimeInMillis() - now.getTimeInMillis(), MILLI(SmartHomeUnits.SECOND))
.toUnit(SmartHomeUnits.DAY);
return new QuantityType<>(next.getTimeInMillis() - now.getTimeInMillis(), MILLI(Units.SECOND))
.toUnit(Units.DAY);
}
}

View File

@ -39,7 +39,7 @@ import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
@ -255,7 +255,7 @@ public class AutomowerHandler extends BaseThingHandler {
updateState(CHANNEL_STATUS_LAST_UPDATE,
new DateTimeType(ZonedDateTime.ofInstant(statusTimestamp, ZoneId.systemDefault())));
updateState(CHANNEL_STATUS_BATTERY, new QuantityType<Dimensionless>(
mower.getAttributes().getBattery().getBatteryPercent(), SmartHomeUnits.PERCENT));
mower.getAttributes().getBattery().getBatteryPercent(), Units.PERCENT));
updateState(CHANNEL_STATUS_ERROR_CODE, new DecimalType(mower.getAttributes().getMower().getErrorCode()));

View File

@ -46,7 +46,7 @@ import org.openhab.core.library.types.OpenClosedType;
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.thing.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
@ -222,11 +222,9 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
private void updatePowermeter(@Nullable PowerMeterModel powerMeterModel) {
if (powerMeterModel != null) {
updateThingChannelState(CHANNEL_ENERGY,
new QuantityType<>(powerMeterModel.getEnergy(), SmartHomeUnits.WATT_HOUR));
updateThingChannelState(CHANNEL_POWER, new QuantityType<>(powerMeterModel.getPower(), SmartHomeUnits.WATT));
updateThingChannelState(CHANNEL_VOLTAGE,
new QuantityType<>(powerMeterModel.getVoltage(), SmartHomeUnits.VOLT));
updateThingChannelState(CHANNEL_ENERGY, new QuantityType<>(powerMeterModel.getEnergy(), Units.WATT_HOUR));
updateThingChannelState(CHANNEL_POWER, new QuantityType<>(powerMeterModel.getPower(), Units.WATT));
updateThingChannelState(CHANNEL_VOLTAGE, new QuantityType<>(powerMeterModel.getVoltage(), Units.VOLT));
}
}

View File

@ -35,7 +35,7 @@ import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
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;
@ -159,11 +159,9 @@ public class Powerline546EHandler extends AVMFritzBaseBridgeHandler implements F
private void updatePowermeter(@Nullable PowerMeterModel powerMeterModel) {
if (powerMeterModel != null) {
updateThingChannelState(CHANNEL_ENERGY,
new QuantityType<>(powerMeterModel.getEnergy(), SmartHomeUnits.WATT_HOUR));
updateThingChannelState(CHANNEL_POWER, new QuantityType<>(powerMeterModel.getPower(), SmartHomeUnits.WATT));
updateThingChannelState(CHANNEL_VOLTAGE,
new QuantityType<>(powerMeterModel.getVoltage(), SmartHomeUnits.VOLT));
updateThingChannelState(CHANNEL_ENERGY, new QuantityType<>(powerMeterModel.getEnergy(), Units.WATT_HOUR));
updateThingChannelState(CHANNEL_POWER, new QuantityType<>(powerMeterModel.getPower(), Units.WATT));
updateThingChannelState(CHANNEL_VOLTAGE, new QuantityType<>(powerMeterModel.getVoltage(), Units.VOLT));
}
}

View File

@ -20,14 +20,14 @@ import javax.measure.quantity.Dimensionless;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.bluetooth.BluetoothBindingConstants;
import org.openhab.core.library.dimension.Density;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.ThingTypeUID;
import tec.uom.se.format.SimpleUnitFormat;
import tec.uom.se.function.RationalConverter;
import tec.uom.se.unit.ProductUnit;
import tec.uom.se.unit.TransformedUnit;
import tec.uom.se.unit.Units;
/**
* The {@link AirthingsBindingConstants} class defines common constants, which are
@ -51,10 +51,10 @@ public class AirthingsBindingConstants {
public static final String CHANNEL_ID_RADON_ST_AVG = "radon_st_avg";
public static final String CHANNEL_ID_RADON_LT_AVG = "radon_lt_avg";
public static final Unit<Dimensionless> PARTS_PER_BILLION = new TransformedUnit<>(SmartHomeUnits.ONE,
public static final Unit<Dimensionless> PARTS_PER_BILLION = new TransformedUnit<>(Units.ONE,
new RationalConverter(BigInteger.ONE, BigInteger.valueOf(1000000000)));
public static final Unit<Density> BECQUEREL_PER_CUBIC_METRE = new ProductUnit<>(
Units.BECQUEREL.divide(Units.CUBIC_METRE));
Units.BECQUEREL.divide(SIUnits.CUBIC_METRE));
static {
SimpleUnitFormat.getInstance().label(PARTS_PER_BILLION, "ppb");

View File

@ -29,7 +29,7 @@ import org.openhab.binding.bluetooth.BluetoothDevice.ConnectionState;
import org.openhab.binding.bluetooth.notification.BluetoothConnectionStatusNotification;
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;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
@ -231,14 +231,11 @@ public class AirthingsWavePlusHandler extends BeaconBluetoothHandler {
private void updateChannels(AirthingsWavePlusDataParser parser) {
logger.debug("Parsed data: {}", parser);
updateState(CHANNEL_ID_HUMIDITY,
QuantityType.valueOf(Double.valueOf(parser.getHumidity()), SmartHomeUnits.PERCENT));
updateState(CHANNEL_ID_HUMIDITY, QuantityType.valueOf(Double.valueOf(parser.getHumidity()), Units.PERCENT));
updateState(CHANNEL_ID_TEMPERATURE,
QuantityType.valueOf(Double.valueOf(parser.getTemperature()), SIUnits.CELSIUS));
updateState(CHANNEL_ID_PRESSURE,
QuantityType.valueOf(Double.valueOf(parser.getPressure()), SmartHomeUnits.MILLIBAR));
updateState(CHANNEL_ID_CO2,
QuantityType.valueOf(Double.valueOf(parser.getCo2()), SmartHomeUnits.PARTS_PER_MILLION));
updateState(CHANNEL_ID_PRESSURE, QuantityType.valueOf(Double.valueOf(parser.getPressure()), Units.MILLIBAR));
updateState(CHANNEL_ID_CO2, QuantityType.valueOf(Double.valueOf(parser.getCo2()), Units.PARTS_PER_MILLION));
updateState(CHANNEL_ID_TVOC, QuantityType.valueOf(Double.valueOf(parser.getTvoc()), PARTS_PER_BILLION));
updateState(CHANNEL_ID_RADON_ST_AVG,
QuantityType.valueOf(Double.valueOf(parser.getRadonShortTermAvg()), BECQUEREL_PER_CUBIC_METRE));

View File

@ -23,7 +23,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.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
/**
@ -53,19 +53,19 @@ public class BlukiiHandler extends BeaconBluetoothHandler implements BluetoothDe
updateState(BlukiiBindingConstants.CHANNEL_ID_TEMPERATURE,
new QuantityType<>(environment.temperature, SIUnits.CELSIUS));
updateState(BlukiiBindingConstants.CHANNEL_ID_HUMIDITY,
new QuantityType<>(environment.humidity, SmartHomeUnits.PERCENT));
new QuantityType<>(environment.humidity, Units.PERCENT));
updateState(BlukiiBindingConstants.CHANNEL_ID_PRESSURE,
new QuantityType<>(environment.pressure, MetricPrefix.HECTO(SIUnits.PASCAL)));
updateState(BlukiiBindingConstants.CHANNEL_ID_LUMINANCE,
new QuantityType<>(environment.luminance, SmartHomeUnits.LUX));
new QuantityType<>(environment.luminance, Units.LUX));
});
blukiiData.accelerometer.ifPresent(accelerometer -> {
updateState(BlukiiBindingConstants.CHANNEL_ID_TILTX,
new QuantityType<>(accelerometer.tiltX, SmartHomeUnits.DEGREE_ANGLE));
new QuantityType<>(accelerometer.tiltX, Units.DEGREE_ANGLE));
updateState(BlukiiBindingConstants.CHANNEL_ID_TILTY,
new QuantityType<>(accelerometer.tiltY, SmartHomeUnits.DEGREE_ANGLE));
new QuantityType<>(accelerometer.tiltY, Units.DEGREE_ANGLE));
updateState(BlukiiBindingConstants.CHANNEL_ID_TILTZ,
new QuantityType<>(accelerometer.tiltZ, SmartHomeUnits.DEGREE_ANGLE));
new QuantityType<>(accelerometer.tiltZ, Units.DEGREE_ANGLE));
});
blukiiData.magnetometer.ifPresent(magnetometer -> {
// It isn't easy to get a heading from these values without any calibration, so we ignore those

View File

@ -34,7 +34,7 @@ import org.openhab.core.library.dimension.VolumetricFlowRate;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.MetricPrefix;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import tec.uom.se.format.SimpleUnitFormat;
import tec.uom.se.function.MultiplyConverter;
@ -42,7 +42,6 @@ import tec.uom.se.function.PiMultiplierConverter;
import tec.uom.se.function.RationalConverter;
import tec.uom.se.unit.ProductUnit;
import tec.uom.se.unit.TransformedUnit;
import tec.uom.se.unit.Units;
/**
* The {@link BluetoothUnit} maps bluetooth units to openHAB units.
@ -52,134 +51,130 @@ import tec.uom.se.unit.Units;
@NonNullByDefault
public enum BluetoothUnit {
UNITLESS(0x2700, "org.bluetooth.unit.unitless", SmartHomeUnits.ONE),
UNITLESS(0x2700, "org.bluetooth.unit.unitless", Units.ONE),
METRE(0x2701, "org.bluetooth.unit.length.metre", SIUnits.METRE),
KILOGRAM(0x2702, "org.bluetooth.unit.mass.kilogram", SIUnits.KILOGRAM),
SECOND(0x2703, "org.bluetooth.unit.time.second", SmartHomeUnits.SECOND),
AMPERE(0x2704, "org.bluetooth.unit.electric_current.ampere", SmartHomeUnits.AMPERE),
KELVIN(0x2705, "org.bluetooth.unit.thermodynamic_temperature.kelvin", SmartHomeUnits.KELVIN),
MOLE(0x2706, "org.bluetooth.unit.amount_of_substance.mole", SmartHomeUnits.MOLE),
CANDELA(0x2707, "org.bluetooth.unit.luminous_intensity.candela", SmartHomeUnits.CANDELA),
SECOND(0x2703, "org.bluetooth.unit.time.second", Units.SECOND),
AMPERE(0x2704, "org.bluetooth.unit.electric_current.ampere", Units.AMPERE),
KELVIN(0x2705, "org.bluetooth.unit.thermodynamic_temperature.kelvin", Units.KELVIN),
MOLE(0x2706, "org.bluetooth.unit.amount_of_substance.mole", Units.MOLE),
CANDELA(0x2707, "org.bluetooth.unit.luminous_intensity.candela", Units.CANDELA),
SQUARE_METRES(0x2710, "org.bluetooth.unit.area.square_metres", SIUnits.SQUARE_METRE),
CUBIC_METRES(0x2711, "org.bluetooth.unit.volume.cubic_metres", SIUnits.CUBIC_METRE),
METRE_PER_SECOND(0x2712, "org.bluetooth.unit.velocity.metres_per_second", SmartHomeUnits.METRE_PER_SECOND),
METRE_PER_SECOND(0x2712, "org.bluetooth.unit.velocity.metres_per_second", Units.METRE_PER_SECOND),
METRE_PER_SQUARE_SECOND(0X2713, "org.bluetooth.unit.acceleration.metres_per_second_squared",
SmartHomeUnits.METRE_PER_SQUARE_SECOND),
WAVENUMBER(0x2714, "org.bluetooth.unit.wavenumber.reciprocal_metre", SmartHomeUnits.ONE),
Units.METRE_PER_SQUARE_SECOND),
WAVENUMBER(0x2714, "org.bluetooth.unit.wavenumber.reciprocal_metre", Units.ONE),
KILOGRAM_PER_CUBIC_METRE(0x2715, "org.bluetooth.unit.density.kilogram_per_cubic_metre",
SmartHomeUnits.KILOGRAM_PER_CUBICMETRE),
Units.KILOGRAM_PER_CUBICMETRE),
KILOGRAM_PER_SQUARE_METRE(0x2716, "org.bluetooth.unit.surface_density.kilogram_per_square_metre",
BUnits.KILOGRAM_PER_SQUARE_METER),
CUBIC_METRE_PER_KILOGRAM(0x2717, "org.bluetooth.unit.specific_volume.cubic_metre_per_kilogram", SmartHomeUnits.ONE),
AMPERE_PER_SQUARE_METRE(0x2718, "org.bluetooth.unit.current_density.ampere_per_square_metre", SmartHomeUnits.ONE),
AMPERE_PER_METRE(0x2719, "org.bluetooth.unit.magnetic_field_strength.ampere_per_metre", SmartHomeUnits.ONE),
MOLE_PER_CUBIC_METRE(0x271A, "org.bluetooth.unit.amount_concentration.mole_per_cubic_metre", SmartHomeUnits.ONE),
CUBIC_METRE_PER_KILOGRAM(0x2717, "org.bluetooth.unit.specific_volume.cubic_metre_per_kilogram", Units.ONE),
AMPERE_PER_SQUARE_METRE(0x2718, "org.bluetooth.unit.current_density.ampere_per_square_metre", Units.ONE),
AMPERE_PER_METRE(0x2719, "org.bluetooth.unit.magnetic_field_strength.ampere_per_metre", Units.ONE),
MOLE_PER_CUBIC_METRE(0x271A, "org.bluetooth.unit.amount_concentration.mole_per_cubic_metre", Units.ONE),
CONCENTRATION_KILOGRAM_PER_CUBIC_METRE(0x271B, "org.bluetooth.unit.mass_concentration.kilogram_per_cubic_metre",
SmartHomeUnits.KILOGRAM_PER_CUBICMETRE),
CANDELA_PER_SQUARE_METRE(0x271C, "org.bluetooth.unit.luminance.candela_per_square_metre", SmartHomeUnits.ONE),
REFRACTIVE_INDEX(0x271D, "org.bluetooth.unit.refractive_index", SmartHomeUnits.ONE),
RELATIVE_PERMEABILITY(0x271E, "org.bluetooth.unit.relative_permeability", SmartHomeUnits.ONE),
RADIAN(0x2720, "org.bluetooth.unit.plane_angle.radian", SmartHomeUnits.RADIAN),
STERADIAN(0x2721, "org.bluetooth.unit.solid_angle.steradian", SmartHomeUnits.STERADIAN),
HERTZ(0x2722, "org.bluetooth.unit.frequency.hertz", SmartHomeUnits.HERTZ),
NEWTON(0x2723, "org.bluetooth.unit.force.newton", SmartHomeUnits.NEWTON),
Units.KILOGRAM_PER_CUBICMETRE),
CANDELA_PER_SQUARE_METRE(0x271C, "org.bluetooth.unit.luminance.candela_per_square_metre", Units.ONE),
REFRACTIVE_INDEX(0x271D, "org.bluetooth.unit.refractive_index", Units.ONE),
RELATIVE_PERMEABILITY(0x271E, "org.bluetooth.unit.relative_permeability", Units.ONE),
RADIAN(0x2720, "org.bluetooth.unit.plane_angle.radian", Units.RADIAN),
STERADIAN(0x2721, "org.bluetooth.unit.solid_angle.steradian", Units.STERADIAN),
HERTZ(0x2722, "org.bluetooth.unit.frequency.hertz", Units.HERTZ),
NEWTON(0x2723, "org.bluetooth.unit.force.newton", Units.NEWTON),
PASCAL(0x2724, "org.bluetooth.unit.pressure.pascal", SIUnits.PASCAL),
JOULE(0x2725, "org.bluetooth.unit.energy.joule", SmartHomeUnits.JOULE),
WATT(0x2726, "org.bluetooth.unit.power.watt", SmartHomeUnits.WATT),
COULOMB(0x2727, "org.bluetooth.unit.electric_charge.coulomb", SmartHomeUnits.COULOMB),
VOLT(0x2728, "org.bluetooth.unit.electric_potential_difference.volt", SmartHomeUnits.VOLT),
FARAD(0x2729, "org.bluetooth.unit.capacitance.farad", SmartHomeUnits.FARAD),
OHM(0x272A, "org.bluetooth.unit.electric_resistance.ohm", SmartHomeUnits.OHM),
SIEMENS(0x272B, "org.bluetooth.unit.electric_conductance.siemens", SmartHomeUnits.SIEMENS),
WEBER(0x272C, "org.bluetooth.unit.magnetic_flux.weber", SmartHomeUnits.WEBER),
TESLA(0x272D, "org.bluetooth.unit.magnetic_flux_density.tesla", SmartHomeUnits.TESLA),
HENRY(0x272E, "org.bluetooth.unit.inductance.henry", SmartHomeUnits.HENRY),
JOULE(0x2725, "org.bluetooth.unit.energy.joule", Units.JOULE),
WATT(0x2726, "org.bluetooth.unit.power.watt", Units.WATT),
COULOMB(0x2727, "org.bluetooth.unit.electric_charge.coulomb", Units.COULOMB),
VOLT(0x2728, "org.bluetooth.unit.electric_potential_difference.volt", Units.VOLT),
FARAD(0x2729, "org.bluetooth.unit.capacitance.farad", Units.FARAD),
OHM(0x272A, "org.bluetooth.unit.electric_resistance.ohm", Units.OHM),
SIEMENS(0x272B, "org.bluetooth.unit.electric_conductance.siemens", Units.SIEMENS),
WEBER(0x272C, "org.bluetooth.unit.magnetic_flux.weber", Units.WEBER),
TESLA(0x272D, "org.bluetooth.unit.magnetic_flux_density.tesla", Units.TESLA),
HENRY(0x272E, "org.bluetooth.unit.inductance.henry", Units.HENRY),
DEGREE_CELSIUS(0x272F, "org.bluetooth.unit.thermodynamic_temperature.degree_celsius", SIUnits.CELSIUS),
LUMEN(0x2730, "org.bluetooth.unit.luminous_flux.lumen", SmartHomeUnits.LUMEN),
LUX(0x2731, "org.bluetooth.unit.illuminance.lux", SmartHomeUnits.LUX),
BECQUEREL(0x2732, "org.bluetooth.unit.activity_referred_to_a_radionuclide.becquerel", SmartHomeUnits.BECQUEREL),
GRAY(0x2733, "org.bluetooth.unit.absorbed_dose.gray", SmartHomeUnits.GRAY),
SIEVERT(0x2734, "org.bluetooth.unit.dose_equivalent.sievert", SmartHomeUnits.SIEVERT),
KATAL(0x2735, "org.bluetooth.unit.catalytic_activity.katal", SmartHomeUnits.KATAL),
PASCAL_SECOND(0x2740, "org.bluetooth.unit.dynamic_viscosity.pascal_second", SmartHomeUnits.ONE),
NEWTON_METRE(0x2741, "org.bluetooth.unit.moment_of_force.newton_metre", SmartHomeUnits.ONE),
NEWTON_PER_METRE(0x2742, "org.bluetooth.unit.surface_tension.newton_per_metre", SmartHomeUnits.ONE),
RADIAN_PER_SECOND(0x2743, "org.bluetooth.unit.angular_velocity.radian_per_second", SmartHomeUnits.ONE),
RADIAN_PER_SECOND_SQUARED(0x2744, "org.bluetooth.unit.angular_acceleration.radian_per_second_squared",
SmartHomeUnits.ONE),
FLUX_WATT_PER_SQUARE_METRE(0x2745, "org.bluetooth.unit.heat_flux_density.watt_per_square_metre",
SmartHomeUnits.ONE),
JOULE_PER_KELVIN(0x2746, "org.bluetooth.unit.heat_capacity.joule_per_kelvin", SmartHomeUnits.ONE),
JOULE_PER_KILOGRAM_KELVIN(0x2747, "org.bluetooth.unit.specific_heat_capacity.joule_per_kilogram_kelvin",
SmartHomeUnits.ONE),
JOULE_PER_KILOGRAM(0x2748, "org.bluetooth.unit.specific_energy.joule_per_kilogram", SmartHomeUnits.ONE),
WATT_PER_METRE_KELVIN(0x2749, "org.bluetooth.unit.thermal_conductivity.watt_per_metre_kelvin", SmartHomeUnits.ONE),
JOULE_PER_CUBIC_METRE(0x274A, "org.bluetooth.unit.energy_density.joule_per_cubic_metre", SmartHomeUnits.ONE),
VOLT_PER_METRE(0x274B, "org.bluetooth.unit.electric_field_strength.volt_per_metre", SmartHomeUnits.ONE),
LUMEN(0x2730, "org.bluetooth.unit.luminous_flux.lumen", Units.LUMEN),
LUX(0x2731, "org.bluetooth.unit.illuminance.lux", Units.LUX),
BECQUEREL(0x2732, "org.bluetooth.unit.activity_referred_to_a_radionuclide.becquerel", Units.BECQUEREL),
GRAY(0x2733, "org.bluetooth.unit.absorbed_dose.gray", Units.GRAY),
SIEVERT(0x2734, "org.bluetooth.unit.dose_equivalent.sievert", Units.SIEVERT),
KATAL(0x2735, "org.bluetooth.unit.catalytic_activity.katal", Units.KATAL),
PASCAL_SECOND(0x2740, "org.bluetooth.unit.dynamic_viscosity.pascal_second", Units.ONE),
NEWTON_METRE(0x2741, "org.bluetooth.unit.moment_of_force.newton_metre", Units.ONE),
NEWTON_PER_METRE(0x2742, "org.bluetooth.unit.surface_tension.newton_per_metre", Units.ONE),
RADIAN_PER_SECOND(0x2743, "org.bluetooth.unit.angular_velocity.radian_per_second", Units.ONE),
RADIAN_PER_SECOND_SQUARED(0x2744, "org.bluetooth.unit.angular_acceleration.radian_per_second_squared", Units.ONE),
FLUX_WATT_PER_SQUARE_METRE(0x2745, "org.bluetooth.unit.heat_flux_density.watt_per_square_metre", Units.ONE),
JOULE_PER_KELVIN(0x2746, "org.bluetooth.unit.heat_capacity.joule_per_kelvin", Units.ONE),
JOULE_PER_KILOGRAM_KELVIN(0x2747, "org.bluetooth.unit.specific_heat_capacity.joule_per_kilogram_kelvin", Units.ONE),
JOULE_PER_KILOGRAM(0x2748, "org.bluetooth.unit.specific_energy.joule_per_kilogram", Units.ONE),
WATT_PER_METRE_KELVIN(0x2749, "org.bluetooth.unit.thermal_conductivity.watt_per_metre_kelvin", Units.ONE),
JOULE_PER_CUBIC_METRE(0x274A, "org.bluetooth.unit.energy_density.joule_per_cubic_metre", Units.ONE),
VOLT_PER_METRE(0x274B, "org.bluetooth.unit.electric_field_strength.volt_per_metre", Units.ONE),
CHARGE_DENSITY_COULOMB_PER_CUBIC_METRE(0x274C, "org.bluetooth.unit.electric_charge_density.coulomb_per_cubic_metre",
SmartHomeUnits.ONE),
Units.ONE),
CHARGE_DENSITY_COULOMB_PER_SQUARE_METRE(0x274D,
"org.bluetooth.unit.surface_charge_density.coulomb_per_square_metre", SmartHomeUnits.ONE),
"org.bluetooth.unit.surface_charge_density.coulomb_per_square_metre", Units.ONE),
FLUX_DENSITY_COULOMB_PER_SQUARE_METRE(0x274E, "org.bluetooth.unit.electric_flux_density.coulomb_per_square_metre",
SmartHomeUnits.ONE),
FARAD_PER_METRE(0x274F, "org.bluetooth.unit.permittivity.farad_per_metre", SmartHomeUnits.ONE),
HENRY_PER_METRE(0x2750, "org.bluetooth.unit.permeability.henry_per_metre", SmartHomeUnits.ONE),
JOULE_PER_MOLE(0x2751, "org.bluetooth.unit.molar_energy.joule_per_mole", SmartHomeUnits.ONE),
JOULE_PER_MOLE_KELVIN(0x2752, "org.bluetooth.unit.molar_entropy.joule_per_mole_kelvin", SmartHomeUnits.ONE),
COULOMB_PER_KILOGRAM(0x2753, "org.bluetooth.unit.exposure.coulomb_per_kilogram", SmartHomeUnits.ONE),
Units.ONE),
FARAD_PER_METRE(0x274F, "org.bluetooth.unit.permittivity.farad_per_metre", Units.ONE),
HENRY_PER_METRE(0x2750, "org.bluetooth.unit.permeability.henry_per_metre", Units.ONE),
JOULE_PER_MOLE(0x2751, "org.bluetooth.unit.molar_energy.joule_per_mole", Units.ONE),
JOULE_PER_MOLE_KELVIN(0x2752, "org.bluetooth.unit.molar_entropy.joule_per_mole_kelvin", Units.ONE),
COULOMB_PER_KILOGRAM(0x2753, "org.bluetooth.unit.exposure.coulomb_per_kilogram", Units.ONE),
GRAY_PER_SECOND(0x2754, "org.bluetooth.unit.absorbed_dose_rate.gray_per_second", BUnits.GRAY_PER_SECOND),
WATT_PER_STERADIAN(0x2755, "org.bluetooth.unit.radiant_intensity.watt_per_steradian", BUnits.WATT_PER_STERADIAN),
WATT_PER_STERADIAN_PER_SQUARE_METRE(0x2756, "org.bluetooth.unit.radiance.watt_per_square_metre_steradian",
BUnits.WATT_PER_STERADIAN_PER_SQUARE_METRE),
KATAL_PER_CUBIC_METRE(0x2757, "org.bluetooth.unit.catalytic_activity_concentration.katal_per_cubic_metre",
SmartHomeUnits.ONE),
MINUTE(0x2760, "org.bluetooth.unit.time.minute", SmartHomeUnits.MINUTE),
HOUR(0x2761, "org.bluetooth.unit.time.hour", SmartHomeUnits.HOUR),
DAY(0x2762, "org.bluetooth.unit.time.day", SmartHomeUnits.DAY),
ANGLE_DEGREE(0x2763, "org.bluetooth.unit.plane_angle.degree", SmartHomeUnits.DEGREE_ANGLE),
Units.ONE),
MINUTE(0x2760, "org.bluetooth.unit.time.minute", Units.MINUTE),
HOUR(0x2761, "org.bluetooth.unit.time.hour", Units.HOUR),
DAY(0x2762, "org.bluetooth.unit.time.day", Units.DAY),
ANGLE_DEGREE(0x2763, "org.bluetooth.unit.plane_angle.degree", Units.DEGREE_ANGLE),
ANGLE_MINUTE(0x2764, "org.bluetooth.unit.plane_angle.minute", BUnits.MINUTE_ANGLE),
ANGLE_SECOND(0x2765, "org.bluetooth.unit.plane_angle.second", BUnits.SECOND_ANGLE),
HECTARE(0x2766, "org.bluetooth.unit.area.hectare", BUnits.HECTARE),
LITRE(0x2767, "org.bluetooth.unit.volume.litre", SmartHomeUnits.LITRE),
LITRE(0x2767, "org.bluetooth.unit.volume.litre", Units.LITRE),
TONNE(0x2768, "org.bluetooth.unit.mass.tonne", MetricPrefix.KILO(SIUnits.KILOGRAM)),
BAR(0x2780, "org.bluetooth.unit.pressure.bar", SmartHomeUnits.BAR),
MILLIMETRE_OF_MERCURY(0x2781, "org.bluetooth.unit.pressure.millimetre_of_mercury",
SmartHomeUnits.MILLIMETRE_OF_MERCURY),
ÅNGSTRÖM(0x2782, "org.bluetooth.unit.length.ångström", SmartHomeUnits.ONE),
BAR(0x2780, "org.bluetooth.unit.pressure.bar", Units.BAR),
MILLIMETRE_OF_MERCURY(0x2781, "org.bluetooth.unit.pressure.millimetre_of_mercury", Units.MILLIMETRE_OF_MERCURY),
ÅNGSTRÖM(0x2782, "org.bluetooth.unit.length.ångström", Units.ONE),
NAUTICAL_MILE(0x2783, "org.bluetooth.unit.length.nautical_mile", BUnits.NAUTICAL_MILE),
BARN(0x2784, "org.bluetooth.unit.area.barn", BUnits.BARN),
KNOT(0x2785, "org.bluetooth.unit.velocity.knot", SmartHomeUnits.KNOT),
NEPER(0x2786, "org.bluetooth.unit.logarithmic_radio_quantity.neper", SmartHomeUnits.ONE),
BEL(0x2787, "org.bluetooth.unit.logarithmic_radio_quantity.bel", SmartHomeUnits.ONE),
KNOT(0x2785, "org.bluetooth.unit.velocity.knot", Units.KNOT),
NEPER(0x2786, "org.bluetooth.unit.logarithmic_radio_quantity.neper", Units.ONE),
BEL(0x2787, "org.bluetooth.unit.logarithmic_radio_quantity.bel", Units.ONE),
YARD(0x27A0, "org.bluetooth.unit.length.yard", ImperialUnits.YARD),
PARSEC(0x27A1, "org.bluetooth.unit.length.parsec", SmartHomeUnits.ONE),
PARSEC(0x27A1, "org.bluetooth.unit.length.parsec", Units.ONE),
INCH(0x27A2, "org.bluetooth.unit.length.inch", ImperialUnits.INCH),
FOOT(0x27A3, "org.bluetooth.unit.length.foot", ImperialUnits.FOOT),
MILE(0x27A4, "org.bluetooth.unit.length.mile", ImperialUnits.MILE),
POUND_FORCE_PER_SQUARE_INCH(0x27A5, "org.bluetooth.unit.pressure.pound_force_per_square_inch", SmartHomeUnits.ONE),
POUND_FORCE_PER_SQUARE_INCH(0x27A5, "org.bluetooth.unit.pressure.pound_force_per_square_inch", Units.ONE),
KILOMETRE_PER_HOUR(0x27A6, "org.bluetooth.unit.velocity.kilometre_per_hour", SIUnits.KILOMETRE_PER_HOUR),
MILES_PER_HOUR(0x27A7, "org.bluetooth.unit.velocity.mile_per_hour", ImperialUnits.MILES_PER_HOUR),
REVOLUTION_PER_MINUTE(0x27A8, "org.bluetooth.unit.angular_velocity.revolution_per_minute",
BUnits.REVOLUTION_PER_MINUTE),
GRAM_CALORIE(0x27A9, "org.bluetooth.unit.energy.gram_calorie", SmartHomeUnits.ONE),
KILOGRAM_CALORIE(0x27AA, "org.bluetooth.unit.energy.kilogram_calorie", SmartHomeUnits.ONE),
KILOWATT_HOUR(0x27AB, "org.bluetooth.unit.energy.kilowatt_hour", SmartHomeUnits.KILOWATT_HOUR),
GRAM_CALORIE(0x27A9, "org.bluetooth.unit.energy.gram_calorie", Units.ONE),
KILOGRAM_CALORIE(0x27AA, "org.bluetooth.unit.energy.kilogram_calorie", Units.ONE),
KILOWATT_HOUR(0x27AB, "org.bluetooth.unit.energy.kilowatt_hour", Units.KILOWATT_HOUR),
DEGREE_FAHRENHEIT(0x27AC, "org.bluetooth.unit.thermodynamic_temperature.degree_fahrenheit",
ImperialUnits.FAHRENHEIT),
PERCENTAGE(0x27AD, "org.bluetooth.unit.percentage", SmartHomeUnits.PERCENT),
PER_MILLE(0x27AE, "org.bluetooth.unit.per_mille", SmartHomeUnits.ONE),
PERCENTAGE(0x27AD, "org.bluetooth.unit.percentage", Units.PERCENT),
PER_MILLE(0x27AE, "org.bluetooth.unit.per_mille", Units.ONE),
BEATS_PER_MINUTE(0x27AF, "org.bluetooth.unit.period.beats_per_minute", BUnits.BEATS_PER_MINUTE),
AMPERE_HOURS(0x27B0, "org.bluetooth.unit.electric_charge.ampere_hours", BUnits.AMPERE_HOUR),
MILLIGRAM_PER_DECILITRE(0x27B1, "org.bluetooth.unit.mass_density.milligram_per_decilitre", SmartHomeUnits.ONE),
MILLIMOLE_PER_LITRE(0x27B2, "org.bluetooth.unit.mass_density.millimole_per_litre", SmartHomeUnits.ONE),
YEAR(0x27B3, "org.bluetooth.unit.time.year", SmartHomeUnits.YEAR),
MONTH(0x27B4, "org.bluetooth.unit.time.month", SmartHomeUnits.ONE),
COUNT_PER_CUBIC_METRE(0x27B5, "org.bluetooth.unit.concentration.count_per_cubic_metre", SmartHomeUnits.ONE),
WATT_PER_SQUARE_METRE(0x27B6, "org.bluetooth.unit.irradiance.watt_per_square_metre", SmartHomeUnits.IRRADIANCE),
MILLIGRAM_PER_DECILITRE(0x27B1, "org.bluetooth.unit.mass_density.milligram_per_decilitre", Units.ONE),
MILLIMOLE_PER_LITRE(0x27B2, "org.bluetooth.unit.mass_density.millimole_per_litre", Units.ONE),
YEAR(0x27B3, "org.bluetooth.unit.time.year", Units.YEAR),
MONTH(0x27B4, "org.bluetooth.unit.time.month", Units.ONE),
COUNT_PER_CUBIC_METRE(0x27B5, "org.bluetooth.unit.concentration.count_per_cubic_metre", Units.ONE),
WATT_PER_SQUARE_METRE(0x27B6, "org.bluetooth.unit.irradiance.watt_per_square_metre", Units.IRRADIANCE),
MILLILITER_PER_KILOGRAM_PER_MINUTE(0x27B7, "org.bluetooth.unit.transfer_rate.milliliter_per_kilogram_per_minute",
SmartHomeUnits.ONE),
Units.ONE),
POUND(0x27B8, "org.bluetooth.unit.mass.pound", BUnits.POUND),
METABOLIC_EQUIVALENT(0x27B9, "org.bluetooth.unit.metabolic_equivalent", SmartHomeUnits.ONE),
METABOLIC_EQUIVALENT(0x27B9, "org.bluetooth.unit.metabolic_equivalent", Units.ONE),
STEP_PER_MINUTE(0x27BA, "org.bluetooth.unit.step_per_minute", BUnits.STEP_PER_MINUTE),
STROKE_PER_MINUTE(0x27BC, "org.bluetooth.unit.stroke_per_minute", BUnits.STROKE_PER_MINUTE),
KILOMETER_PER_MINUTE(0x27BD, "org.bluetooth.unit.velocity.kilometer_per_minute", BUnits.KILOMETRE_PER_MINUTE),
@ -188,9 +183,9 @@ public enum BluetoothUnit {
LUX_HOUR(0x27C0, "org.bluetooth.unit.luminous_exposure.lux_hour", BUnits.LUX_HOUR),
GRAM_PER_SECOND(0x27C1, "org.bluetooth.unit.mass_flow.gram_per_second", BUnits.GRAM_PER_SECOND),
LITRE_PER_SECOND(0x27C2, "org.bluetooth.unit.volume_flow.litre_per_second", BUnits.LITRE_PER_SECOND),
DECIBEL_SPL(0x27C3, "org.bluetooth.unit.sound_pressure.decibel_spl", SmartHomeUnits.ONE),
PARTS_PER_MILLION(0x27C4, "org.bluetooth.unit.concentration.parts_per_million", SmartHomeUnits.PARTS_PER_MILLION),
PARTS_PER_BILLION(0x27C5, "org.bluetooth.unit.concentration.parts_per_billion", SmartHomeUnits.PARTS_PER_BILLION);
DECIBEL_SPL(0x27C3, "org.bluetooth.unit.sound_pressure.decibel_spl", Units.ONE),
PARTS_PER_MILLION(0x27C4, "org.bluetooth.unit.concentration.parts_per_million", Units.PARTS_PER_MILLION),
PARTS_PER_BILLION(0x27C5, "org.bluetooth.unit.concentration.parts_per_billion", Units.PARTS_PER_BILLION);
private UUID uuid;
@ -235,16 +230,16 @@ public enum BluetoothUnit {
@Deprecated
public static class BUnits {
public static final Unit<ArealDensity> KILOGRAM_PER_SQUARE_METER = addUnit(
new ProductUnit<ArealDensity>(Units.KILOGRAM.divide(Units.SQUARE_METRE)));
new ProductUnit<ArealDensity>(SIUnits.KILOGRAM.divide(SIUnits.SQUARE_METRE)));
public static final Unit<RadiationExposure> COULOMB_PER_KILOGRAM = addUnit(
new ProductUnit<RadiationExposure>(Units.COULOMB.divide(Units.KILOGRAM)));
new ProductUnit<RadiationExposure>(Units.COULOMB.divide(SIUnits.KILOGRAM)));
public static final Unit<RadiationDoseAbsorptionRate> GRAY_PER_SECOND = addUnit(
new ProductUnit<RadiationDoseAbsorptionRate>(Units.GRAY.divide(Units.SECOND)));
public static final Unit<Mass> POUND = addUnit(
new TransformedUnit<Mass>(Units.KILOGRAM, new MultiplyConverter(0.45359237)));
new TransformedUnit<Mass>(SIUnits.KILOGRAM, new MultiplyConverter(0.45359237)));
public static final Unit<Angle> MINUTE_ANGLE = addUnit(new TransformedUnit<Angle>(Units.RADIAN,
new PiMultiplierConverter().concatenate(new RationalConverter(1, 180 * 60))));
@ -252,8 +247,8 @@ public enum BluetoothUnit {
public static final Unit<Angle> SECOND_ANGLE = addUnit(new TransformedUnit<Angle>(Units.RADIAN,
new PiMultiplierConverter().concatenate(new RationalConverter(1, 180 * 60 * 60))));
public static final Unit<Area> HECTARE = addUnit(Units.SQUARE_METRE.multiply(10000.0));
public static final Unit<Area> BARN = addUnit(Units.SQUARE_METRE.multiply(10E-28));
public static final Unit<Area> HECTARE = addUnit(SIUnits.SQUARE_METRE.multiply(10000.0));
public static final Unit<Area> BARN = addUnit(SIUnits.SQUARE_METRE.multiply(10E-28));
public static final Unit<Length> NAUTICAL_MILE = addUnit(SIUnits.METRE.multiply(1852.0));
@ -261,7 +256,7 @@ public enum BluetoothUnit {
new ProductUnit<RadiantIntensity>(Units.WATT.divide(Units.STERADIAN)));
public static final Unit<Radiance> WATT_PER_STERADIAN_PER_SQUARE_METRE = addUnit(
new ProductUnit<Radiance>(WATT_PER_STERADIAN.divide(Units.SQUARE_METRE)));
new ProductUnit<Radiance>(WATT_PER_STERADIAN.divide(SIUnits.SQUARE_METRE)));
public static final Unit<Frequency> CYCLES_PER_MINUTE = addUnit(new TransformedUnit<Frequency>(Units.HERTZ,
new RationalConverter(BigInteger.valueOf(60), BigInteger.ONE)));
@ -271,9 +266,9 @@ public enum BluetoothUnit {
public static final Unit<AngularVelocity> REVOLUTION_PER_MINUTE = addUnit(
new ProductUnit<AngularVelocity>(REVOLUTION.divide(Units.MINUTE)));
public static final Unit<Dimensionless> STEPS = addUnit(SmartHomeUnits.ONE.alternate("steps"));
public static final Unit<Dimensionless> BEATS = addUnit(SmartHomeUnits.ONE.alternate("beats"));
public static final Unit<Dimensionless> STROKE = addUnit(SmartHomeUnits.ONE.alternate("stroke"));
public static final Unit<Dimensionless> STEPS = addUnit(Units.ONE.alternate("steps"));
public static final Unit<Dimensionless> BEATS = addUnit(Units.ONE.alternate("beats"));
public static final Unit<Dimensionless> STROKE = addUnit(Units.ONE.alternate("stroke"));
public static final Unit<Frequency> STEP_PER_MINUTE = addUnit(
new ProductUnit<Frequency>(STEPS.divide(Units.MINUTE)));
@ -285,7 +280,7 @@ public enum BluetoothUnit {
new ProductUnit<Frequency>(STROKE.divide(Units.MINUTE)));
public static final Unit<MassFlowRate> GRAM_PER_SECOND = addUnit(
new ProductUnit<MassFlowRate>(Units.GRAM.divide(Units.SECOND)));
new ProductUnit<MassFlowRate>(SIUnits.GRAM.divide(Units.SECOND)));
public static final Unit<LuminousEfficacy> LUMEN_PER_WATT = addUnit(
new ProductUnit<LuminousEfficacy>(Units.LUMEN.divide(Units.WATT)));
@ -302,7 +297,7 @@ public enum BluetoothUnit {
public static final Unit<LuminousExposure> LUX_HOUR = addUnit(
new ProductUnit<LuminousExposure>(Units.LUX.multiply(Units.HOUR)));
public static final Unit<Speed> KILOMETRE_PER_MINUTE = addUnit(Units.KILOMETRE_PER_HOUR.multiply(60.0));
public static final Unit<Speed> KILOMETRE_PER_MINUTE = addUnit(SIUnits.KILOMETRE_PER_HOUR.multiply(60.0));
public static final Unit<VolumetricFlowRate> LITRE_PER_SECOND = addUnit(
new ProductUnit<VolumetricFlowRate>(Units.LITRE.divide(Units.SECOND)));

View File

@ -28,7 +28,7 @@ import org.openhab.binding.bluetooth.notification.BluetoothScanNotification;
import org.openhab.core.library.types.DecimalType;
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
@ -111,19 +111,19 @@ public class RuuviTagHandler extends BeaconBluetoothHandler {
switch (channelUID.getId()) {
case CHANNEL_ID_ACCELERATIONX:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
ruuvitagData.getAccelerationX(), SmartHomeUnits.STANDARD_GRAVITY);
ruuvitagData.getAccelerationX(), Units.STANDARD_GRAVITY);
break;
case CHANNEL_ID_ACCELERATIONY:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
ruuvitagData.getAccelerationY(), SmartHomeUnits.STANDARD_GRAVITY);
ruuvitagData.getAccelerationY(), Units.STANDARD_GRAVITY);
break;
case CHANNEL_ID_ACCELERATIONZ:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
ruuvitagData.getAccelerationZ(), SmartHomeUnits.STANDARD_GRAVITY);
ruuvitagData.getAccelerationZ(), Units.STANDARD_GRAVITY);
break;
case CHANNEL_ID_BATTERY:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
ruuvitagData.getBatteryVoltage(), SmartHomeUnits.VOLT);
ruuvitagData.getBatteryVoltage(), Units.VOLT);
break;
case CHANNEL_ID_DATA_FORMAT:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
@ -131,15 +131,15 @@ public class RuuviTagHandler extends BeaconBluetoothHandler {
break;
case CHANNEL_ID_HUMIDITY:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
ruuvitagData.getHumidity(), SmartHomeUnits.PERCENT);
ruuvitagData.getHumidity(), Units.PERCENT);
break;
case CHANNEL_ID_MEASUREMENT_SEQUENCE_NUMBER:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
ruuvitagData.getMeasurementSequenceNumber(), SmartHomeUnits.ONE);
ruuvitagData.getMeasurementSequenceNumber(), Units.ONE);
break;
case CHANNEL_ID_MOVEMENT_COUNTER:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
ruuvitagData.getMovementCounter(), SmartHomeUnits.ONE);
ruuvitagData.getMovementCounter(), Units.ONE);
break;
case CHANNEL_ID_PRESSURE:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
@ -151,7 +151,7 @@ public class RuuviTagHandler extends BeaconBluetoothHandler {
break;
case CHANNEL_ID_TX_POWER:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
ruuvitagData.getTxPower(), SmartHomeUnits.DECIBEL_MILLIWATTS);
ruuvitagData.getTxPower(), Units.DECIBEL_MILLIWATTS);
break;
}
}

View File

@ -27,7 +27,7 @@ import org.openhab.binding.bluetooth.notification.BluetoothConnectionStatusNotif
import org.openhab.binding.bluetooth.notification.BluetoothScanNotification;
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;
@ -173,7 +173,7 @@ public class BeaconBluetoothHandler extends BaseThingHandler implements Bluetoot
private void updateRSSI(@Nullable Integer rssi) {
if (rssi != null && rssi != 0) {
QuantityType<Power> quantity = new QuantityType<>(rssi, SmartHomeUnits.DECIBEL_MILLIWATTS);
QuantityType<Power> quantity = new QuantityType<>(rssi, Units.DECIBEL_MILLIWATTS);
updateState(BluetoothBindingConstants.CHANNEL_TYPE_RSSI, quantity);
updateStatusBasedOnRssi(true);
} else {

View File

@ -18,7 +18,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.bticinosmarther.internal.api.exception.SmartherIllegalPropertyValueException;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* The {@code Enums} class represents a container for enums related to Smarther API.
@ -175,7 +175,7 @@ public class Enums {
return CELSIUS;
} else if (unit == ImperialUnits.FAHRENHEIT) {
return FAHRENHEIT;
} else if (unit == SmartHomeUnits.PERCENT) {
} else if (unit == Units.PERCENT) {
return PERCENTAGE;
} else {
return DIMENSIONLESS;

View File

@ -24,7 +24,7 @@ import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.ImperialUnits;
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;
@ -100,8 +100,7 @@ public class Measure {
.orElse(UnDefType.UNDEF);
break;
case PERCENTAGE:
state = optValue
.<State> map(t -> new QuantityType<Dimensionless>(new DecimalType(t), SmartHomeUnits.PERCENT))
state = optValue.<State> map(t -> new QuantityType<Dimensionless>(new DecimalType(t), Units.PERCENT))
.orElse(UnDefType.UNDEF);
break;
case DIMENSIONLESS:

View File

@ -34,7 +34,7 @@ import org.openhab.binding.buienradar.internal.buienradarapi.PredictionAPI;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.PointType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -152,7 +152,7 @@ public class BuienradarHandler extends BaseThingHandler {
if (minutesFromNow >= 0 && minutesFromNow <= 115) {
final String label = String.format(Locale.ENGLISH, "forecast_%d", minutesFromNow);
updateState(label, new QuantityType<>(intensity, SmartHomeUnits.MILLIMETRE_PER_HOUR));
updateState(label, new QuantityType<>(intensity, Units.MILLIMETRE_PER_HOUR));
}
}

View File

@ -37,7 +37,7 @@ import org.openhab.core.library.types.PointType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.RawType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -168,7 +168,7 @@ public class ChromecastStatusUpdater {
break;
}
callback.updateState(CHANNEL_CURRENT_TIME, new QuantityType<>(mediaStatus.currentTime, SmartHomeUnits.SECOND));
callback.updateState(CHANNEL_CURRENT_TIME, new QuantityType<>(mediaStatus.currentTime, Units.SECOND));
// If we're playing, paused or buffering but don't have any MEDIA information don't null everything out.
Media media = mediaStatus.media;
@ -188,7 +188,7 @@ public class ChromecastStatusUpdater {
// duration can be null when a new song is about to play.
if (media.duration != null) {
duration = new QuantityType<>(media.duration, SmartHomeUnits.SECOND);
duration = new QuantityType<>(media.duration, Units.SECOND);
}
}

View File

@ -16,7 +16,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.comfoair.internal.ComfoAirCommandType;
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.slf4j.Logger;
@ -52,7 +52,7 @@ public class DataTypeTime implements ComfoAirDataType {
return UnDefType.NULL;
}
return new QuantityType<>(value, SmartHomeUnits.HOUR);
return new QuantityType<>(value, Units.HOUR);
}
}
@ -61,7 +61,7 @@ public class DataTypeTime implements ComfoAirDataType {
int[] template = commandType.getChangeDataTemplate();
int[] possibleValues = commandType.getPossibleValues();
int position = commandType.getChangeDataPos();
QuantityType<?> hours = ((QuantityType<?>) value).toUnit(SmartHomeUnits.HOUR);
QuantityType<?> hours = ((QuantityType<?>) value).toUnit(Units.HOUR);
if (hours != null) {
int intValue = hours.intValue();

View File

@ -16,7 +16,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.comfoair.internal.ComfoAirCommandType;
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.slf4j.Logger;
@ -49,7 +49,7 @@ public class DataTypeVolt implements ComfoAirDataType {
} else {
int[] readReplyDataPos = commandType.getReadReplyDataPos();
if (readReplyDataPos != null && readReplyDataPos[0] < data.length) {
return new QuantityType<>((double) data[readReplyDataPos[0]] * 10 / 255, SmartHomeUnits.VOLT);
return new QuantityType<>((double) data[readReplyDataPos[0]] * 10 / 255, Units.VOLT);
} else {
return UnDefType.NULL;
}
@ -59,7 +59,7 @@ public class DataTypeVolt implements ComfoAirDataType {
@Override
public int @Nullable [] convertFromState(State value, ComfoAirCommandType commandType) {
int[] template = commandType.getChangeDataTemplate();
QuantityType<?> volts = ((QuantityType<?>) value).toUnit(SmartHomeUnits.VOLT);
QuantityType<?> volts = ((QuantityType<?>) value).toUnit(Units.VOLT);
if (volts != null) {
template[commandType.getChangeDataPos()] = (int) (volts.doubleValue() * 255 / 10);

View File

@ -21,7 +21,7 @@ import javax.measure.quantity.Dimensionless;
import org.eclipse.jdt.annotation.NonNullByDefault;
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;
@ -58,7 +58,7 @@ public class CoronaStatsCases {
if (count == -1) {
return UnDefType.NULL;
} else {
return new QuantityType<Dimensionless>(count, SmartHomeUnits.ONE);
return new QuantityType<Dimensionless>(count, Units.ONE);
}
}
}

View File

@ -35,7 +35,7 @@ import org.openhab.binding.daikin.internal.api.SensorInfo;
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.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -102,14 +102,14 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
if (sensorInfo.indoorhumidity.isPresent()) {
updateState(DaikinBindingConstants.CHANNEL_HUMIDITY,
new QuantityType<>(sensorInfo.indoorhumidity.get(), SmartHomeUnits.PERCENT));
new QuantityType<>(sensorInfo.indoorhumidity.get(), Units.PERCENT));
} else {
updateState(DaikinBindingConstants.CHANNEL_HUMIDITY, UnDefType.UNDEF);
}
if (sensorInfo.compressorfrequency.isPresent()) {
updateState(DaikinBindingConstants.CHANNEL_CMP_FREQ,
new QuantityType<>(sensorInfo.compressorfrequency.get(), SmartHomeUnits.PERCENT));
new QuantityType<>(sensorInfo.compressorfrequency.get(), Units.PERCENT));
} else {
updateState(DaikinBindingConstants.CHANNEL_CMP_FREQ, UnDefType.UNDEF);
}
@ -247,13 +247,13 @@ public class DaikinAcUnitHandler extends DaikinBaseHandler {
* @param maybePower
*/
protected void updateEnergyYearChannel(String channelPrefix, Optional<Integer[]> maybePower) {
IntStream.range(1, 13)
.forEach(i -> updateState(
String.format(DaikinBindingConstants.CHANNEL_ENERGY_STRING_FORMAT, channelPrefix, i),
maybePower.<State> map(t -> new QuantityType<>(BigDecimal.valueOf(t[i - 1].longValue(), 1),
SmartHomeUnits.KILOWATT_HOUR)).orElse(UnDefType.UNDEF))
IntStream.range(1, 13).forEach(i -> updateState(
String.format(DaikinBindingConstants.CHANNEL_ENERGY_STRING_FORMAT, channelPrefix, i),
maybePower.<State> map(
t -> new QuantityType<>(BigDecimal.valueOf(t[i - 1].longValue(), 1), Units.KILOWATT_HOUR))
.orElse(UnDefType.UNDEF))
);
);
}
@Override

View File

@ -15,7 +15,7 @@ package org.openhab.binding.darksky.internal.handler;
import static org.openhab.binding.darksky.internal.DarkSkyBindingConstants.*;
import static org.openhab.core.library.unit.MetricPrefix.*;
import static org.openhab.core.library.unit.SIUnits.*;
import static org.openhab.core.library.unit.SmartHomeUnits.*;
import static org.openhab.core.library.unit.Units.*;
import java.time.Instant;
import java.time.ZoneId;

View File

@ -14,7 +14,7 @@ package org.openhab.binding.deconz.internal.handler;
import static org.openhab.binding.deconz.internal.BindingConstants.*;
import static org.openhab.core.library.unit.SIUnits.CELSIUS;
import static org.openhab.core.library.unit.SmartHomeUnits.PERCENT;
import static org.openhab.core.library.unit.Units.PERCENT;
import java.math.BigDecimal;
import java.util.Arrays;

View File

@ -15,7 +15,7 @@ package org.openhab.binding.deconz.internal.handler;
import static org.openhab.binding.deconz.internal.BindingConstants.*;
import static org.openhab.core.library.unit.MetricPrefix.*;
import static org.openhab.core.library.unit.SIUnits.*;
import static org.openhab.core.library.unit.SmartHomeUnits.*;
import static org.openhab.core.library.unit.Units.*;
import java.util.Arrays;
import java.util.List;

View File

@ -36,7 +36,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.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingUID;
@ -104,7 +104,7 @@ public class SensorsTest {
sensorThingHandler.messageReceived("", sensorMessage);
Mockito.verify(thingHandlerCallback).stateUpdated(eq(channelValveUID),
eq(new QuantityType<>(100.0, SmartHomeUnits.PERCENT)));
eq(new QuantityType<>(100.0, Units.PERCENT)));
Mockito.verify(thingHandlerCallback).stateUpdated(eq(channelHeatSetPointUID),
eq(new QuantityType<>(25, SIUnits.CELSIUS)));
Mockito.verify(thingHandlerCallback).stateUpdated(eq(channelModeUID),

View File

@ -31,7 +31,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.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.Command;
import org.openhab.core.types.State;
@ -110,13 +110,13 @@ public class ControllerHandler extends DraytonWiserThingHandler<ControllerData>
private State getHeatChannel1Demand() {
return getData().heatingChannels.size() >= 1
? new QuantityType<>(getData().heatingChannels.get(0).getPercentageDemand(), SmartHomeUnits.PERCENT)
? new QuantityType<>(getData().heatingChannels.get(0).getPercentageDemand(), Units.PERCENT)
: UnDefType.UNDEF;
}
private State getHeatChannel2Demand() {
return getData().heatingChannels.size() >= 2
? new QuantityType<>(getData().heatingChannels.get(1).getPercentageDemand(), SmartHomeUnits.PERCENT)
? new QuantityType<>(getData().heatingChannels.get(1).getPercentageDemand(), Units.PERCENT)
: UnDefType.UNDEF;
}

View File

@ -28,7 +28,7 @@ import org.openhab.binding.draytonwiser.internal.model.SystemDTO;
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.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
@ -132,11 +132,10 @@ public class HotWaterHandler extends DraytonWiserThingHandler<HotWaterData> {
final Integer overrideTimeout = firstChannel.getOverrideTimeoutUnixTime();
if (overrideTimeout != null && !"NONE".equalsIgnoreCase(firstChannel.getOverrideType())) {
return new QuantityType<Time>(overrideTimeout - (System.currentTimeMillis() / 1000L),
SmartHomeUnits.SECOND);
return new QuantityType<Time>(overrideTimeout - (System.currentTimeMillis() / 1000L), Units.SECOND);
}
}
return new QuantityType<Time>(0, SmartHomeUnits.SECOND);
return new QuantityType<Time>(0, Units.SECOND);
}
static class HotWaterData {

View File

@ -27,7 +27,7 @@ import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
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;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
@ -123,7 +123,7 @@ public class RoomHandler extends DraytonWiserThingHandler<RoomDTO> {
if (roomStat != null) {
final Integer humidity = roomStat.getMeasuredHumidity();
return humidity == null ? UnDefType.UNDEF : new QuantityType<>(humidity, SmartHomeUnits.PERCENT);
return humidity == null ? UnDefType.UNDEF : new QuantityType<>(humidity, Units.PERCENT);
}
}
return UnDefType.UNDEF;
@ -137,7 +137,7 @@ public class RoomHandler extends DraytonWiserThingHandler<RoomDTO> {
}
private State getDemand() {
return new QuantityType<>(getData().getPercentageDemand(), SmartHomeUnits.PERCENT);
return new QuantityType<>(getData().getPercentageDemand(), Units.PERCENT);
}
private State getHeatRequest() {
@ -167,10 +167,9 @@ public class RoomHandler extends DraytonWiserThingHandler<RoomDTO> {
private State getBoostRemainingState() {
final Integer overrideTimeout = getData().getOverrideTimeoutUnixTime();
if (overrideTimeout != null && !"NONE".equalsIgnoreCase(getData().getOverrideType())) {
return new QuantityType<Time>(overrideTimeout - (System.currentTimeMillis() / 1000L),
SmartHomeUnits.SECOND);
return new QuantityType<Time>(overrideTimeout - (System.currentTimeMillis() / 1000L), Units.SECOND);
}
return new QuantityType<Time>(0, SmartHomeUnits.SECOND);
return new QuantityType<Time>(0, Units.SECOND);
}
private void setBoostDuration(final int durationMinutes) throws DraytonWiserApiException {

View File

@ -28,7 +28,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.thing.Thing;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
@ -93,7 +93,7 @@ public class RoomStatHandler extends DraytonWiserThingHandler<RoomStatData> {
private State getHumidity() {
final Integer humidity = getData().roomStat.getMeasuredHumidity();
return humidity == null ? UnDefType.UNDEF : new QuantityType<>(humidity, SmartHomeUnits.PERCENT);
return humidity == null ? UnDefType.UNDEF : new QuantityType<>(humidity, Units.PERCENT);
}
private State getTemperature() {
@ -120,7 +120,7 @@ public class RoomStatHandler extends DraytonWiserThingHandler<RoomStatData> {
}
private State getBatteryVoltage() {
return new QuantityType<>(getData().device.getBatteryVoltage() / 10.0, SmartHomeUnits.VOLT);
return new QuantityType<>(getData().device.getBatteryVoltage() / 10.0, Units.VOLT);
}
private State getWiserBatteryLevel() {

View File

@ -28,7 +28,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.thing.Thing;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
@ -93,7 +93,7 @@ public class TRVHandler extends DraytonWiserThingHandler<SmartValveData> {
}
private State getDemand() {
return new QuantityType<>(getData().smartValve.getPercentageDemand(), SmartHomeUnits.PERCENT);
return new QuantityType<>(getData().smartValve.getPercentageDemand(), Units.PERCENT);
}
private State getTemperature() {
@ -120,7 +120,7 @@ public class TRVHandler extends DraytonWiserThingHandler<SmartValveData> {
}
private State getBatteryVoltage() {
return new QuantityType<>(getData().device.getBatteryVoltage() / 10.0, SmartHomeUnits.VOLT);
return new QuantityType<>(getData().device.getBatteryVoltage() / 10.0, Units.VOLT);
}
private State getWiserBatteryLevel() {

View File

@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map.Entry;
import org.openhab.binding.dsmr.internal.meter.DSMRMeterConstants;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* Enumeration Cosem Object types
@ -80,7 +80,7 @@ public enum CosemObjectType {
EMETER_POWER_FAILURE_LOG(new OBISIdentifier(1, 0, 99, 97, 0, null), 2, new CosemDecimal("entries"),
new CosemString("obisId"),
/* Next 2 descriptors are repeating */
CosemDate.INSTANCE, new CosemQuantity<>(SmartHomeUnits.SECOND, "duration")),
CosemDate.INSTANCE, new CosemQuantity<>(Units.SECOND, "duration")),
EMETER_VOLTAGE_SAGS_L1(new OBISIdentifier(1, 0, 32, 32, 0, null), CosemDecimal.INSTANCE),
EMETER_VOLTAGE_SAGS_L2(new OBISIdentifier(1, 0, 52, 32, 0, null), CosemDecimal.INSTANCE),
EMETER_VOLTAGE_SAGS_L3(new OBISIdentifier(1, 0, 72, 32, 0, null), CosemDecimal.INSTANCE),

View File

@ -29,7 +29,7 @@ import org.eclipse.jdt.annotation.Nullable;
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.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* {@link CosemQuantity} represents a value with a unit.
@ -41,15 +41,15 @@ import org.openhab.core.library.unit.SmartHomeUnits;
@NonNullByDefault
class CosemQuantity<Q extends @Nullable Quantity<Q>> extends CosemValueDescriptor<QuantityType<Q>> {
public static final CosemQuantity<ElectricCurrent> AMPERE = new CosemQuantity<>(SmartHomeUnits.AMPERE);
public static final CosemQuantity<ElectricCurrent> AMPERE = new CosemQuantity<>(Units.AMPERE);
public static final CosemQuantity<Volume> CUBIC_METRE = new CosemQuantity<>(SIUnits.CUBIC_METRE);
public static final CosemQuantity<Energy> GIGA_JOULE = new CosemQuantity<>(MetricPrefix.GIGA(SmartHomeUnits.JOULE));
public static final CosemQuantity<Power> KILO_WATT = new CosemQuantity<>(MetricPrefix.KILO(SmartHomeUnits.WATT));
public static final CosemQuantity<Energy> KILO_WATT_HOUR = new CosemQuantity<>(SmartHomeUnits.KILOWATT_HOUR);
public static final CosemQuantity<ElectricPotential> VOLT = new CosemQuantity<>(SmartHomeUnits.VOLT);
public static final CosemQuantity<Power> WATT = new CosemQuantity<>(SmartHomeUnits.WATT);
public static final CosemQuantity<Power> KILO_VAR = new CosemQuantity<>(SmartHomeUnits.KILOVAR);
public static final CosemQuantity<Energy> KILO_VAR_HOUR = new CosemQuantity<>(SmartHomeUnits.KILOVAR_HOUR);
public static final CosemQuantity<Energy> GIGA_JOULE = new CosemQuantity<>(MetricPrefix.GIGA(Units.JOULE));
public static final CosemQuantity<Power> KILO_WATT = new CosemQuantity<>(MetricPrefix.KILO(Units.WATT));
public static final CosemQuantity<Energy> KILO_WATT_HOUR = new CosemQuantity<>(Units.KILOWATT_HOUR);
public static final CosemQuantity<ElectricPotential> VOLT = new CosemQuantity<>(Units.VOLT);
public static final CosemQuantity<Power> WATT = new CosemQuantity<>(Units.WATT);
public static final CosemQuantity<Power> KILO_VAR = new CosemQuantity<>(Units.KILOVAR);
public static final CosemQuantity<Energy> KILO_VAR_HOUR = new CosemQuantity<>(Units.KILOVAR_HOUR);
/**
* Pattern to convert a cosem value to a value that can be parsed by {@link QuantityType}.

View File

@ -22,7 +22,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.ecobee.internal.config.EcobeeSensorConfiguration;
import org.openhab.binding.ecobee.internal.dto.thermostat.RemoteSensorCapabilityDTO;
import org.openhab.binding.ecobee.internal.dto.thermostat.RemoteSensorDTO;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
@ -189,7 +189,7 @@ public class EcobeeSensorThingHandler extends BaseThingHandler {
break;
case CAPABILITY_HUMIDITY:
try {
state = EcobeeUtils.undefOrQuantity(Integer.parseInt(value), SmartHomeUnits.PERCENT);
state = EcobeeUtils.undefOrQuantity(Integer.parseInt(value), Units.PERCENT);
} catch (NumberFormatException e) {
state = UnDefType.UNDEF;
}

View File

@ -62,7 +62,7 @@ import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.unit.ImperialUnits;
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.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
@ -414,16 +414,14 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
updateChannel(grp + CH_RUNTIME_DATE, EcobeeUtils.undefOrString(runtime.runtimeDate));
updateChannel(grp + CH_RUNTIME_INTERVAL, EcobeeUtils.undefOrDecimal(runtime.runtimeInterval));
updateChannel(grp + CH_ACTUAL_TEMPERATURE, EcobeeUtils.undefOrTemperature(runtime.actualTemperature));
updateChannel(grp + CH_ACTUAL_HUMIDITY,
EcobeeUtils.undefOrQuantity(runtime.actualHumidity, SmartHomeUnits.PERCENT));
updateChannel(grp + CH_ACTUAL_HUMIDITY, EcobeeUtils.undefOrQuantity(runtime.actualHumidity, Units.PERCENT));
updateChannel(grp + CH_RAW_TEMPERATURE, EcobeeUtils.undefOrTemperature(runtime.rawTemperature));
updateChannel(grp + CH_SHOW_ICON_MODE, EcobeeUtils.undefOrDecimal(runtime.showIconMode));
updateChannel(grp + CH_DESIRED_HEAT, EcobeeUtils.undefOrTemperature(runtime.desiredHeat));
updateChannel(grp + CH_DESIRED_COOL, EcobeeUtils.undefOrTemperature(runtime.desiredCool));
updateChannel(grp + CH_DESIRED_HUMIDITY,
EcobeeUtils.undefOrQuantity(runtime.desiredHumidity, SmartHomeUnits.PERCENT));
updateChannel(grp + CH_DESIRED_HUMIDITY, EcobeeUtils.undefOrQuantity(runtime.desiredHumidity, Units.PERCENT));
updateChannel(grp + CH_DESIRED_DEHUMIDITY,
EcobeeUtils.undefOrQuantity(runtime.desiredDehumidity, SmartHomeUnits.PERCENT));
EcobeeUtils.undefOrQuantity(runtime.desiredDehumidity, Units.PERCENT));
updateChannel(grp + CH_DESIRED_FAN_MODE, EcobeeUtils.undefOrString(runtime.desiredFanMode));
if (runtime.desiredHeatRange != null && runtime.desiredHeatRange.size() == 2) {
updateChannel(grp + CH_DESIRED_HEAT_RANGE_LOW,
@ -538,9 +536,9 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
updateChannel(grp + CH_RANDOM_START_DELAY_COOL, EcobeeUtils.undefOrDecimal(settings.randomStartDelayCool));
updateChannel(grp + CH_RANDOM_START_DELAY_HEAT, EcobeeUtils.undefOrDecimal(settings.randomStartDelayHeat));
updateChannel(grp + CH_HUMIDITY_HIGH_ALERT,
EcobeeUtils.undefOrQuantity(settings.humidityHighAlert, SmartHomeUnits.PERCENT));
EcobeeUtils.undefOrQuantity(settings.humidityHighAlert, Units.PERCENT));
updateChannel(grp + CH_HUMIDITY_LOW_ALERT,
EcobeeUtils.undefOrQuantity(settings.humidityLowAlert, SmartHomeUnits.PERCENT));
EcobeeUtils.undefOrQuantity(settings.humidityLowAlert, Units.PERCENT));
updateChannel(grp + CH_DISABLE_HEAT_PUMP_ALERTS, EcobeeUtils.undefOrOnOff(settings.disableHeatPumpAlerts));
updateChannel(grp + CH_DISABLE_ALERTS_ON_IDT, EcobeeUtils.undefOrOnOff(settings.disableAlertsOnIdt));
updateChannel(grp + CH_HUMIDITY_ALERT_NOTIFY, EcobeeUtils.undefOrOnOff(settings.humidityAlertNotify));
@ -695,7 +693,7 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
updateChannel(grp + CH_FORECAST_PRESSURE,
EcobeeUtils.undefOrQuantity(forecast.pressure, ImperialUnits.INCH_OF_MERCURY));
updateChannel(grp + CH_FORECAST_RELATIVE_HUMIDITY,
EcobeeUtils.undefOrQuantity(forecast.relativeHumidity, SmartHomeUnits.PERCENT));
EcobeeUtils.undefOrQuantity(forecast.relativeHumidity, Units.PERCENT));
updateChannel(grp + CH_FORECAST_DEWPOINT, EcobeeUtils.undefOrTemperature(forecast.dewpoint));
updateChannel(grp + CH_FORECAST_VISIBILITY,
EcobeeUtils.undefOrQuantity(forecast.visibility, SIUnits.METRE));
@ -705,8 +703,8 @@ public class EcobeeThermostatBridgeHandler extends BaseBridgeHandler {
EcobeeUtils.undefOrQuantity(forecast.windGust, ImperialUnits.MILES_PER_HOUR));
updateChannel(grp + CH_FORECAST_WIND_DIRECTION, EcobeeUtils.undefOrString(forecast.windDirection));
updateChannel(grp + CH_FORECAST_WIND_BEARING,
EcobeeUtils.undefOrQuantity(forecast.windBearing, SmartHomeUnits.DEGREE_ANGLE));
updateChannel(grp + CH_FORECAST_POP, EcobeeUtils.undefOrQuantity(forecast.pop, SmartHomeUnits.PERCENT));
EcobeeUtils.undefOrQuantity(forecast.windBearing, Units.DEGREE_ANGLE));
updateChannel(grp + CH_FORECAST_POP, EcobeeUtils.undefOrQuantity(forecast.pop, Units.PERCENT));
updateChannel(grp + CH_FORECAST_TEMP_HIGH, EcobeeUtils.undefOrTemperature(forecast.tempHigh));
updateChannel(grp + CH_FORECAST_TEMP_LOW, EcobeeUtils.undefOrTemperature(forecast.tempLow));
updateChannel(grp + CH_FORECAST_SKY, EcobeeUtils.undefOrDecimal(forecast.sky));

View File

@ -16,7 +16,7 @@ import javax.measure.Unit;
import org.eclipse.jdt.annotation.NonNullByDefault;
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.slf4j.Logger;
@ -30,10 +30,10 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault
public enum EnergeniePWMStateEnum {
VOLTAGE("var V = ", 9, 20, 10, SmartHomeUnits.VOLT),
CURRENT("var V = ", 9, 20, 100, SmartHomeUnits.AMPERE),
POWER("var P=", 6, 20, 466, SmartHomeUnits.WATT),
ENERGY("var E=", 6, 20, 25600, SmartHomeUnits.WATT_HOUR);
VOLTAGE("var V = ", 9, 20, 10, Units.VOLT),
CURRENT("var V = ", 9, 20, 100, Units.AMPERE),
POWER("var P=", 6, 20, 466, Units.WATT),
ENERGY("var E=", 6, 20, 25600, Units.WATT_HOUR);
private final Logger logger = LoggerFactory.getLogger(EnergeniePWMStateEnum.class);

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)) {

View File

@ -15,7 +15,7 @@ package org.openhab.binding.fmiweather.internal;
import static org.openhab.binding.fmiweather.internal.BindingConstants.*;
import static org.openhab.binding.fmiweather.internal.client.ForecastRequest.*;
import static org.openhab.core.library.unit.SIUnits.CELSIUS;
import static org.openhab.core.library.unit.SmartHomeUnits.*;
import static org.openhab.core.library.unit.Units.*;
import java.math.BigDecimal;
import java.time.Instant;

View File

@ -15,7 +15,7 @@ package org.openhab.binding.fmiweather.internal;
import static org.openhab.binding.fmiweather.internal.BindingConstants.*;
import static org.openhab.binding.fmiweather.internal.client.ObservationRequest.*;
import static org.openhab.core.library.unit.SIUnits.*;
import static org.openhab.core.library.unit.SmartHomeUnits.*;
import static org.openhab.core.library.unit.Units.*;
import java.math.BigDecimal;
import java.time.Instant;

View File

@ -23,7 +23,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* Enum for all specific sensor data returned by the Foobot device.
@ -33,10 +33,10 @@ import org.openhab.core.library.unit.SmartHomeUnits;
@NonNullByDefault
public enum FoobotSensor {
TIME("time", "time", null),
PM("pm", "pm", SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
PM("pm", "pm", Units.MICROGRAM_PER_CUBICMETRE),
TEMPERATURE("temperature", "tmp", "C", SIUnits.CELSIUS, ImperialUnits.FAHRENHEIT),
HUMIDITY("humidity", "hum", null),
CO2("co2", "co2", SmartHomeUnits.PARTS_PER_MILLION),
CO2("co2", "co2", Units.PARTS_PER_MILLION),
VOC("voc", "voc", null),
GPI("gpi", "allpollu", null);

View File

@ -45,7 +45,7 @@ import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
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.Channel;
import org.openhab.core.thing.ChannelGroupUID;
import org.openhab.core.thing.ChannelUID;
@ -270,7 +270,7 @@ public class Ipx800v3Handler extends BaseThingHandler implements Ipx800EventList
case ANALOG:
state = new DecimalType(value);
updateState(channelId + PROPERTY_SEPARATOR + CHANNEL_VOLTAGE,
new QuantityType<>(value * ANALOG_SAMPLING, SmartHomeUnits.VOLT));
new QuantityType<>(value * ANALOG_SAMPLING, Units.VOLT));
break;
case CONTACT:
DigitalInputConfiguration config = configuration.as(DigitalInputConfiguration.class);
@ -307,7 +307,7 @@ public class Ipx800v3Handler extends BaseThingHandler implements Ipx800EventList
updateState(channelId, state);
if (!portData.isInitializing()) {
updateState(channelId + PROPERTY_SEPARATOR + CHANNEL_LAST_STATE_DURATION,
new QuantityType<>(sinceLastChange / 1000, SmartHomeUnits.SECOND));
new QuantityType<>(sinceLastChange / 1000, Units.SECOND));
}
portData.setData(value, now);
} else {

View File

@ -59,7 +59,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.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -107,7 +107,7 @@ public class GoEChargerHandler extends BaseThingHandler {
if (goeResponse.maxCurrent == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.maxCurrent, SmartHomeUnits.AMPERE);
return new QuantityType<>(goeResponse.maxCurrent, Units.AMPERE);
case PWM_SIGNAL:
if (goeResponse.pwmSignal == null) {
return UnDefType.UNDEF;
@ -182,7 +182,7 @@ public class GoEChargerHandler extends BaseThingHandler {
if (goeResponse.cableEncoding == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.cableEncoding, SmartHomeUnits.AMPERE);
return new QuantityType<>(goeResponse.cableEncoding, Units.AMPERE);
case PHASES:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
@ -208,19 +208,18 @@ public class GoEChargerHandler extends BaseThingHandler {
return UnDefType.UNDEF;
}
return new QuantityType<>((Double) (goeResponse.sessionChargeConsumption / 360000d),
SmartHomeUnits.KILOWATT_HOUR);
Units.KILOWATT_HOUR);
case SESSION_CHARGE_CONSUMPTION_LIMIT:
if (goeResponse.sessionChargeConsumptionLimit == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>((Double) (goeResponse.sessionChargeConsumptionLimit / 10d),
SmartHomeUnits.KILOWATT_HOUR);
Units.KILOWATT_HOUR);
case TOTAL_CONSUMPTION:
if (goeResponse.totalChargeConsumption == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>((Double) (goeResponse.totalChargeConsumption / 10d),
SmartHomeUnits.KILOWATT_HOUR);
return new QuantityType<>((Double) (goeResponse.totalChargeConsumption / 10d), Units.KILOWATT_HOUR);
case FIRMWARE:
if (goeResponse.firmware == null) {
return UnDefType.UNDEF;
@ -230,49 +229,49 @@ public class GoEChargerHandler extends BaseThingHandler {
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[0], SmartHomeUnits.VOLT);
return new QuantityType<>(goeResponse.energy[0], Units.VOLT);
case VOLTAGE_L2:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[1], SmartHomeUnits.VOLT);
return new QuantityType<>(goeResponse.energy[1], Units.VOLT);
case VOLTAGE_L3:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[2], SmartHomeUnits.VOLT);
return new QuantityType<>(goeResponse.energy[2], Units.VOLT);
case CURRENT_L1:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
// values come in as A*10, 41 means 4.1A
return new QuantityType<>((Double) (goeResponse.energy[4] / 10d), SmartHomeUnits.AMPERE);
return new QuantityType<>((Double) (goeResponse.energy[4] / 10d), Units.AMPERE);
case CURRENT_L2:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>((Double) (goeResponse.energy[5] / 10d), SmartHomeUnits.AMPERE);
return new QuantityType<>((Double) (goeResponse.energy[5] / 10d), Units.AMPERE);
case CURRENT_L3:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>((Double) (goeResponse.energy[6] / 10d), SmartHomeUnits.AMPERE);
return new QuantityType<>((Double) (goeResponse.energy[6] / 10d), Units.AMPERE);
case POWER_L1:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
// values come in as kW*10, 41 means 4.1kW
return new QuantityType<>(goeResponse.energy[7] * 100, SmartHomeUnits.WATT);
return new QuantityType<>(goeResponse.energy[7] * 100, Units.WATT);
case POWER_L2:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[8] * 100, SmartHomeUnits.WATT);
return new QuantityType<>(goeResponse.energy[8] * 100, Units.WATT);
case POWER_L3:
if (goeResponse.energy == null) {
return UnDefType.UNDEF;
}
return new QuantityType<>(goeResponse.energy[9] * 100, SmartHomeUnits.WATT);
return new QuantityType<>(goeResponse.energy[9] * 100, Units.WATT);
}
return UnDefType.UNDEF;
}
@ -293,8 +292,7 @@ public class GoEChargerHandler extends BaseThingHandler {
if (command instanceof DecimalType) {
value = String.valueOf(((DecimalType) command).intValue());
} else if (command instanceof QuantityType<?>) {
value = String.valueOf(
((QuantityType<ElectricCurrent>) command).toUnit(SmartHomeUnits.AMPERE).intValue());
value = String.valueOf(((QuantityType<ElectricCurrent>) command).toUnit(Units.AMPERE).intValue());
}
break;
case SESSION_CHARGE_CONSUMPTION_LIMIT:
@ -302,8 +300,8 @@ public class GoEChargerHandler extends BaseThingHandler {
if (command instanceof DecimalType) {
value = String.valueOf(((DecimalType) command).intValue() * 10);
} else if (command instanceof QuantityType<?>) {
value = String.valueOf(
((QuantityType<Energy>) command).toUnit(SmartHomeUnits.KILOWATT_HOUR).intValue() * 10);
value = String
.valueOf(((QuantityType<Energy>) command).toUnit(Units.KILOWATT_HOUR).intValue() * 10);
}
break;
case ALLOW_CHARGING:

View File

@ -36,7 +36,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.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
@ -79,7 +79,7 @@ public class GroheOndusSenseGuardHandler<T, M> extends GroheOndusBaseHandler<App
newState = new StringType(appliance.getName());
break;
case CHANNEL_PRESSURE:
newState = new QuantityType<>(getLastMeasurement(dataPoint).getPressure(), SmartHomeUnits.BAR);
newState = new QuantityType<>(getLastMeasurement(dataPoint).getPressure(), Units.BAR);
break;
case CHANNEL_TEMPERATURE_GUARD:
newState = new QuantityType<>(getLastMeasurement(dataPoint).getTemperatureGuard(), SIUnits.CELSIUS);

View File

@ -32,7 +32,7 @@ import org.openhab.core.library.types.DecimalType;
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.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -76,7 +76,7 @@ public class GroheOndusSenseHandler<T, M> extends GroheOndusBaseHandler<Applianc
newState = new QuantityType<>(measurement.getTemperature(), SIUnits.CELSIUS);
break;
case CHANNEL_HUMIDITY:
newState = new QuantityType<>(measurement.getHumidity(), SmartHomeUnits.PERCENT);
newState = new QuantityType<>(measurement.getHumidity(), Units.PERCENT);
break;
case CHANNEL_BATTERY:
newState = new DecimalType(getBatteryStatus(appliance));

View File

@ -18,7 +18,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.State;
import org.openhab.core.types.UnDefType;
@ -179,7 +179,7 @@ public class HeliosVentilationDataPoint {
return new QuantityType<>(TEMP_MAP[val], SIUnits.CELSIUS);
case BYTE_PERCENT:
return new QuantityType<>((int) ((val - BYTE_PERCENT_OFFSET) * 100.0 / (255 - BYTE_PERCENT_OFFSET)),
SmartHomeUnits.PERCENT);
Units.PERCENT);
case SWITCH:
if (bitLength != 1) {
return UnDefType.UNDEF;
@ -192,7 +192,7 @@ public class HeliosVentilationDataPoint {
int value = (b & bitMask()) >> bitStart;
return new DecimalType(value);
case PERCENT:
return new QuantityType<>(val, SmartHomeUnits.PERCENT);
return new QuantityType<>(val, Units.PERCENT);
case FANSPEED:
int i = 1;
while (i < FANSPEED_MAP.length && FANSPEED_MAP[i] < val) {

View File

@ -45,7 +45,7 @@ import org.openhab.binding.heos.internal.resources.HeosEventListener;
import org.openhab.binding.heos.internal.resources.Telnet.ReadException;
import org.openhab.core.io.net.http.HttpUtil;
import org.openhab.core.library.types.*;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.*;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.UnDefType;
@ -321,7 +321,7 @@ public abstract class HeosThingBaseHandler extends BaseThingHandler implements H
}
private QuantityType<Time> quantityFromMilliSeconds(long position) {
return new QuantityType<>(position / 1000, SmartHomeUnits.SECOND);
return new QuantityType<>(position / 1000, Units.SECOND);
}
private void handleShuffleMode(HeosObject eventObject) {

View File

@ -21,7 +21,7 @@ import org.openhab.binding.homematic.internal.model.HmDatapoint;
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.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.types.Type;
/**
@ -61,11 +61,11 @@ public class QuantityTypeConverter extends AbstractTypeConverter<QuantityType<?
// convert the given QuantityType to a QuantityType with the unit of the target datapoint
switch (dp.getUnit()) {
case "Lux":
return type.toUnit(SmartHomeUnits.LUX);
return type.toUnit(Units.LUX);
case "degree":
return type.toUnit(SmartHomeUnits.DEGREE_ANGLE);
return type.toUnit(Units.DEGREE_ANGLE);
case HUNDRED_PERCENT:
return type.toUnit(SmartHomeUnits.ONE);
return type.toUnit(Units.ONE);
case UNCORRECT_ENCODED_CELSIUS:
return type.toUnit(SIUnits.CELSIUS);
case "dBm":
@ -103,31 +103,31 @@ public class QuantityTypeConverter extends AbstractTypeConverter<QuantityType<?
case "°C":
return new QuantityType<>(number, SIUnits.CELSIUS);
case "V":
return new QuantityType<>(number, SmartHomeUnits.VOLT);
return new QuantityType<>(number, Units.VOLT);
case "%":
return new QuantityType<>(number, SmartHomeUnits.PERCENT);
return new QuantityType<>(number, Units.PERCENT);
case "mHz":
return new QuantityType<>(number, MetricPrefix.MILLI(SmartHomeUnits.HERTZ));
return new QuantityType<>(number, MetricPrefix.MILLI(Units.HERTZ));
case "Hz":
return new QuantityType<>(number, SmartHomeUnits.HERTZ);
return new QuantityType<>(number, Units.HERTZ);
case "hPa":
return new QuantityType<>(number, SIUnits.PASCAL.multiply(2));
case "Lux":
return new QuantityType<>(number, SmartHomeUnits.LUX);
return new QuantityType<>(number, Units.LUX);
case "degree":
return new QuantityType<>(number, SmartHomeUnits.DEGREE_ANGLE);
return new QuantityType<>(number, Units.DEGREE_ANGLE);
case "km/h":
return new QuantityType<>(number, SIUnits.KILOMETRE_PER_HOUR);
case "mm":
return new QuantityType<>(number, MetricPrefix.MILLI(SIUnits.METRE));
case "W":
return new QuantityType<>(number, SmartHomeUnits.WATT);
return new QuantityType<>(number, Units.WATT);
case "Wh":
return new QuantityType<>(number, SmartHomeUnits.WATT_HOUR);
return new QuantityType<>(number, Units.WATT_HOUR);
case "m3":
return new QuantityType<>(number, SIUnits.CUBIC_METRE);
case HUNDRED_PERCENT:
return new QuantityType<>(number.doubleValue() * 100.0, SmartHomeUnits.PERCENT);
return new QuantityType<>(number.doubleValue() * 100.0, Units.PERCENT);
case "dBm":
case "s":
case "min":
@ -137,7 +137,7 @@ public class QuantityTypeConverter extends AbstractTypeConverter<QuantityType<?
case "year":
case "":
default:
return new QuantityType<>(number, SmartHomeUnits.ONE);
return new QuantityType<>(number, Units.ONE);
}
}

View File

@ -21,7 +21,7 @@ import org.openhab.binding.homematic.internal.model.HmDatapoint;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.types.State;
import tec.uom.se.quantity.QuantityDimension;
@ -90,7 +90,7 @@ public class ConvertFromBindingTest extends BaseConverterTest {
assertThat(((QuantityType<?>) convertedState).getDimension(),
is(QuantityDimension.NONE.divide(QuantityDimension.TIME)));
assertThat(((QuantityType<?>) convertedState).intValue(), is(50000));
assertThat(((QuantityType<?>) convertedState).toUnit(SmartHomeUnits.HERTZ).intValue(), is(50));
assertThat(((QuantityType<?>) convertedState).toUnit(Units.HERTZ).intValue(), is(50));
floatQuantityDp.setValue(0.7);
floatQuantityDp.setUnit("100%");
@ -98,7 +98,7 @@ public class ConvertFromBindingTest extends BaseConverterTest {
assertThat(convertedState, instanceOf(QuantityType.class));
assertThat(((QuantityType<?>) convertedState).getDimension(), is(QuantityDimension.NONE));
assertThat(((QuantityType<?>) convertedState).doubleValue(), is(70.0));
assertThat(((QuantityType<?>) convertedState).getUnit(), is(SmartHomeUnits.PERCENT));
assertThat(((QuantityType<?>) convertedState).toUnit(SmartHomeUnits.ONE).doubleValue(), is(0.7));
assertThat(((QuantityType<?>) convertedState).getUnit(), is(Units.PERCENT));
assertThat(((QuantityType<?>) convertedState).toUnit(Units.ONE).doubleValue(), is(0.7));
}
}

View File

@ -40,7 +40,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.MetricPrefix;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.ThingStatus;
@ -651,15 +651,15 @@ public class HPPrinterBinder {
if (result.getStatus() == RequestStatus.SUCCESS) {
// Inks
handler.updateState(CGROUP_INK, CHANNEL_BLACK_LEVEL,
new QuantityType<>(result.getData().getInkBlack(), SmartHomeUnits.PERCENT));
new QuantityType<>(result.getData().getInkBlack(), Units.PERCENT));
handler.updateState(CGROUP_INK, CHANNEL_COLOR_LEVEL,
new QuantityType<>(result.getData().getInkColor(), SmartHomeUnits.PERCENT));
new QuantityType<>(result.getData().getInkColor(), Units.PERCENT));
handler.updateState(CGROUP_INK, CHANNEL_CYAN_LEVEL,
new QuantityType<>(result.getData().getInkCyan(), SmartHomeUnits.PERCENT));
new QuantityType<>(result.getData().getInkCyan(), Units.PERCENT));
handler.updateState(CGROUP_INK, CHANNEL_MAGENTA_LEVEL,
new QuantityType<>(result.getData().getInkMagenta(), SmartHomeUnits.PERCENT));
new QuantityType<>(result.getData().getInkMagenta(), Units.PERCENT));
handler.updateState(CGROUP_INK, CHANNEL_YELLOW_LEVEL,
new QuantityType<>(result.getData().getInkYellow(), SmartHomeUnits.PERCENT));
new QuantityType<>(result.getData().getInkYellow(), Units.PERCENT));
handler.updateState(CGROUP_USAGE, CHANNEL_JAM_EVENTS, new DecimalType(result.getData().getJamEvents()));
handler.updateState(CGROUP_USAGE, CHANNEL_SUBSCRIPTION,
@ -675,16 +675,16 @@ public class HPPrinterBinder {
handler.updateState(CGROUP_USAGE, CHANNEL_FRONT_PANEL_CANCEL,
new DecimalType(result.getData().getFrontPanelCancelCount()));
handler.updateState(CGROUP_USAGE, CHANNEL_BLACK_MARKING, new QuantityType<>(
result.getData().getInkBlackMarking(), MetricPrefix.MILLI(SmartHomeUnits.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_COLOR_MARKING, new QuantityType<>(
result.getData().getInkColorMarking(), MetricPrefix.MILLI(SmartHomeUnits.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_BLACK_MARKING,
new QuantityType<>(result.getData().getInkBlackMarking(), MetricPrefix.MILLI(Units.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_COLOR_MARKING,
new QuantityType<>(result.getData().getInkColorMarking(), MetricPrefix.MILLI(Units.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_CYAN_MARKING,
new QuantityType<>(result.getData().getInkCyanMarking(), MetricPrefix.MILLI(SmartHomeUnits.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_MAGENTA_MARKING, new QuantityType<>(
result.getData().getInkMagentaMarking(), MetricPrefix.MILLI(SmartHomeUnits.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_YELLOW_MARKING, new QuantityType<>(
result.getData().getInkYellowMarking(), MetricPrefix.MILLI(SmartHomeUnits.LITRE)));
new QuantityType<>(result.getData().getInkCyanMarking(), MetricPrefix.MILLI(Units.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_MAGENTA_MARKING,
new QuantityType<>(result.getData().getInkMagentaMarking(), MetricPrefix.MILLI(Units.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_YELLOW_MARKING,
new QuantityType<>(result.getData().getInkYellowMarking(), MetricPrefix.MILLI(Units.LITRE)));
handler.updateState(CGROUP_USAGE, CHANNEL_BLACK_PAGES_REMAINING,
new DecimalType(result.getData().getInkBlackPagesRemaining()));

View File

@ -29,7 +29,7 @@ import org.openhab.core.config.core.Configuration;
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.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
@ -74,7 +74,7 @@ public class LightLevelHandler extends HueSensorHandler {
// calculate lux, according to
// https://developers.meethue.com/documentation/supported-sensors#clip_zll_lightlevel
double lux = Math.pow(10, (value.subtract(BigDecimal.ONE).divide(new BigDecimal(10000))).doubleValue());
updateState(CHANNEL_ILLUMINANCE, new QuantityType<>(lux, SmartHomeUnits.LUX));
updateState(CHANNEL_ILLUMINANCE, new QuantityType<>(lux, Units.LUX));
}
Object dark = sensor.getState().get(STATE_DARK);

View File

@ -14,7 +14,7 @@ package org.openhab.binding.iammeter.internal;
import javax.measure.Unit;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* The {@link IammeterWEM3080Channel} Enum defines common constants, which are
@ -24,11 +24,11 @@ import org.openhab.core.library.unit.SmartHomeUnits;
*/
public enum IammeterWEM3080Channel {
CHANNEL_VOLTAGE("voltage", SmartHomeUnits.VOLT),
CHANNEL_CURRENT("current", SmartHomeUnits.AMPERE),
CHANNEL_POWER("power", SmartHomeUnits.WATT),
CHANNEL_IMPORTENERGY("importenergy", SmartHomeUnits.KILOWATT_HOUR),
CHANNEL_EXPORTGRID("exportgrid", SmartHomeUnits.KILOWATT_HOUR);
CHANNEL_VOLTAGE("voltage", Units.VOLT),
CHANNEL_CURRENT("current", Units.AMPERE),
CHANNEL_POWER("power", Units.WATT),
CHANNEL_IMPORTENERGY("importenergy", Units.KILOWATT_HOUR),
CHANNEL_EXPORTGRID("exportgrid", Units.KILOWATT_HOUR);
private final String id;
private final Unit<?> unit;

View File

@ -14,7 +14,7 @@ package org.openhab.binding.iammeter.internal;
import javax.measure.Unit;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* The {@link IammeterWEM3080TChannel} Enum defines common constants, which are
@ -24,13 +24,13 @@ import org.openhab.core.library.unit.SmartHomeUnits;
*/
public enum IammeterWEM3080TChannel {
CHANNEL_VOLTAGE("voltage", SmartHomeUnits.VOLT),
CHANNEL_CURRENT("current", SmartHomeUnits.AMPERE),
CHANNEL_POWER("power", SmartHomeUnits.WATT),
CHANNEL_IMPORTENERGY("importenergy", SmartHomeUnits.KILOWATT_HOUR),
CHANNEL_EXPORTGRID("exportgrid", SmartHomeUnits.KILOWATT_HOUR),
CHANNEL_FREQUENCY("frequency", SmartHomeUnits.HERTZ),
CHANNEL_PF("pf", SmartHomeUnits.HERTZ);
CHANNEL_VOLTAGE("voltage", Units.VOLT),
CHANNEL_CURRENT("current", Units.AMPERE),
CHANNEL_POWER("power", Units.WATT),
CHANNEL_IMPORTENERGY("importenergy", Units.KILOWATT_HOUR),
CHANNEL_EXPORTGRID("exportgrid", Units.KILOWATT_HOUR),
CHANNEL_FREQUENCY("frequency", Units.HERTZ),
CHANNEL_PF("pf", Units.HERTZ);
private final String id;
private final Unit<?> unit;

View File

@ -36,7 +36,7 @@ import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.ImperialUnits;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -752,9 +752,8 @@ public abstract class MessageHandler {
batteryPercentage = (batteryLevel - 0x70) * 100 / (0xd2 - 0x70);
}
logger.debug("{}: {} battery percentage: {}", nm(), dev.getAddress(), batteryPercentage);
feature.publish(new QuantityType<>(batteryPercentage, SmartHomeUnits.PERCENT),
StateChangeType.CHANGED, InsteonDeviceHandler.FIELD,
InsteonDeviceHandler.FIELD_BATTERY_PERCENTAGE);
feature.publish(new QuantityType<>(batteryPercentage, Units.PERCENT), StateChangeType.CHANGED,
InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_BATTERY_PERCENTAGE);
break;
default:
logger.warn("unknown cmd2 = {} in info reply message {}", cmd2, msg);
@ -804,7 +803,7 @@ public abstract class MessageHandler {
batteryPercentage = (batteryLevel - 0x70) * 100 / (0xd2 - 0x70);
}
logger.debug("{}: {} battery percentage: {}", nm(), dev.getAddress(), batteryPercentage);
feature.publish(new QuantityType<>(batteryPercentage, SmartHomeUnits.PERCENT), StateChangeType.CHANGED,
feature.publish(new QuantityType<>(batteryPercentage, Units.PERCENT), StateChangeType.CHANGED,
InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_BATTERY_PERCENTAGE);
} catch (FieldException e) {
logger.warn("error parsing {}: ", msg, e);
@ -875,9 +874,9 @@ public abstract class MessageHandler {
}
logger.debug("{}:{} watts: {} kwh: {} ", nm(), f.getDevice().getAddress(), watts, kwh);
feature.publish(new QuantityType<>(kwh, SmartHomeUnits.KILOWATT_HOUR), StateChangeType.CHANGED,
feature.publish(new QuantityType<>(kwh, Units.KILOWATT_HOUR), StateChangeType.CHANGED,
InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_KWH);
feature.publish(new QuantityType<>(watts, SmartHomeUnits.WATT), StateChangeType.CHANGED,
feature.publish(new QuantityType<>(watts, Units.WATT), StateChangeType.CHANGED,
InsteonDeviceHandler.FIELD, InsteonDeviceHandler.FIELD_WATTS);
} catch (FieldException e) {
logger.warn("error parsing {}: ", msg, e);

View File

@ -24,7 +24,7 @@ import org.openhab.binding.jeelink.internal.RollingReadingAverage;
import org.openhab.binding.jeelink.internal.config.BufferedSensorConfig;
import org.openhab.core.library.types.DecimalType;
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;
import org.openhab.core.thing.ThingStatus;
import org.slf4j.Logger;
@ -61,13 +61,12 @@ public class Ec3kSensorHandler extends JeeLinkSensorHandler<Ec3kReading> {
getThing().getUID().getId(), currentWatt, reading.getCurrentWatt(), maxWatt,
reading.getConsumptionTotal(), reading.getApplianceTime(), reading.getSensorTime());
updateState(CURRENT_POWER_CHANNEL, new QuantityType<>(currentWatt, SmartHomeUnits.WATT));
updateState(MAX_POWER_CHANNEL, new QuantityType<>(maxWatt, SmartHomeUnits.WATT));
updateState(CURRENT_POWER_CHANNEL, new QuantityType<>(currentWatt, Units.WATT));
updateState(MAX_POWER_CHANNEL, new QuantityType<>(maxWatt, Units.WATT));
updateState(CONSUMPTION_CHANNEL,
new QuantityType<>(reading.getConsumptionTotal(), SmartHomeUnits.WATT_HOUR));
updateState(APPLIANCE_TIME_CHANNEL,
new QuantityType<>(reading.getApplianceTime(), SmartHomeUnits.HOUR));
updateState(SENSOR_TIME_CHANNEL, new QuantityType<>(reading.getSensorTime(), SmartHomeUnits.HOUR));
new QuantityType<>(reading.getConsumptionTotal(), Units.WATT_HOUR));
updateState(APPLIANCE_TIME_CHANNEL, new QuantityType<>(reading.getApplianceTime(), Units.HOUR));
updateState(SENSOR_TIME_CHANNEL, new QuantityType<>(reading.getSensorTime(), Units.HOUR));
updateState(RESETS_CHANNEL, new DecimalType(reading.getResets()));
}
}

View File

@ -30,7 +30,7 @@ import org.openhab.binding.jeelink.internal.config.LaCrosseTemperatureSensorConf
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.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
@ -130,8 +130,7 @@ public class LaCrosseTemperatureSensorHandler extends JeeLinkSensorHandler<LaCro
getThing().getLabel(), getThing().getUID().getId(), temp, reading.getTemperature(),
reading.getHumidity(), reading.isBatteryNew(), reading.isBatteryLow());
updateState(TEMPERATURE_CHANNEL, new QuantityType<>(temp, SIUnits.CELSIUS));
updateState(HUMIDITY_CHANNEL,
new QuantityType<>(reading.getHumidity(), SmartHomeUnits.PERCENT));
updateState(HUMIDITY_CHANNEL, new QuantityType<>(reading.getHumidity(), Units.PERCENT));
updateState(BATTERY_NEW_CHANNEL, reading.isBatteryNew() ? OnOffType.ON : OnOffType.OFF);
updateState(BATTERY_LOW_CHANNEL, reading.isBatteryLow() ? OnOffType.ON : OnOffType.OFF);
} else {
@ -141,7 +140,7 @@ public class LaCrosseTemperatureSensorHandler extends JeeLinkSensorHandler<LaCro
updateState(TEMPERATURE_CHANNEL + reading.getChannel(),
new QuantityType<>(temp, SIUnits.CELSIUS));
updateState(HUMIDITY_CHANNEL + reading.getChannel(),
new QuantityType<>(reading.getHumidity(), SmartHomeUnits.PERCENT));
new QuantityType<>(reading.getHumidity(), Units.PERCENT));
}
}
}

View File

@ -24,7 +24,7 @@ import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler;
import org.openhab.binding.jeelink.internal.ReadingPublisher;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -84,8 +84,7 @@ public class LgwSensorHandler extends JeeLinkSensorHandler<LgwReading> {
hasHumidityChannel = true;
}
updateState(HUMIDITY_CHANNEL,
new QuantityType<>(reading.getHumidity(), SmartHomeUnits.PERCENT));
updateState(HUMIDITY_CHANNEL, new QuantityType<>(reading.getHumidity(), Units.PERCENT));
}
if (reading.hasPressure()) {

View File

@ -23,7 +23,7 @@ import org.openhab.binding.jeelink.internal.ReadingPublisher;
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.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.slf4j.Logger;
@ -63,8 +63,7 @@ public class Tx22SensorHandler extends JeeLinkSensorHandler<Tx22Reading> {
updateState(TEMPERATURE_CHANNEL, new QuantityType<>(temp, SIUnits.CELSIUS));
}
if (reading.hasHumidity()) {
updateState(HUMIDITY_CHANNEL,
new QuantityType<>(reading.getHumidity(), SmartHomeUnits.PERCENT));
updateState(HUMIDITY_CHANNEL, new QuantityType<>(reading.getHumidity(), Units.PERCENT));
}
if (reading.hasRain()) {
updateState(RAIN_CHANNEL, new QuantityType<>(reading.getRain(), MILLI(SIUnits.METRE)));
@ -74,15 +73,15 @@ public class Tx22SensorHandler extends JeeLinkSensorHandler<Tx22Reading> {
}
if (reading.hasWindDirection()) {
updateState(WIND_ANGLE_CHANNEL,
new QuantityType<>(reading.getWindDirection(), SmartHomeUnits.DEGREE_ANGLE));
new QuantityType<>(reading.getWindDirection(), Units.DEGREE_ANGLE));
}
if (reading.hasWindSpeed()) {
updateState(WIND_STENGTH_CHANNEL,
new QuantityType<>(reading.getWindSpeed(), SmartHomeUnits.METRE_PER_SECOND));
new QuantityType<>(reading.getWindSpeed(), Units.METRE_PER_SECOND));
}
if (reading.hasWindGust()) {
updateState(GUST_STRENGTH_CHANNEL,
new QuantityType<>(reading.getWindGust(), SmartHomeUnits.METRE_PER_SECOND));
new QuantityType<>(reading.getWindGust(), Units.METRE_PER_SECOND));
}
}
}

View File

@ -26,7 +26,7 @@ import org.openhab.binding.jeelink.internal.ReadingPublisher;
import org.openhab.binding.jeelink.internal.config.Pca301SensorConfig;
import org.openhab.core.library.types.OnOffType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.Command;
@ -105,8 +105,8 @@ public class Pca301SensorHandler extends JeeLinkSensorHandler<Pca301Reading> {
BigDecimal current = new BigDecimal(reading.getCurrent()).setScale(1, RoundingMode.HALF_UP);
state = reading.isOn() ? OnOffType.ON : OnOffType.OFF;
updateState(CURRENT_POWER_CHANNEL, new QuantityType<>(current, SmartHomeUnits.WATT));
updateState(CONSUMPTION_CHANNEL, new QuantityType<>(reading.getTotal(), SmartHomeUnits.WATT_HOUR));
updateState(CURRENT_POWER_CHANNEL, new QuantityType<>(current, Units.WATT));
updateState(CONSUMPTION_CHANNEL, new QuantityType<>(reading.getTotal(), Units.WATT_HOUR));
updateState(SWITCHING_STATE_CHANNEL, state);
logger.debug("updated states for thing {} ({}): state={}, current={}, total={}",

View File

@ -21,7 +21,7 @@ import org.openhab.binding.jeelink.internal.JeeLinkSensorHandler;
import org.openhab.binding.jeelink.internal.ReadingPublisher;
import org.openhab.core.library.types.DecimalType;
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;
import org.openhab.core.thing.ThingStatus;
import org.slf4j.Logger;
@ -60,13 +60,12 @@ public class RevoltSensorHandler extends JeeLinkSensorHandler<RevoltReading> {
getThing().getUID().getId(), power, powerFactor, consumption, current, reading.getVoltage(),
reading.getFrequency());
updateState(CURRENT_POWER_CHANNEL, new QuantityType<>(power, SmartHomeUnits.WATT));
updateState(CURRENT_POWER_CHANNEL, new QuantityType<>(power, Units.WATT));
updateState(POWER_FACTOR_CHANNEL, new DecimalType(powerFactor));
updateState(CONSUMPTION_CHANNEL, new QuantityType<>(consumption, SmartHomeUnits.WATT_HOUR));
updateState(ELECTRIC_CURRENT_CHANNEL, new QuantityType<>(current, SmartHomeUnits.AMPERE));
updateState(ELECTRIC_POTENTIAL_CHANNEL,
new QuantityType<>(reading.getVoltage(), SmartHomeUnits.VOLT));
updateState(FREQUENCY_CHANNEL, new QuantityType<>(reading.getFrequency(), SmartHomeUnits.HERTZ));
updateState(CONSUMPTION_CHANNEL, new QuantityType<>(consumption, Units.WATT_HOUR));
updateState(ELECTRIC_CURRENT_CHANNEL, new QuantityType<>(current, Units.AMPERE));
updateState(ELECTRIC_POTENTIAL_CHANNEL, new QuantityType<>(reading.getVoltage(), Units.VOLT));
updateState(FREQUENCY_CHANNEL, new QuantityType<>(reading.getFrequency(), Units.HERTZ));
}
}

View File

@ -46,7 +46,7 @@ import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.PlayPauseType;
import org.openhab.core.library.types.RewindFastforwardType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -77,7 +77,7 @@ public class KaleidescapeHandler extends BaseThingHandler implements Kaleidescap
private final Map<String, String> cache = new HashMap<String, String>();
protected final HttpClient httpClient;
protected final Unit<Time> apiSecondUnit = SmartHomeUnits.SECOND;
protected final Unit<Time> apiSecondUnit = Units.SECOND;
private ThingTypeUID thingTypeUID = THING_TYPE_PLAYER;
private @Nullable ScheduledFuture<?> reconnectJob;

View File

@ -50,7 +50,7 @@ import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.RawType;
import org.openhab.core.library.types.RewindFastforwardType;
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
@ -958,17 +958,17 @@ public class KodiHandler extends BaseThingHandler implements KodiEventListener {
@Override
public void updateCurrentTime(long currentTime) {
updateState(CHANNEL_CURRENTTIME, createQuantityState(currentTime, SmartHomeUnits.SECOND));
updateState(CHANNEL_CURRENTTIME, createQuantityState(currentTime, Units.SECOND));
}
@Override
public void updateCurrentTimePercentage(double currentTimePercentage) {
updateState(CHANNEL_CURRENTTIMEPERCENTAGE, createQuantityState(currentTimePercentage, SmartHomeUnits.PERCENT));
updateState(CHANNEL_CURRENTTIMEPERCENTAGE, createQuantityState(currentTimePercentage, Units.PERCENT));
}
@Override
public void updateDuration(long duration) {
updateState(CHANNEL_DURATION, createQuantityState(duration, SmartHomeUnits.SECOND));
updateState(CHANNEL_DURATION, createQuantityState(duration, Units.SECOND));
}
@Override

View File

@ -30,7 +30,7 @@ import org.openhab.core.config.core.validation.ConfigValidationException;
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.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
@ -145,8 +145,7 @@ public class KonnectedHandler extends BaseThingHandler {
updateState(channelId, onOffType);
} else if (channelType.equalsIgnoreCase(CHANNEL_HUMIDITY)) {
// if the state is of type number then this means it is the humidity channel of the dht22
updateState(channelId,
new QuantityType<>(Double.parseDouble(event.getHumi()), SmartHomeUnits.PERCENT));
updateState(channelId, new QuantityType<>(Double.parseDouble(event.getHumi()), Units.PERCENT));
} else if (channelType.equalsIgnoreCase(CHANNEL_TEMPERATURE)) {
Configuration configuration = channel.getConfiguration();
if (((Boolean) configuration.get(CHANNEL_TEMPERATURE_TYPE))) {

View File

@ -27,7 +27,7 @@ import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
@ -52,20 +52,20 @@ public class WebscrapeHandler extends BaseThingHandler {
public WebscrapeHandler(Thing thing) {
super(thing);
channelConfigs.add(new ChannelConfig("acPower", "td", 4, SmartHomeUnits.WATT));
channelConfigs.add(new ChannelConfig("totalEnergy", "td", 7, SmartHomeUnits.KILOWATT_HOUR));
channelConfigs.add(new ChannelConfig("dayEnergy", "td", 10, SmartHomeUnits.KILOWATT_HOUR));
channelConfigs.add(new ChannelConfig("acPower", "td", 4, Units.WATT));
channelConfigs.add(new ChannelConfig("totalEnergy", "td", 7, Units.KILOWATT_HOUR));
channelConfigs.add(new ChannelConfig("dayEnergy", "td", 10, Units.KILOWATT_HOUR));
channelConfigs.add(new ChannelConfig("status", "td", 13, null));
channelConfigs.add(new ChannelConfig("str1Voltage", "td", 19, SmartHomeUnits.VOLT));
channelConfigs.add(new ChannelConfig("str1Current", "td", 25, SmartHomeUnits.AMPERE));
channelConfigs.add(new ChannelConfig("str2Voltage", "td", 33, SmartHomeUnits.VOLT));
channelConfigs.add(new ChannelConfig("str2Current", "td", 39, SmartHomeUnits.AMPERE));
channelConfigs.add(new ChannelConfig("l1Voltage", "td", 22, SmartHomeUnits.VOLT));
channelConfigs.add(new ChannelConfig("l1Power", "td", 28, SmartHomeUnits.WATT));
channelConfigs.add(new ChannelConfig("l2Voltage", "td", 36, SmartHomeUnits.VOLT));
channelConfigs.add(new ChannelConfig("l2Power", "td", 42, SmartHomeUnits.WATT));
channelConfigs.add(new ChannelConfig("l3Voltage", "td", 46, SmartHomeUnits.VOLT));
channelConfigs.add(new ChannelConfig("l3Power", "td", 49, SmartHomeUnits.WATT));
channelConfigs.add(new ChannelConfig("str1Voltage", "td", 19, Units.VOLT));
channelConfigs.add(new ChannelConfig("str1Current", "td", 25, Units.AMPERE));
channelConfigs.add(new ChannelConfig("str2Voltage", "td", 33, Units.VOLT));
channelConfigs.add(new ChannelConfig("str2Current", "td", 39, Units.AMPERE));
channelConfigs.add(new ChannelConfig("l1Voltage", "td", 22, Units.VOLT));
channelConfigs.add(new ChannelConfig("l1Power", "td", 28, Units.WATT));
channelConfigs.add(new ChannelConfig("l2Voltage", "td", 36, Units.VOLT));
channelConfigs.add(new ChannelConfig("l2Power", "td", 42, Units.WATT));
channelConfigs.add(new ChannelConfig("l3Voltage", "td", 46, Units.VOLT));
channelConfigs.add(new ChannelConfig("l3Power", "td", 49, Units.WATT));
}
@Override

View File

@ -44,7 +44,7 @@ import org.eclipse.jetty.client.api.ContentResponse;
import org.openhab.core.library.types.DecimalType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -220,7 +220,7 @@ public class ThirdGenerationHandler extends BaseThingHandler {
break;
}
case PERCEMTAGE: {
updateState(channeluid, new QuantityType<>(value, SmartHomeUnits.PERCENT));
updateState(channeluid, new QuantityType<>(value, Units.PERCENT));
break;
}
case KILOGRAM: {
@ -228,28 +228,28 @@ public class ThirdGenerationHandler extends BaseThingHandler {
break;
}
case SECONDS: {
updateState(channeluid, new QuantityType<>(value, SmartHomeUnits.SECOND));
updateState(channeluid, new QuantityType<>(value, Units.SECOND));
break;
}
case KILOWATT_HOUR: {
updateState(channeluid, new QuantityType<>(value / 1000, SmartHomeUnits.KILOWATT_HOUR));
updateState(channeluid, new QuantityType<>(value / 1000, Units.KILOWATT_HOUR));
break;
}
case WATT: {
updateState(channeluid, new QuantityType<>(value, SmartHomeUnits.WATT));
updateState(channeluid, new QuantityType<>(value, Units.WATT));
break;
}
case AMPERE: {
updateState(channeluid, new QuantityType<>(value, SmartHomeUnits.AMPERE));
updateState(channeluid, new QuantityType<>(value, Units.AMPERE));
break;
}
case AMPERE_HOUR: {
// Ampere hours are not supported by ESH, but 1 AH is equal tp 3600 coulomb...
updateState(channeluid, new QuantityType<>(value * 3600, SmartHomeUnits.COULOMB));
updateState(channeluid, new QuantityType<>(value * 3600, Units.COULOMB));
break;
}
case VOLT: {
updateState(channeluid, new QuantityType<>(value, SmartHomeUnits.VOLT));
updateState(channeluid, new QuantityType<>(value, Units.VOLT));
break;
}
default: {

View File

@ -14,7 +14,7 @@ package org.openhab.binding.lcn.internal.converter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.library.unit.SIUnits;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
/**
* Holds all Converter objects.
@ -34,12 +34,12 @@ public class Converters {
static {
TEMPERATURE = new ValueConverter(SIUnits.CELSIUS, n -> (n - 1000) / 10d, h -> Math.round(h * 10) + 1000);
LIGHT = new ValueConverter(SmartHomeUnits.LUX, Converters::lightToHumanReadable, Converters::lightToNative);
CO2 = new ValueConverter(SmartHomeUnits.PARTS_PER_MILLION, n -> (double) n, Math::round);
CURRENT = new ValueConverter(SmartHomeUnits.AMPERE, n -> n / 100d, h -> Math.round(h * 100));
VOLTAGE = new ValueConverter(SmartHomeUnits.VOLT, n -> n / 400d, h -> Math.round(h * 400));
ANGLE = new ValueConverter(SmartHomeUnits.DEGREE_ANGLE, n -> (n - 1000) / 10d, Converters::angleToNative);
WINDSPEED = new ValueConverter(SmartHomeUnits.METRE_PER_SECOND, n -> n / 10d, h -> Math.round(h * 10));
LIGHT = new ValueConverter(Units.LUX, Converters::lightToHumanReadable, Converters::lightToNative);
CO2 = new ValueConverter(Units.PARTS_PER_MILLION, n -> (double) n, Math::round);
CURRENT = new ValueConverter(Units.AMPERE, n -> n / 100d, h -> Math.round(h * 100));
VOLTAGE = new ValueConverter(Units.VOLT, n -> n / 400d, h -> Math.round(h * 400));
ANGLE = new ValueConverter(Units.DEGREE_ANGLE, n -> (n - 1000) / 10d, Converters::angleToNative);
WINDSPEED = new ValueConverter(Units.METRE_PER_SECOND, n -> n / 10d, h -> Math.round(h * 10));
IDENTITY = new ValueConverter(null, n -> (double) n, Math::round);
}

View File

@ -16,7 +16,7 @@ import java.math.BigDecimal;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.unit.SmartHomeUnits;
import org.openhab.core.library.unit.Units;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -31,7 +31,7 @@ public class S0Converter extends ValueConverter {
protected double pulsesPerKwh;
public S0Converter(@Nullable Object parameter) {
super(SmartHomeUnits.WATT, n -> 0d, h -> 0L);
super(Units.WATT, n -> 0d, h -> 0L);
if (parameter == null) {
pulsesPerKwh = 1000;

View File

@ -40,7 +40,7 @@ import org.openhab.binding.linky.internal.dto.UserInfo;
import org.openhab.core.i18n.LocaleProvider;
import org.openhab.core.library.types.DateTimeType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
@ -264,14 +264,13 @@ public class LinkyHandler extends BaseThingHandler {
private void updateKwhChannel(String channelId, double consumption) {
logger.debug("Update channel {} with {}", channelId, consumption);
updateState(channelId, Double.isNaN(consumption) ? UnDefType.UNDEF
: new QuantityType<>(consumption, SmartHomeUnits.KILOWATT_HOUR));
updateState(channelId,
Double.isNaN(consumption) ? UnDefType.UNDEF : new QuantityType<>(consumption, Units.KILOWATT_HOUR));
}
private void updateVAChannel(String channelId, double power) {
logger.debug("Update channel {} with {}", channelId, power);
updateState(channelId,
Double.isNaN(power) ? UnDefType.UNDEF : new QuantityType<>(power, SmartHomeUnits.VOLT_AMPERE));
updateState(channelId, Double.isNaN(power) ? UnDefType.UNDEF : new QuantityType<>(power, Units.VOLT_AMPERE));
}
/**

View File

@ -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);

View File

@ -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);
}
});

Some files were not shown because too many files have changed in this diff Show More