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;
// 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);
}
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;
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;
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();
}
} 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);
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;
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)) {
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
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);
// 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);
}
}
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
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);
// 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
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
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);
// 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);
}
}
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
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);
// 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
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
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);
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.
* Returns the age in days.
*/
public QuantityType<Time> getAge() {
- return new QuantityType<>(age, SmartHomeUnits.DAY);
+ return new QuantityType<>(age, Units.DAY);
}
/**
* Returns the illumination.
*/
public QuantityType<Dimensionless> getIllumination() {
- return new QuantityType<>(illumination, SmartHomeUnits.PERCENT);
+ return new QuantityType<>(illumination, Units.PERCENT);
}
/**
* Returns the age in degree.
*/
public QuantityType<Angle> getAgeDegree() {
- return new QuantityType<>(ageDegree, SmartHomeUnits.DEGREE_ANGLE);
+ return new QuantityType<>(ageDegree, Units.DEGREE_ANGLE);
}
/**
* Returns the age in percent.
*/
public QuantityType<Dimensionless> getAgePercent() {
- return new QuantityType<>(agePercent, SmartHomeUnits.PERCENT);
+ return new QuantityType<>(agePercent, Units.PERCENT);
}
/**
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.
* Returns the azimuth.
*/
public QuantityType<Angle> getAzimuth() {
- return new QuantityType<>(azimuth, SmartHomeUnits.DEGREE_ANGLE);
+ return new QuantityType<>(azimuth, Units.DEGREE_ANGLE);
}
/**
* Returns the elevation.
*/
public QuantityType<Angle> getElevation() {
- return new QuantityType<>(elevation, SmartHomeUnits.DEGREE_ANGLE);
+ return new QuantityType<>(elevation, Units.DEGREE_ANGLE);
}
public double getElevationAsDouble() {
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
* 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);
}
}
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.
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);
}
/**
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.
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);
}
}
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;
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()));
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;
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));
}
}
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;
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));
}
}
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
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");
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;
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));
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;
/**
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
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;
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.
@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),
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;
@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))));
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));
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)));
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)));
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)));
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)));
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;
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,
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,
break;
case CHANNEL_ID_TX_POWER:
atLeastOneRuuviFieldPresent |= updateStateIfLinked(channelUID,
- ruuvitagData.getTxPower(), SmartHomeUnits.DECIBEL_MILLIWATTS);
+ ruuvitagData.getTxPower(), Units.DECIBEL_MILLIWATTS);
break;
}
}
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;
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 {
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.
return CELSIUS;
} else if (unit == ImperialUnits.FAHRENHEIT) {
return FAHRENHEIT;
- } else if (unit == SmartHomeUnits.PERCENT) {
+ } else if (unit == Units.PERCENT) {
return PERCENTAGE;
} else {
return DIMENSIONLESS;
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;
.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:
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;
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));
}
}
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;
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;
// 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);
}
}
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;
return UnDefType.NULL;
}
- return new QuantityType<>(value, SmartHomeUnits.HOUR);
+ return new QuantityType<>(value, Units.HOUR);
}
}
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();
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;
} 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;
}
@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);
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;
if (count == -1) {
return UnDefType.NULL;
} else {
- return new QuantityType<Dimensionless>(count, SmartHomeUnits.ONE);
+ return new QuantityType<Dimensionless>(count, Units.ONE);
}
}
}
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;
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);
}
* @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
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;
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;
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;
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;
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),
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;
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;
}
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;
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 {
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;
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;
}
private State getDemand() {
- return new QuantityType<>(getData().getPercentageDemand(), SmartHomeUnits.PERCENT);
+ return new QuantityType<>(getData().getPercentageDemand(), Units.PERCENT);
}
private State getHeatRequest() {
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 {
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;
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() {
}
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() {
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;
}
private State getDemand() {
- return new QuantityType<>(getData().smartValve.getPercentageDemand(), SmartHomeUnits.PERCENT);
+ return new QuantityType<>(getData().smartValve.getPercentageDemand(), Units.PERCENT);
}
private State getTemperature() {
}
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() {
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
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),
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.
@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}.
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;
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;
}
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;
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,
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));
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));
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));
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;
@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);
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;
/**
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);
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;
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() {
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
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;
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);
}
}
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;
}
double voltage = value / 50.0; // 0..250 = 0.0..5.0V
- return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
+ return new QuantityType<>(voltage, Units.VOLT);
}
@Override
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;
/**
@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);
}
}
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;
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)) {
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;
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);
}
}
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;
return new QuantityType<>(
Long.parseLong(HexUtils.bytesToHex(new byte[] { getDB_3(), getDB_2() }), 16) * factor,
- SmartHomeUnits.KILOWATT_HOUR);
+ Units.KILOWATT_HOUR);
}
return UnDefType.UNDEF;
}
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;
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;
}
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() {
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;
/**
@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);
}
}
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;
/**
@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);
}
}
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;
/**
@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);
}
}
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;
/**
@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);
}
}
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;
}
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() {
}
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() {
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;
double voltage = db3 / 50.0; // 0..250 = 0.0..5.0V
- return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
+ return new QuantityType<>(voltage, Units.VOLT);
}
@Override
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;
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() {
double voltage = db2 / 51.0; // 0..255 = 0.0..5.0V
- return new QuantityType<>(voltage, SmartHomeUnits.VOLT);
+ return new QuantityType<>(voltage, Units.VOLT);
}
@Override
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;
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() {
}
private State getValvePosition() {
- return new QuantityType<>(getDB_3Value(), SmartHomeUnits.PERCENT);
+ return new QuantityType<>(getDB_3Value(), Units.PERCENT);
}
}
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;
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);
}
}
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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)) {
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;
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;
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.
@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);
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;
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);
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 {
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;
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;
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;
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;
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;
}
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:
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:
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;
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);
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;
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));
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;
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;
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) {
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;
}
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) {
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;
/**
// 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":
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":
case "year":
case "":
default:
- return new QuantityType<>(number, SmartHomeUnits.ONE);
+ return new QuantityType<>(number, Units.ONE);
}
}
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;
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%");
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));
}
}
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;
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,
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()));
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;
// 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);
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
*/
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;
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
*/
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;
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;
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);
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);
}
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);
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;
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()));
}
}
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;
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 {
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));
}
}
}
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;
hasHumidityChannel = true;
}
- updateState(HUMIDITY_CHANNEL,
- new QuantityType<>(reading.getHumidity(), SmartHomeUnits.PERCENT));
+ updateState(HUMIDITY_CHANNEL, new QuantityType<>(reading.getHumidity(), Units.PERCENT));
}
if (reading.hasPressure()) {
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;
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)));
}
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));
}
}
}
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;
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={}",
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;
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));
}
}
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;
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;
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;
@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
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;
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))) {
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;
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
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;
break;
}
case PERCEMTAGE: {
- updateState(channeluid, new QuantityType<>(value, SmartHomeUnits.PERCENT));
+ updateState(channeluid, new QuantityType<>(value, Units.PERCENT));
break;
}
case KILOGRAM: {
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: {
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.
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);
}
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;
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;
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;
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));
}
/**
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;
/**
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);
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);
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;
/**
*/
@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);
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);
}
});
import org.openhab.binding.luftdateninfo.internal.utils.NumberUtils;
import org.openhab.core.library.dimension.Density;
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;
/**
@NonNullByDefault
public class PMHandler extends BaseSensorHandler {
- protected QuantityType<Density> pm25Cache = QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
- protected QuantityType<Density> pm100Cache = QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
+ protected QuantityType<Density> pm25Cache = QuantityType.valueOf(-1, Units.MICROGRAM_PER_CUBICMETRE);
+ protected QuantityType<Density> pm100Cache = QuantityType.valueOf(-1, Units.MICROGRAM_PER_CUBICMETRE);
public PMHandler(Thing thing) {
super(thing);
valueList.forEach(v -> {
if (v.getValueType().equals(P1)) {
pm100Cache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1),
- SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
+ Units.MICROGRAM_PER_CUBICMETRE);
updateState(PM100_CHANNEL, pm100Cache);
} else if (v.getValueType().equals(P2)) {
pm25Cache = QuantityType.valueOf(NumberUtils.round(v.getValue(), 1),
- SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
+ Units.MICROGRAM_PER_CUBICMETRE);
updateState(PM25_CHANNEL, pm25Cache);
}
});
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
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;
/**
* The {@link ConditionHandlerTest} Test Condition Handler updates
UpdateStatus result = condHandler.updateChannels(pmJson);
assertEquals(UpdateStatus.OK, result, "Valid update");
assertEquals(QuantityType.valueOf(22.7, SIUnits.CELSIUS), condHandler.getTemperature(), "Temperature");
- assertEquals(QuantityType.valueOf(61.0, SmartHomeUnits.PERCENT), condHandler.getHumidity(), "Humidity");
+ assertEquals(QuantityType.valueOf(61.0, Units.PERCENT), condHandler.getHumidity(), "Humidity");
assertEquals(QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressure(), "Pressure");
assertEquals(QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressureSea(), "Pressure Sea");
} else {
UpdateStatus result = condHandler.updateChannels(pmJson);
assertEquals(UpdateStatus.OK, result, "Valid update");
assertEquals(QuantityType.valueOf(21.5, SIUnits.CELSIUS), condHandler.getTemperature(), "Temperature");
- assertEquals(QuantityType.valueOf(58.5, SmartHomeUnits.PERCENT), condHandler.getHumidity(), "Humidity");
+ assertEquals(QuantityType.valueOf(58.5, Units.PERCENT), condHandler.getHumidity(), "Humidity");
assertEquals(QuantityType.valueOf(100200.0, SIUnits.PASCAL), condHandler.getPressure(), "Pressure");
assertEquals(QuantityType.valueOf(101968.7, SIUnits.PASCAL), condHandler.getPressureSea(), "Pressure Sea");
} else {
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
import org.openhab.core.library.types.QuantityType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
/**
* The {@link NoiseHandlerTest} Test Noise Handler updates
if (pmJson != null) {
UpdateStatus result = noiseHandler.updateChannels(pmJson);
assertEquals(UpdateStatus.OK, result, "Valid update");
- assertEquals(QuantityType.valueOf(51.0, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseEQCache(),
- "Noise EQ");
- assertEquals(QuantityType.valueOf(47.2, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMinCache(),
- "Noise Min");
- assertEquals(QuantityType.valueOf(57.0, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMaxCache(),
- "Noise Max");
+ assertEquals(QuantityType.valueOf(51.0, Units.DECIBEL), noiseHandler.getNoiseEQCache(), "Noise EQ");
+ assertEquals(QuantityType.valueOf(47.2, Units.DECIBEL), noiseHandler.getNoiseMinCache(), "Noise Min");
+ assertEquals(QuantityType.valueOf(57.0, Units.DECIBEL), noiseHandler.getNoiseMaxCache(), "Noise Max");
} else {
assertTrue(false);
}
if (pmJson != null) {
UpdateStatus result = noiseHandler.updateChannels(pmJson);
assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
- assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseEQCache(),
- "Values undefined");
- assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMinCache(),
- "Values undefined");
- assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMaxCache(),
- "Values undefined");
+ assertEquals(QuantityType.valueOf(-1, Units.DECIBEL), noiseHandler.getNoiseEQCache(), "Values undefined");
+ assertEquals(QuantityType.valueOf(-1, Units.DECIBEL), noiseHandler.getNoiseMinCache(), "Values undefined");
+ assertEquals(QuantityType.valueOf(-1, Units.DECIBEL), noiseHandler.getNoiseMaxCache(), "Values undefined");
} else {
assertTrue(false);
}
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
import org.openhab.core.library.types.QuantityType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (pmJson != null) {
UpdateStatus result = pmHandler.updateChannels(pmJson);
assertEquals(UpdateStatus.OK, result, "Valid update");
- assertEquals(QuantityType.valueOf(2.9, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
- "PM25");
- assertEquals(QuantityType.valueOf(5.2, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
- "PM100");
+ assertEquals(QuantityType.valueOf(2.9, Units.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(), "PM25");
+ assertEquals(QuantityType.valueOf(5.2, Units.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(), "PM100");
} else {
assertTrue(false);
}
if (pmJson != null) {
UpdateStatus result = pmHandler.updateChannels(pmJson);
assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
- assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
+ assertEquals(QuantityType.valueOf(-1, Units.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
"Values undefined");
- assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
+ assertEquals(QuantityType.valueOf(-1, Units.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
"Values undefined");
} else {
assertTrue(false);
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = dateFormat.parse(ps.duration);
long minutes = date.getTime() / 1000L / 60l;
- updateState(CHANNEL_PROG_DURATION, toQuantityType(minutes, SmartHomeUnits.MINUTE));
+ updateState(CHANNEL_PROG_DURATION, toQuantityType(minutes, Units.MINUTE));
} catch (ParseException e) {
logger.debug("{}: Unable to parse programDuration: {}", thingId, ps.duration);
}
updateState(CHANNEL_PROG_DURATION, new StringType(event.duration.toString()));
}
if (event.playPostion != -1) {
- updateState(CHANNEL_PROG_POS, toQuantityType(event.playPostion / 6, SmartHomeUnits.MINUTE));
+ updateState(CHANNEL_PROG_POS, toQuantityType(event.playPostion / 6, Units.MINUTE));
}
} else {
logger.debug("{}: Unknown MR event, JSON={}", thingId, jsonEvent);
import org.openhab.core.library.types.RawType;
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;
} else if (type.equals("Number:Pressure")) {
state = new QuantityType<>(value, HECTO(SIUnits.PASCAL));
} else if (type.equals("Number:Speed")) {
- state = new QuantityType<>(value, SmartHomeUnits.METRE_PER_SECOND);
+ state = new QuantityType<>(value, Units.METRE_PER_SECOND);
}
return state;
import static org.openhab.binding.meteostick.internal.MeteostickBindingConstants.*;
import static org.openhab.core.library.unit.MetricPrefix.MILLI;
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.math.RoundingMode;
import org.openhab.binding.mihome.internal.XiaomiItemUpdateListener;
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.ChannelUID;
import org.openhab.core.thing.Thing;
protected static final Unit<Temperature> TEMPERATURE_UNIT = SIUnits.CELSIUS;
protected static final Unit<Pressure> PRESSURE_UNIT = KILO(SIUnits.PASCAL);
- protected static final Unit<Dimensionless> PERCENT_UNIT = SmartHomeUnits.PERCENT;
- protected static final Unit<Angle> ANGLE_UNIT = SmartHomeUnits.DEGREE_ANGLE;
- protected static final Unit<Time> TIME_UNIT = MILLI(SmartHomeUnits.SECOND);
+ protected static final Unit<Dimensionless> PERCENT_UNIT = Units.PERCENT;
+ protected static final Unit<Angle> ANGLE_UNIT = Units.DEGREE_ANGLE;
+ protected static final Unit<Time> TIME_UNIT = MILLI(Units.SECOND);
private static final String REMOVE_DEVICE = "remove_device";
private static final long ONLINE_TIMEOUT_MILLIS = TimeUnit.HOURS.toMillis(2);
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 tec.uom.se.unit.Units;
+import org.openhab.core.library.unit.Units;
/**
* Enum of the units used in the miio protocol
CELCIUS(SIUnits.CELSIUS, "C"),
FAHRENHEIT(ImperialUnits.FAHRENHEIT),
- SECOND(SmartHomeUnits.SECOND, "seconds"),
- MINUTE(SmartHomeUnits.MINUTE, "minutes"),
- HOUR(SmartHomeUnits.HOUR, "hours"),
- AMPERE(SmartHomeUnits.AMPERE),
- WATT(SmartHomeUnits.WATT),
- SQUARE_METRE(Units.SQUARE_METRE, "square_meter", "squaremeter"),
- PERCENT(SmartHomeUnits.PERCENT);
+ SECOND(Units.SECOND, "seconds"),
+ MINUTE(Units.MINUTE, "minutes"),
+ HOUR(Units.HOUR, "hours"),
+ AMPERE(Units.AMPERE),
+ WATT(Units.WATT),
+ SQUARE_METRE(SIUnits.SQUARE_METRE, "square_meter", "squaremeter"),
+ PERCENT(Units.PERCENT);
private final Unit<?> unit;
private final String[] aliasses;
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;
updateState(basicChannel.getChannel(), new QuantityType<>(val.getAsBigDecimal(), SIUnits.CELSIUS));
break;
case "electriccurrent":
- updateState(basicChannel.getChannel(),
- new QuantityType<>(val.getAsBigDecimal(), SmartHomeUnits.AMPERE));
+ updateState(basicChannel.getChannel(), new QuantityType<>(val.getAsBigDecimal(), Units.AMPERE));
break;
case "energy":
- updateState(basicChannel.getChannel(), new QuantityType<>(val.getAsBigDecimal(), SmartHomeUnits.WATT));
+ updateState(basicChannel.getChannel(), new QuantityType<>(val.getAsBigDecimal(), Units.WATT));
break;
case "time":
- updateState(basicChannel.getChannel(), new QuantityType<>(val.getAsBigDecimal(), SmartHomeUnits.HOUR));
+ updateState(basicChannel.getChannel(), new QuantityType<>(val.getAsBigDecimal(), Units.HOUR));
break;
default:
updateState(basicChannel.getChannel(), new DecimalType(val.getAsBigDecimal()));
import org.openhab.core.library.types.RawType;
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;
}
if (statusInfo.getCleanTime() != null) {
updateState(CHANNEL_CLEAN_TIME,
- new QuantityType<>(TimeUnit.SECONDS.toMinutes(statusInfo.getCleanTime()), SmartHomeUnits.MINUTE));
+ new QuantityType<>(TimeUnit.SECONDS.toMinutes(statusInfo.getCleanTime()), Units.MINUTE));
}
safeUpdateState(CHANNEL_DND_ENABLED, statusInfo.getDndEnabled());
int sideBrush = consumablesData.get("side_brush_work_time").getAsInt();
int filter = consumablesData.get("filter_work_time").getAsInt();
int sensor = consumablesData.get("sensor_dirty_time").getAsInt();
- updateState(CHANNEL_CONSUMABLE_MAIN_TIME, new QuantityType<>(
- ConsumablesType.remainingHours(mainBrush, ConsumablesType.MAIN_BRUSH), SmartHomeUnits.HOUR));
+ updateState(CHANNEL_CONSUMABLE_MAIN_TIME,
+ new QuantityType<>(ConsumablesType.remainingHours(mainBrush, ConsumablesType.MAIN_BRUSH), Units.HOUR));
updateState(CHANNEL_CONSUMABLE_MAIN_PERC,
new DecimalType(ConsumablesType.remainingPercent(mainBrush, ConsumablesType.MAIN_BRUSH)));
- updateState(CHANNEL_CONSUMABLE_SIDE_TIME, new QuantityType<>(
- ConsumablesType.remainingHours(sideBrush, ConsumablesType.SIDE_BRUSH), SmartHomeUnits.HOUR));
+ updateState(CHANNEL_CONSUMABLE_SIDE_TIME,
+ new QuantityType<>(ConsumablesType.remainingHours(sideBrush, ConsumablesType.SIDE_BRUSH), Units.HOUR));
updateState(CHANNEL_CONSUMABLE_SIDE_PERC,
new DecimalType(ConsumablesType.remainingPercent(sideBrush, ConsumablesType.SIDE_BRUSH)));
- updateState(CHANNEL_CONSUMABLE_FILTER_TIME, new QuantityType<>(
- ConsumablesType.remainingHours(filter, ConsumablesType.FILTER), SmartHomeUnits.HOUR));
+ updateState(CHANNEL_CONSUMABLE_FILTER_TIME,
+ new QuantityType<>(ConsumablesType.remainingHours(filter, ConsumablesType.FILTER), Units.HOUR));
updateState(CHANNEL_CONSUMABLE_FILTER_PERC,
new DecimalType(ConsumablesType.remainingPercent(filter, ConsumablesType.FILTER)));
- updateState(CHANNEL_CONSUMABLE_SENSOR_TIME, new QuantityType<>(
- ConsumablesType.remainingHours(sensor, ConsumablesType.SENSOR), SmartHomeUnits.HOUR));
+ updateState(CHANNEL_CONSUMABLE_SENSOR_TIME,
+ new QuantityType<>(ConsumablesType.remainingHours(sensor, ConsumablesType.SENSOR), Units.HOUR));
updateState(CHANNEL_CONSUMABLE_SENSOR_PERC,
new DecimalType(ConsumablesType.remainingPercent(sensor, ConsumablesType.SENSOR)));
return true;
private boolean updateHistory(JsonArray historyData) {
logger.trace("Cleaning history data: {}", historyData.toString());
updateState(CHANNEL_HISTORY_TOTALTIME,
- new QuantityType<>(TimeUnit.SECONDS.toMinutes(historyData.get(0).getAsLong()), SmartHomeUnits.MINUTE));
+ new QuantityType<>(TimeUnit.SECONDS.toMinutes(historyData.get(0).getAsLong()), Units.MINUTE));
updateState(CHANNEL_HISTORY_TOTALAREA,
new QuantityType<>(historyData.get(1).getAsDouble() / 1000000D, SIUnits.SQUARE_METRE));
updateState(CHANNEL_HISTORY_COUNT, new DecimalType(historyData.get(2).toString()));
historyRecord.addProperty("finished", finished);
updateState(CHANNEL_HISTORY_START_TIME, new DateTimeType(startTime));
updateState(CHANNEL_HISTORY_END_TIME, new DateTimeType(endTime));
- updateState(CHANNEL_HISTORY_DURATION, new QuantityType<>(duration, SmartHomeUnits.MINUTE));
+ updateState(CHANNEL_HISTORY_DURATION, new QuantityType<>(duration, Units.MINUTE));
updateState(CHANNEL_HISTORY_AREA, new QuantityType<>(area, SIUnits.SQUARE_METRE));
updateState(CHANNEL_HISTORY_ERROR, new DecimalType(error));
updateState(CHANNEL_HISTORY_FINISH, new DecimalType(finished));
package org.openhab.binding.miio.internal;
import static org.junit.jupiter.api.Assertions.*;
-import static tec.uom.se.unit.Units.SQUARE_METRE;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.SIUnits;
+import org.openhab.core.library.unit.Units;
/**
* Test case for {@link MiIoQuantityTypes}
public void regularsUnitTest() {
String unitName = "minute";
- assertEquals(SmartHomeUnits.MINUTE, MiIoQuantiyTypes.get(unitName));
+ assertEquals(Units.MINUTE, MiIoQuantiyTypes.get(unitName));
unitName = "Minute";
- assertEquals(SmartHomeUnits.MINUTE, MiIoQuantiyTypes.get(unitName));
+ assertEquals(Units.MINUTE, MiIoQuantiyTypes.get(unitName));
}
@Test
public void aliasUnitsTest() {
String unitName = "square_meter";
- assertEquals(SQUARE_METRE, MiIoQuantiyTypes.get(unitName));
+ assertEquals(SIUnits.SQUARE_METRE, MiIoQuantiyTypes.get(unitName));
unitName = "Square_meter";
- assertEquals(SQUARE_METRE, MiIoQuantiyTypes.get(unitName));
+ assertEquals(SIUnits.SQUARE_METRE, MiIoQuantiyTypes.get(unitName));
unitName = "squaremeter";
- assertEquals(SQUARE_METRE, MiIoQuantiyTypes.get(unitName));
+ assertEquals(SIUnits.SQUARE_METRE, MiIoQuantiyTypes.get(unitName));
}
}
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
if (command instanceof RefreshType) {
if (config.power != null) {
if (heater.isHeatingActive()) {
- updateState(channelUID, new QuantityType<>(config.power, SmartHomeUnits.WATT));
+ updateState(channelUID, new QuantityType<>(config.power, Units.WATT));
} else {
- updateState(channelUID, new QuantityType<>(0, SmartHomeUnits.WATT));
+ updateState(channelUID, new QuantityType<>(0, Units.WATT));
}
} else {
updateState(channelUID, UnDefType.UNDEF);
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.modbus.e3dc.internal.modbus.Data;
import org.openhab.core.library.types.QuantityType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.openhab.io.transport.modbus.ValueBuffer;
/**
* Positive value - Battery is charging = Power consumer
* Negative value - Battery is discharging = Power supplier
*/
- pvPowerSupply = QuantityType.valueOf(pvPowerSupplyL, SmartHomeUnits.WATT);
+ pvPowerSupply = QuantityType.valueOf(pvPowerSupplyL, Units.WATT);
long batteryPower = wrap.getSInt32Swap();
if (batteryPower > 0) {
// Battery is charging so Power is consumed by Battery
- batteryPowerSupply = QuantityType.valueOf(0, SmartHomeUnits.WATT);
- batteryPowerConsumption = QuantityType.valueOf(batteryPower, SmartHomeUnits.WATT);
+ batteryPowerSupply = QuantityType.valueOf(0, Units.WATT);
+ batteryPowerConsumption = QuantityType.valueOf(batteryPower, Units.WATT);
} else {
// Battery is discharging so Power is provided by Battery
- batteryPowerSupply = QuantityType.valueOf(batteryPower * -1, SmartHomeUnits.WATT);
- batteryPowerConsumption = QuantityType.valueOf(0, SmartHomeUnits.WATT);
+ batteryPowerSupply = QuantityType.valueOf(batteryPower * -1, Units.WATT);
+ batteryPowerConsumption = QuantityType.valueOf(0, Units.WATT);
}
// int32_swap value = 4 byte
long householdPowerConsumptionL = wrap.getSInt32Swap();
- householdPowerConsumption = QuantityType.valueOf(householdPowerConsumptionL, SmartHomeUnits.WATT);
+ householdPowerConsumption = QuantityType.valueOf(householdPowerConsumptionL, Units.WATT);
/*
* int32_swap value don't provide negative values!
long gridPower = wrap.getSInt32Swap();
if (gridPower > 0) {
// Power is provided by Grid
- gridPowerSupply = QuantityType.valueOf(gridPower, SmartHomeUnits.WATT);
- gridPowerConsumpition = QuantityType.valueOf(0, SmartHomeUnits.WATT);
+ gridPowerSupply = QuantityType.valueOf(gridPower, Units.WATT);
+ gridPowerConsumpition = QuantityType.valueOf(0, Units.WATT);
} else {
// Power is consumed by Grid
- gridPowerConsumpition = QuantityType.valueOf(gridPower * -1, SmartHomeUnits.WATT);
- gridPowerSupply = QuantityType.valueOf(0, SmartHomeUnits.WATT);
+ gridPowerConsumpition = QuantityType.valueOf(gridPower * -1, Units.WATT);
+ gridPowerSupply = QuantityType.valueOf(0, Units.WATT);
}
// int32_swap value = 4 byte
- externalPowerSupply = QuantityType.valueOf(wrap.getSInt32Swap(), SmartHomeUnits.WATT);
+ externalPowerSupply = QuantityType.valueOf(wrap.getSInt32Swap(), Units.WATT);
// int32_swap value = 4 byte
- wallboxPowerConsumption = QuantityType.valueOf(wrap.getSInt32Swap(), SmartHomeUnits.WATT);
+ wallboxPowerConsumption = QuantityType.valueOf(wrap.getSInt32Swap(), Units.WATT);
// int32_swap value = 4 byte
- wallboxPVPowerConsumption = QuantityType.valueOf(wrap.getSInt32Swap(), SmartHomeUnits.WATT);
+ wallboxPVPowerConsumption = QuantityType.valueOf(wrap.getSInt32Swap(), Units.WATT);
// unit8 + uint8 - one register with split value for Autarky & Self Consumption
- autarky = QuantityType.valueOf(wrap.getSInt8(), SmartHomeUnits.PERCENT);
- selfConsumption = QuantityType.valueOf(wrap.getSInt8(), SmartHomeUnits.PERCENT);
+ autarky = QuantityType.valueOf(wrap.getSInt8(), Units.PERCENT);
+ selfConsumption = QuantityType.valueOf(wrap.getSInt8(), Units.PERCENT);
// uint16 for Battery State of Charge
- batterySOC = QuantityType.valueOf(wrap.getSInt16(), SmartHomeUnits.PERCENT);
+ batterySOC = QuantityType.valueOf(wrap.getSInt16(), Units.PERCENT);
}
}
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.modbus.e3dc.internal.modbus.Data;
import org.openhab.core.library.types.QuantityType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.openhab.io.transport.modbus.ValueBuffer;
/**
public StringBlock(byte[] bArray) {
ValueBuffer wrap = ValueBuffer.wrap(bArray);
// straight forward - for each String the values Volt, Ampere and then Watt. All unt16 = 2 bytes values
- string1Volt = QuantityType.valueOf(wrap.getUInt16(), SmartHomeUnits.VOLT);
- string2Volt = QuantityType.valueOf(wrap.getUInt16(), SmartHomeUnits.VOLT);
- string3Volt = QuantityType.valueOf(wrap.getUInt16(), SmartHomeUnits.VOLT);
+ string1Volt = QuantityType.valueOf(wrap.getUInt16(), Units.VOLT);
+ string2Volt = QuantityType.valueOf(wrap.getUInt16(), Units.VOLT);
+ string3Volt = QuantityType.valueOf(wrap.getUInt16(), Units.VOLT);
// E3DC Modbus Spec chapter 3.1.2, page 16 - Ampere values shall be handled with factor 0.01
- string1Ampere = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.01), SmartHomeUnits.AMPERE);
- string2Ampere = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.01), SmartHomeUnits.AMPERE);
- string3Ampere = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.01), SmartHomeUnits.AMPERE);
- string1Watt = QuantityType.valueOf(wrap.getUInt16(), SmartHomeUnits.WATT);
- string2Watt = QuantityType.valueOf(wrap.getUInt16(), SmartHomeUnits.WATT);
- string3Watt = QuantityType.valueOf(wrap.getUInt16(), SmartHomeUnits.WATT);
+ string1Ampere = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.01), Units.AMPERE);
+ string2Ampere = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.01), Units.AMPERE);
+ string3Ampere = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.01), Units.AMPERE);
+ string1Watt = QuantityType.valueOf(wrap.getUInt16(), Units.WATT);
+ string2Watt = QuantityType.valueOf(wrap.getUInt16(), Units.WATT);
+ string3Watt = QuantityType.valueOf(wrap.getUInt16(), Units.WATT);
}
}
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;
if (unit != null) {
switch (unit) {
case HeliosVariable.UNIT_DAY:
- val = val.toUnit(SmartHomeUnits.DAY);
+ val = val.toUnit(Units.DAY);
break;
case HeliosVariable.UNIT_HOUR:
- val = val.toUnit(SmartHomeUnits.HOUR);
+ val = val.toUnit(Units.HOUR);
break;
case HeliosVariable.UNIT_MIN:
- val = val.toUnit(SmartHomeUnits.MINUTE);
+ val = val.toUnit(Units.MINUTE);
break;
case HeliosVariable.UNIT_SEC:
- val = val.toUnit(SmartHomeUnits.SECOND);
+ val = val.toUnit(Units.SECOND);
break;
case HeliosVariable.UNIT_VOLT:
- val = val.toUnit(SmartHomeUnits.VOLT);
+ val = val.toUnit(Units.VOLT);
break;
case HeliosVariable.UNIT_PERCENT:
- val = val.toUnit(SmartHomeUnits.PERCENT);
+ val = val.toUnit(Units.PERCENT);
break;
case HeliosVariable.UNIT_PPM:
- val = val.toUnit(SmartHomeUnits.PARTS_PER_MILLION);
+ val = val.toUnit(Units.PARTS_PER_MILLION);
break;
case HeliosVariable.UNIT_TEMP:
val = val.toUnit(SIUnits.CELSIUS);
if (unit == null) {
return null;
} else if (unit.equals(HeliosVariable.UNIT_DAY)) {
- return new QuantityType<>(Integer.parseInt(value), SmartHomeUnits.DAY);
+ return new QuantityType<>(Integer.parseInt(value), Units.DAY);
} else if (unit.equals(HeliosVariable.UNIT_HOUR)) {
- return new QuantityType<>(Integer.parseInt(value), SmartHomeUnits.HOUR);
+ return new QuantityType<>(Integer.parseInt(value), Units.HOUR);
} else if (unit.equals(HeliosVariable.UNIT_MIN)) {
- return new QuantityType<>(Integer.parseInt(value), SmartHomeUnits.MINUTE);
+ return new QuantityType<>(Integer.parseInt(value), Units.MINUTE);
} else if (unit.equals(HeliosVariable.UNIT_SEC)) {
- return new QuantityType<>(Integer.parseInt(value), SmartHomeUnits.SECOND);
+ return new QuantityType<>(Integer.parseInt(value), Units.SECOND);
} else if (unit.equals(HeliosVariable.UNIT_VOLT)) {
- return new QuantityType<>(Float.parseFloat(value), SmartHomeUnits.VOLT);
+ return new QuantityType<>(Float.parseFloat(value), Units.VOLT);
} else if (unit.equals(HeliosVariable.UNIT_PERCENT)) {
- return new QuantityType<>(Float.parseFloat(value), SmartHomeUnits.PERCENT);
+ return new QuantityType<>(Float.parseFloat(value), Units.PERCENT);
} else if (unit.equals(HeliosVariable.UNIT_PPM)) {
- return new QuantityType<>(Float.parseFloat(value), SmartHomeUnits.PARTS_PER_MILLION);
+ return new QuantityType<>(Float.parseFloat(value), Units.PARTS_PER_MILLION);
} else if (unit.equals(HeliosVariable.UNIT_TEMP)) {
return new QuantityType<>(Float.parseFloat(value), SIUnits.CELSIUS);
} else {
import static org.openhab.binding.modbus.stiebeleltron.internal.StiebelEltronBindingConstants.*;
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.util.Optional;
import static org.openhab.core.library.unit.MetricPrefix.KILO;
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.util.HashMap;
import java.util.HashSet;
import static org.openhab.binding.modbus.sunspec.internal.SunSpecConstants.*;
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.util.Optional;
package org.openhab.binding.modbus.sunspec.internal.handler;
import static org.openhab.binding.modbus.sunspec.internal.SunSpecConstants.*;
-import static org.openhab.core.library.unit.SmartHomeUnits.*;
+import static org.openhab.core.library.unit.Units.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.modbus.sunspec.internal.dto.MeterModelBlock;
import org.openhab.core.library.types.IncreaseDecreaseType;
import org.openhab.core.library.types.QuantityType;
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.StateDescriptionFragmentBuilder;
import org.openhab.core.types.UnDefType;
} else if (command instanceof QuantityType<?>) {
QuantityType<?> qType = (QuantityType<?>) command;
- if (qType.getUnit().isCompatible(SmartHomeUnits.ONE)) {
+ if (qType.getUnit().isCompatible(Units.ONE)) {
newValue = qType.toBigDecimal();
} else {
qType = qType.toUnit(unit);
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
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.StateDescriptionFragmentBuilder;
import org.openhab.core.types.UnDefType;
} else //
// A quantity type need to be converted according to the current min/max values
if (command instanceof QuantityType) {
- QuantityType<?> qty = ((QuantityType<?>) command).toUnit(SmartHomeUnits.PERCENT);
+ QuantityType<?> qty = ((QuantityType<?>) command).toUnit(Units.PERCENT);
if (qty != null) {
BigDecimal v = qty.toBigDecimal();
v = v.subtract(min).multiply(HUNDRED).divide(max.subtract(min), MathContext.DECIMAL128);
import static org.openhab.binding.mystrom.internal.MyStromBindingConstants.CHANNEL_SWITCH;
import static org.openhab.binding.mystrom.internal.MyStromBindingConstants.CHANNEL_TEMPERATURE;
import static org.openhab.core.library.unit.SIUnits.CELSIUS;
-import static org.openhab.core.library.unit.SmartHomeUnits.WATT;
+import static org.openhab.core.library.unit.Units.WATT;
import java.time.Duration;
import java.util.concurrent.ExecutionException;
import org.openhab.binding.neohub.internal.NeoHubBindingConstants.NeoHubReturnResult;
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.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
onlineDeviceCount++;
}
}
- state = new QuantityType<>((100.0 * onlineDeviceCount) / totalDeviceCount, SmartHomeUnits.PERCENT);
+ state = new QuantityType<>((100.0 * onlineDeviceCount) / totalDeviceCount, Units.PERCENT);
}
updateState(CHAN_MESH_NETWORK_QOS, state);
}
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;
case CHANNEL_FAN_TIMER_ACTIVE:
return getAsOnOffTypeOrNull(thermostat.isFanTimerActive());
case CHANNEL_FAN_TIMER_DURATION:
- return getAsQuantityTypeOrNull(thermostat.getFanTimerDuration(), SmartHomeUnits.MINUTE);
+ return getAsQuantityTypeOrNull(thermostat.getFanTimerDuration(), Units.MINUTE);
case CHANNEL_FAN_TIMER_TIMEOUT:
return getAsDateTimeTypeOrNull(thermostat.getFanTimerTimeout());
case CHANNEL_HAS_FAN:
case CHANNEL_HAS_LEAF:
return getAsOnOffTypeOrNull(thermostat.isHasLeaf());
case CHANNEL_HUMIDITY:
- return getAsQuantityTypeOrNull(thermostat.getHumidity(), SmartHomeUnits.PERCENT);
+ return getAsQuantityTypeOrNull(thermostat.getHumidity(), Units.PERCENT);
case CHANNEL_LAST_CONNECTION:
return getAsDateTimeTypeOrNull(thermostat.getLastConnection());
case CHANNEL_LOCKED:
case CHANNEL_TEMPERATURE:
return getAsQuantityTypeOrNull(thermostat.getAmbientTemperature(), thermostat.getTemperatureUnit());
case CHANNEL_TIME_TO_TARGET:
- return getAsQuantityTypeOrNull(thermostat.getTimeToTarget(), SmartHomeUnits.MINUTE);
+ return getAsQuantityTypeOrNull(thermostat.getTimeToTarget(), Units.MINUTE);
case CHANNEL_USING_EMERGENCY_HEAT:
return getAsOnOffTypeOrNull(thermostat.isUsingEmergencyHeat());
default:
} else if (CHANNEL_FAN_TIMER_DURATION.equals(channelUID.getId())) {
if (command instanceof QuantityType) {
// Update fan timer duration to the command value
- QuantityType<Time> minuteQuantity = ((QuantityType<Time>) command).toUnit(SmartHomeUnits.MINUTE);
+ QuantityType<Time> minuteQuantity = ((QuantityType<Time>) command).toUnit(Units.MINUTE);
if (minuteQuantity != null) {
addUpdateRequest("fan_timer_duration", minuteQuantity.intValue());
}
import org.openhab.core.config.core.Configuration;
import org.openhab.core.i18n.TimeZoneProvider;
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.ChannelUID;
import org.openhab.core.thing.Thing;
public abstract class AbstractNetatmoThingHandler extends BaseThingHandler {
// 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);
public static final Unit<Speed> API_WIND_SPEED_UNIT = SIUnits.KILOMETRE_PER_HOUR;
- public static final Unit<Angle> API_WIND_DIRECTION_UNIT = SmartHomeUnits.DEGREE_ANGLE;
+ public static final Unit<Angle> API_WIND_DIRECTION_UNIT = Units.DEGREE_ANGLE;
public static final Unit<Length> API_RAIN_UNIT = MILLI(SIUnits.METRE);
- public static final Unit<Dimensionless> API_CO2_UNIT = SmartHomeUnits.PARTS_PER_MILLION;
- public static final Unit<Dimensionless> API_NOISE_UNIT = SmartHomeUnits.DECIBEL;
+ public static final Unit<Dimensionless> API_CO2_UNIT = Units.PARTS_PER_MILLION;
+ public static final Unit<Dimensionless> API_NOISE_UNIT = Units.DECIBEL;
private final Logger logger = LoggerFactory.getLogger(AbstractNetatmoThingHandler.class);
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.QuantityType;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
case CHANNEL_DEPRECATED_TIME:
presenceDetection.getValue(value -> {
updateState(CHANNEL_LATENCY,
- new QuantityType<>(value.getLowestLatency(), MetricPrefix.MILLI(SmartHomeUnits.SECOND)));
+ new QuantityType<>(value.getLowestLatency(), MetricPrefix.MILLI(Units.SECOND)));
updateState(CHANNEL_DEPRECATED_TIME, new DecimalType(value.getLowestLatency()));
});
break;
@Override
public void partialDetectionResult(PresenceDetectionValue value) {
updateState(CHANNEL_ONLINE, OnOffType.ON);
- updateState(CHANNEL_LATENCY,
- new QuantityType<>(value.getLowestLatency(), MetricPrefix.MILLI(SmartHomeUnits.SECOND)));
+ updateState(CHANNEL_LATENCY, new QuantityType<>(value.getLowestLatency(), MetricPrefix.MILLI(Units.SECOND)));
updateState(CHANNEL_DEPRECATED_TIME, new DecimalType(value.getLowestLatency()));
}
package org.openhab.binding.network.internal.handler;
import static org.openhab.binding.network.internal.NetworkBindingConstants.*;
-import static org.openhab.core.library.unit.SmartHomeUnits.*;
+import static org.openhab.core.library.unit.Units.*;
import java.math.BigDecimal;
import java.util.concurrent.ScheduledFuture;
import org.openhab.core.library.types.DateTimeType;
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.thing.ThingStatus;
updateState(CHANNEL_TEST_ISRUNNING, OnOffType.ON);
updateState(CHANNEL_TEST_START, new DateTimeType());
updateState(CHANNEL_TEST_END, UnDefType.NULL);
- updateProgress(new QuantityType<>(0, SmartHomeUnits.PERCENT));
+ updateProgress(new QuantityType<>(0, Units.PERCENT));
socket.startDownload(configuration.getDownloadURL());
} else {
logger.info("A speedtest is already in progress, will retry on next refresh");
@Override
public void onProgress(float percent, @Nullable SpeedTestReport testReport) {
- updateProgress(new QuantityType<>(Math.round(percent), SmartHomeUnits.PERCENT));
+ updateProgress(new QuantityType<>(Math.round(percent), Units.PERCENT));
}
private void updateProgress(State state) {
import javax.measure.quantity.Power;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.type.ChannelTypeUID;
import tec.uom.se.format.SimpleUnitFormat;
import tec.uom.se.unit.ProductUnit;
-import tec.uom.se.unit.Units;
/**
* The {@link NUTBindingConstants} class defines common constants, which are
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;
enum NutName {
// UPS
UPS_ALARM("upsAlarm", "ups.alarm", StringType.class),
- UPS_LOAD("upsLoad", "ups.load", SmartHomeUnits.PERCENT),
+ UPS_LOAD("upsLoad", "ups.load", Units.PERCENT),
UPS_POWER("upsPower", "ups.power", NUTBindingConstants.VOLT_AMPERE),
- UPS_REALPOWER("upsRealpower", "ups.realpower", SmartHomeUnits.WATT),
+ UPS_REALPOWER("upsRealpower", "ups.realpower", Units.WATT),
UPS_STATUS("upsStatus", "ups.status", StringType.class),
UPS_TEMPERATURE("upsTemperature", "ups.temperature", SIUnits.CELSIUS),
UPS_TEST_RESULT("upsTestResult", "ups.test.result", StringType.class),
// Input
- INPUT_CURRENT("inputCurrent", "input.current", SmartHomeUnits.AMPERE),
+ INPUT_CURRENT("inputCurrent", "input.current", Units.AMPERE),
INPUT_CURRENT_STATUS("inputCurrentStatus", "input.current.status", StringType.class),
- INPUT_LOAD("inputLoad", "input.load", SmartHomeUnits.PERCENT),
- INPUT_REALPOWER("inputRealpower", "input.realpower", SmartHomeUnits.WATT),
+ INPUT_LOAD("inputLoad", "input.load", Units.PERCENT),
+ INPUT_REALPOWER("inputRealpower", "input.realpower", Units.WATT),
INPUT_QUALITY("inputQuality", "input.quality", StringType.class),
INPUT_TRANSFER_REASON("inputTransferReason", "input.transfer.reason", StringType.class),
- INPUT_VOLTAGE("inputVoltage", "input.voltage", SmartHomeUnits.VOLT),
+ INPUT_VOLTAGE("inputVoltage", "input.voltage", Units.VOLT),
INPUT_VOLTAGE_STATUS("inputVoltageStatus", "input.voltage.status", StringType.class),
// Output
- OUTPUT_CURRENT("outputCurrent", "output.current", SmartHomeUnits.AMPERE),
- OUTPUT_VOLTAGE("outputVoltage", "output.voltage", SmartHomeUnits.VOLT),
+ OUTPUT_CURRENT("outputCurrent", "output.current", Units.AMPERE),
+ OUTPUT_VOLTAGE("outputVoltage", "output.voltage", Units.VOLT),
// Battery
- BATTERY_CHARGE("batteryCharge", "battery.charge", SmartHomeUnits.PERCENT),
- BATTERY_RUNTIME("batteryRuntime", "battery.runtime", SmartHomeUnits.SECOND),
- BATTERY_VOLTAGE("batteryVoltage", "battery.voltage", SmartHomeUnits.VOLT);
+ BATTERY_CHARGE("batteryCharge", "battery.charge", Units.PERCENT),
+ BATTERY_RUNTIME("batteryRuntime", "battery.runtime", Units.SECOND),
+ BATTERY_VOLTAGE("batteryVoltage", "battery.voltage", Units.VOLT);
private static final Map<String, NutName> NUT_NAME_MAP = Stream.of(NutName.values())
.collect(Collectors.toMap(NutName::getChannelId, Function.identity()));
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.Channel;
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.types.State;
putQuantityType(result, channel, value, DIV_10, SIUnits.CELSIUS);
break;
case CHANNEL_TYPE_PRESSURE:
- putQuantityType(result, channel, value, DIV_10, SmartHomeUnits.BAR);
+ putQuantityType(result, channel, value, DIV_10, Units.BAR);
break;
case CHANNEL_TYPE_ENERGY:
- putQuantityType(result, channel, value, DIV_10, MetricPrefix.KILO(SmartHomeUnits.WATT_HOUR));
+ putQuantityType(result, channel, value, DIV_10, MetricPrefix.KILO(Units.WATT_HOUR));
break;
case CHANNEL_TYPE_POWER:
- putQuantityType(result, channel, value, DIV_100, MetricPrefix.KILO(SmartHomeUnits.WATT));
+ putQuantityType(result, channel, value, DIV_100, MetricPrefix.KILO(Units.WATT));
break;
case CHANNEL_TYPE_SWITCH_RW:
case CHANNEL_TYPE_SWITCH:
putOnOffType(result, channel, value);
break;
case CHANNEL_TYPE_ELECTRIC_CURRENT:
- putQuantityType(result, channel, value, DIV_10, SmartHomeUnits.AMPERE);
+ putQuantityType(result, channel, value, DIV_10, Units.AMPERE);
break;
case CHANNEL_TYPE_TIME_UNSCALED:
- putQuantityType(result, channel, value, UNSCALED, SmartHomeUnits.HOUR);
+ putQuantityType(result, channel, value, UNSCALED, Units.HOUR);
break;
case CHANNEL_TYPE_TIME_SCALE10:
- putQuantityType(result, channel, value, DIV_10, SmartHomeUnits.HOUR);
+ putQuantityType(result, channel, value, DIV_10, Units.HOUR);
break;
case CHANNEL_TYPE_FREQUENCY_UNSCALED:
- putQuantityType(result, channel, value, UNSCALED, SmartHomeUnits.HERTZ);
+ putQuantityType(result, channel, value, UNSCALED, Units.HERTZ);
break;
case CHANNEL_TYPE_FREQUENCY_SCALE10:
- putQuantityType(result, channel, value, DIV_10, SmartHomeUnits.HERTZ);
+ putQuantityType(result, channel, value, DIV_10, Units.HERTZ);
break;
case CHANNEL_TYPE_FLOW:
- putQuantityType(result, channel, value, DIV_10,
- SmartHomeUnits.LITRE.divide(SmartHomeUnits.MINUTE));
+ putQuantityType(result, channel, value, DIV_10, Units.LITRE.divide(Units.MINUTE));
break;
case CHANNEL_TYPE_SPEED:
- putQuantityType(result, channel, value, UNSCALED, SmartHomeUnits.PERCENT);
+ putQuantityType(result, channel, value, UNSCALED, Units.PERCENT);
break;
case CHANNEL_TYPE_NUMBER_SCALE100:
putDecimalType(result, channel, value, DIV_100);
import org.openhab.binding.nikohomecontrol.internal.protocol.NikoHomeControlCommunication;
import org.openhab.binding.nikohomecontrol.internal.protocol.nhc2.NhcEnergyMeter2;
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.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
if (power == null) {
updateState(CHANNEL_POWER, UnDefType.UNDEF);
} else {
- updateState(CHANNEL_POWER, new QuantityType<>(power, SmartHomeUnits.WATT));
+ updateState(CHANNEL_POWER, new QuantityType<>(power, Units.WATT));
}
updateStatus(ThingStatus.ONLINE);
}
import org.openhab.core.io.transport.serial.UnsupportedCommOperationException;
import org.openhab.core.library.dimension.Density;
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;
if (sensorData.isValidData()) {
logger.debug("Updating channels with data: {}", sensorData);
- QuantityType<Density> statePM10 = new QuantityType<>(sensorData.getPm10(),
- SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
+ QuantityType<Density> statePM10 = new QuantityType<>(sensorData.getPm10(), Units.MICROGRAM_PER_CUBICMETRE);
updateState(NovaFineDustBindingConstants.CHANNEL_PM10, statePM10);
this.statePM10 = statePM10;
- QuantityType<Density> statePM25 = new QuantityType<>(sensorData.getPm25(),
- SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
+ QuantityType<Density> statePM25 = new QuantityType<>(sensorData.getPm25(), Units.MICROGRAM_PER_CUBICMETRE);
updateState(NovaFineDustBindingConstants.CHANNEL_PM25, statePM25);
this.statePM25 = statePM25;
import org.openhab.core.library.types.PlayPauseType;
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;
private static final long INITIAL_CLOCK_SYNC_DELAY_SEC = 10;
// spec says wait 50ms, min is 100
private static final long SLEEP_BETWEEN_CMD_MS = 100;
- private static final Unit<Time> API_SECOND_UNIT = SmartHomeUnits.SECOND;
+ private static final Unit<Time> API_SECOND_UNIT = Units.SECOND;
private static final String ZONE = "ZONE";
private static final String SOURCE = "SOURCE";
import org.openhab.binding.omnikinverter.internal.OmnikInverterConfiguration;
import org.openhab.binding.omnikinverter.internal.OmnikInverterMessage;
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;
updateStatus(ThingStatus.ONLINE);
- QuantityType<Power> powerQuantity = new QuantityType<>(message.getPower(), SmartHomeUnits.WATT);
+ QuantityType<Power> powerQuantity = new QuantityType<>(message.getPower(), Units.WATT);
updateState(OmnikInverterBindingConstants.CHANNEL_POWER, powerQuantity);
updateState(OmnikInverterBindingConstants.CHANNEL_ENERGY_TODAY,
- new QuantityType<>(message.getEnergyToday(), SmartHomeUnits.KILOWATT_HOUR));
+ new QuantityType<>(message.getEnergyToday(), Units.KILOWATT_HOUR));
updateState(OmnikInverterBindingConstants.CHANNEL_ENERGY_TOTAL,
- new QuantityType<>(message.getTotalEnergy(), SmartHomeUnits.KILOWATT_HOUR));
+ new QuantityType<>(message.getTotalEnergy(), Units.KILOWATT_HOUR));
}
} catch (UnknownHostException | NoRouteToHostException | ConnectException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
import org.eclipse.jdt.annotation.NonNullByDefault;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
Double saturationVaporPressure = 611.2 * Math.exp(17.62 * theta / (243.12 + theta));
// absolute humidity in kg/m^3
Double aH = relativeHumidity.doubleValue() / 100 * saturationVaporPressure / (461.52 * (273.15 + theta));
- State absoluteHumidity = new QuantityType<>(aH, SmartHomeUnits.KILOGRAM_PER_CUBICMETRE).toUnit("g/m³");
+ State absoluteHumidity = new QuantityType<>(aH, Units.KILOGRAM_PER_CUBICMETRE).toUnit("g/m³");
if (absoluteHumidity != null) {
return absoluteHumidity;
} else {
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.Channel;
import org.openhab.core.thing.type.ChannelTypeUID;
import org.openhab.core.types.Command;
// Analog
if (enabledChannels.contains(CHANNEL_VOLTAGE)) {
State analogValue = bridgeHandler.readDecimalType(sensorId, pin7AnalogParameter);
- callback.postUpdate(CHANNEL_VOLTAGE,
- new QuantityType<>((DecimalType) analogValue, SmartHomeUnits.VOLT));
+ callback.postUpdate(CHANNEL_VOLTAGE, new QuantityType<>((DecimalType) analogValue, Units.VOLT));
}
// PWM
if (enabledChannels.contains(CHANNEL_PWM_FREQ1)) {
period1 = ((DecimalType) bridgeHandler.readDecimalType(sensorId, period1Parameter)).intValue();
double frequency = (period1 > 0) ? 1 / (period1 * resolution1 * 1e-6) : 0;
- callback.postUpdate(CHANNEL_PWM_FREQ1, new QuantityType<>(frequency, SmartHomeUnits.HERTZ));
+ callback.postUpdate(CHANNEL_PWM_FREQ1, new QuantityType<>(frequency, Units.HERTZ));
}
if (enabledChannels.contains(CHANNEL_PWM_FREQ2)) {
period2 = ((DecimalType) bridgeHandler.readDecimalType(sensorId, period2Parameter)).intValue();
double frequency = (period2 > 0) ? 1 / (period2 * resolution2 * 1e-6) : 0;
- callback.postUpdate(CHANNEL_PWM_FREQ2, new QuantityType<>(frequency, SmartHomeUnits.HERTZ));
+ callback.postUpdate(CHANNEL_PWM_FREQ2, new QuantityType<>(frequency, Units.HERTZ));
}
if (enabledChannels.contains(CHANNEL_PWM_DUTY1)) {
int dutyValue = ((DecimalType) bridgeHandler.readDecimalType(sensorId, duty1Parameter)).intValue();
double duty = (period1 > 0 && dutyValue <= period1) ? 100 * dutyValue / period1 : 100;
- callback.postUpdate(CHANNEL_PWM_DUTY1, new QuantityType<>(duty, SmartHomeUnits.PERCENT));
+ callback.postUpdate(CHANNEL_PWM_DUTY1, new QuantityType<>(duty, Units.PERCENT));
}
if (enabledChannels.contains(CHANNEL_PWM_DUTY2)) {
int dutyValue = ((DecimalType) bridgeHandler.readDecimalType(sensorId, duty2Parameter)).intValue();
double duty = (period2 > 0 && dutyValue <= period2) ? 100 * dutyValue / period2 : 100;
- callback.postUpdate(CHANNEL_PWM_DUTY2, new QuantityType<>(duty, SmartHomeUnits.PERCENT));
+ callback.postUpdate(CHANNEL_PWM_DUTY2, new QuantityType<>(duty, Units.PERCENT));
}
if (enabledChannels.contains(CHANNEL_PWM_DUTY3)) {
int dutyValue = ((DecimalType) bridgeHandler.readDecimalType(sensorId, duty3Parameter)).intValue();
double duty = (period1 > 0 && dutyValue <= period1) ? 100 * dutyValue / period1 : 100;
- callback.postUpdate(CHANNEL_PWM_DUTY3, new QuantityType<>(duty, SmartHomeUnits.PERCENT));
+ callback.postUpdate(CHANNEL_PWM_DUTY3, new QuantityType<>(duty, Units.PERCENT));
}
if (enabledChannels.contains(CHANNEL_PWM_DUTY4)) {
int dutyValue = ((DecimalType) bridgeHandler.readDecimalType(sensorId, duty4Parameter)).intValue();
double duty = (period2 > 0 && dutyValue <= period2) ? 100 * dutyValue / period2 : 100;
- callback.postUpdate(CHANNEL_PWM_DUTY4, new QuantityType<>(duty, SmartHomeUnits.PERCENT));
+ callback.postUpdate(CHANNEL_PWM_DUTY4, new QuantityType<>(duty, Units.PERCENT));
}
}
}
private DecimalType convertFrequencyToPeriod(Command command, double resolution) throws OwException {
@SuppressWarnings("unchecked")
- QuantityType<Frequency> fHz = ((QuantityType<Frequency>) command).toUnit(SmartHomeUnits.HERTZ);
+ QuantityType<Frequency> fHz = ((QuantityType<Frequency>) command).toUnit(Units.HERTZ);
if (fHz == null) {
throw new OwException("could not convert command to frequency");
}
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (enabledChannels.contains(CHANNEL_HUMIDITY) || enabledChannels.contains(CHANNEL_ABSOLUTE_HUMIDITY)
|| enabledChannels.contains(CHANNEL_DEWPOINT)) {
QuantityType<Dimensionless> humidity = new QuantityType<>(
- (DecimalType) bridgeHandler.readDecimalType(sensorId, humidityParameter),
- SmartHomeUnits.PERCENT);
+ (DecimalType) bridgeHandler.readDecimalType(sensorId, humidityParameter), Units.PERCENT);
if (enabledChannels.contains(CHANNEL_HUMIDITY)) {
callback.postUpdate(CHANNEL_HUMIDITY, humidity);
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.Thing;
import org.openhab.core.types.State;
if (enabledChannels.contains(CHANNEL_HUMIDITY) || enabledChannels.contains(CHANNEL_ABSOLUTE_HUMIDITY)
|| enabledChannels.contains(CHANNEL_DEWPOINT)) {
QuantityType<Dimensionless> humidity = new QuantityType<>(
- (DecimalType) bridgeHandler.readDecimalType(sensorId, humidityParameter),
- SmartHomeUnits.PERCENT);
+ (DecimalType) bridgeHandler.readDecimalType(sensorId, humidityParameter), Units.PERCENT);
logger.trace("read humidity {} from {}", humidity, sensorId);
if (enabledChannels.contains(CHANNEL_HUMIDITY)) {
// workaround bug in DS2438
measured = 0.0;
}
- State voltage = new QuantityType<>(measured, SmartHomeUnits.VOLT);
+ State voltage = new QuantityType<>(measured, Units.VOLT);
logger.trace("read voltage {} from {}", voltage, sensorId);
callback.postUpdate(CHANNEL_VOLTAGE, voltage);
if (current instanceof DecimalType) {
double currentDouble = ((DecimalType) current).doubleValue();
if (currentDouble >= 0.1 || currentDouble <= 3.78) {
- current = new QuantityType<>(currentDouble * 5.163 + 0.483, SmartHomeUnits.AMPERE);
+ current = new QuantityType<>(currentDouble * 5.163 + 0.483, Units.AMPERE);
}
callback.postUpdate(CHANNEL_CURRENT, current);
} else {
} else {
State current = new QuantityType<>(
(DecimalType) bridgeHandler.readDecimalType(sensorId, currentParamater),
- MILLI(SmartHomeUnits.AMPERE));
+ MILLI(Units.AMPERE));
callback.postUpdate(CHANNEL_CURRENT, current);
}
}
if (enabledChannels.contains(CHANNEL_SUPPLYVOLTAGE)) {
Vcc = ((DecimalType) bridgeHandler.readDecimalType(sensorId, supplyVoltageParameter)).doubleValue();
- State supplyVoltage = new QuantityType<>(Vcc, SmartHomeUnits.VOLT);
+ State supplyVoltage = new QuantityType<>(Vcc, Units.VOLT);
callback.postUpdate(CHANNEL_SUPPLYVOLTAGE, supplyVoltage);
}
if (light instanceof DecimalType) {
light = new QuantityType<>(
Math.round(Math.pow(10, ((DecimalType) light).doubleValue() / 47 * 1000)),
- SmartHomeUnits.LUX);
+ Units.LUX);
callback.postUpdate(CHANNEL_LIGHT, light);
}
break;
light = new QuantityType<>(Math.round(Math
.exp(1.059 * Math.log(1000000 * ((DecimalType) light).doubleValue() / (4096 * 390))
+ 4.518)
- * 20000), SmartHomeUnits.LUX);
+ * 20000), Units.LUX);
callback.postUpdate(CHANNEL_LIGHT, light);
}
break;
.doubleValue();
if (measured <= 0 || measured > 10.0) {
// workaround bug in DS2438
- light = new QuantityType<>(0, SmartHomeUnits.LUX);
+ light = new QuantityType<>(0, Units.LUX);
} else {
light = new QuantityType<>(Math.pow(10, (65 / 7.5) - (47 / 7.5) * (Vcc / measured)),
- SmartHomeUnits.LUX);
+ Units.LUX);
}
callback.postUpdate(CHANNEL_LIGHT, light);
}
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (enabledChannels.contains(CHANNEL_HUMIDITY) || enabledChannels.contains(CHANNEL_ABSOLUTE_HUMIDITY)
|| enabledChannels.contains(CHANNEL_DEWPOINT)) {
QuantityType<Dimensionless> humidity = new QuantityType<>(
- (DecimalType) bridgeHandler.readDecimalType(sensorId, humidityParameter),
- SmartHomeUnits.PERCENT);
+ (DecimalType) bridgeHandler.readDecimalType(sensorId, humidityParameter), Units.PERCENT);
if (enabledChannels.contains(CHANNEL_HUMIDITY)) {
callback.postUpdate(CHANNEL_HUMIDITY, humidity);
if (enabledChannels.contains(CHANNEL_LIGHT)) {
QuantityType<Illuminance> light = new QuantityType<>(
- (DecimalType) bridgeHandler.readDecimalType(sensorId, lightParameter), SmartHomeUnits.LUX);
+ (DecimalType) bridgeHandler.readDecimalType(sensorId, lightParameter), Units.LUX);
callback.postUpdate(CHANNEL_LIGHT, light);
}
import static org.openhab.binding.opensprinkler.internal.OpenSprinklerBindingConstants.*;
import static org.openhab.core.library.unit.MetricPrefix.MILLI;
-import static org.openhab.core.library.unit.SmartHomeUnits.PERCENT;
+import static org.openhab.core.library.unit.Units.PERCENT;
import javax.measure.quantity.ElectricCurrent;
import org.openhab.binding.opensprinkler.internal.model.NoCurrentDrawSensorException;
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
break;
case SENSOR_CURRENT_DRAW:
updateState(channel,
- new QuantityType<ElectricCurrent>(getApi().currentDraw(), MILLI(SmartHomeUnits.AMPERE)));
+ new QuantityType<ElectricCurrent>(getApi().currentDraw(), MILLI(Units.AMPERE)));
break;
default:
logger.debug("Not updating unknown channel {}", channel);
import org.openhab.binding.opensprinkler.internal.config.OpenSprinklerStationConfig;
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
return;
}
QuantityType<?> quantity = (QuantityType<?>) command;
- this.nextDurationTime = quantity.toUnit(SmartHomeUnits.SECOND).toBigDecimal();
+ this.nextDurationTime = quantity.toUnit(Units.SECOND).toBigDecimal();
updateState(channelUID, quantity);
}
+ " for the OpenSprinkler device. Exception received: " + exp);
}
- return new QuantityType<>(remainingWaterTime, SmartHomeUnits.SECOND);
+ return new QuantityType<>(remainingWaterTime, Units.SECOND);
}
@Override
case NEXT_DURATION:
BigDecimal duration = nextDurationValue();
if (duration != null) {
- updateState(channel, new QuantityType<>(duration, SmartHomeUnits.SECOND));
+ updateState(channel, new QuantityType<>(duration, Units.SECOND));
}
break;
case STATION_QUEUED:
import org.openhab.core.library.types.HSBType;
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.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
});
} else if (ELEVATION.equals(channelUID.getId()) && command instanceof QuantityType) {
QuantityType<?> qtty = (QuantityType<?>) command;
- if (qtty.getUnit() == SmartHomeUnits.DEGREE_ANGLE) {
+ if (qtty.getUnit() == Units.DEGREE_ANGLE) {
suspendUpdates = qtty.doubleValue() < 0;
} else {
logger.info("The OpenUV Report handles Sun Elevation of Number:Angle type, {} does not fit.", command);
updateState(channelUID, new DecimalType(openUVData.getUvMax()));
break;
case OZONE:
- updateState(channelUID, new QuantityType<>(openUVData.getOzone(), SmartHomeUnits.DOBSON_UNIT));
+ updateState(channelUID, new QuantityType<>(openUVData.getOzone(), Units.DOBSON_UNIT));
break;
case OZONE_TIME:
updateState(channelUID, openUVData.getOzoneTime());
import org.eclipse.jdt.annotation.Nullable;
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.types.State;
import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
FitzpatrickType value = FitzpatrickType.valueOf(index);
Integer duration = safeExposureTime.get(value);
if (duration != null) {
- return new QuantityType<>(duration, SmartHomeUnits.MINUTE);
+ return new QuantityType<>(duration, Units.MINUTE);
}
} catch (IllegalArgumentException e) {
logger.warn("Unexpected Fitzpatrick index value '{}' : {}", index, e.getMessage());
import static org.openhab.binding.openweathermap.internal.OpenWeatherMapBindingConstants.*;
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.ArrayList;
import java.util.List;
import static org.openhab.core.library.unit.MetricPrefix.KILO;
import static org.openhab.core.library.unit.MetricPrefix.MILLI;
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.regex.Matcher;
import java.util.regex.Pattern;
import static org.openhab.binding.openweathermap.internal.OpenWeatherMapBindingConstants.*;
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.ArrayList;
import java.util.List;
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
if (timeArr.length == 3) {
int seconds = (Integer.parseInt(timeArr[0]) * 3600) + (Integer.parseInt(timeArr[1]) * 60)
+ Integer.parseInt(timeArr[2]);
- state = new QuantityType<>(seconds, SmartHomeUnits.SECOND);
+ state = new QuantityType<>(seconds, Units.SECOND);
} else {
state = UnDefType.UNDEF;
}
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
updateProperty(PANEL_BOOTLOADER_VERSION_PROPERTY_NAME, panelInformation.getBootLoaderVersion().toString());
updateState(PANEL_TIME, new DateTimeType(panel.getPanelTime()));
- updateState(PANEL_INPUT_VOLTAGE,
- new QuantityType<ElectricPotential>(panel.getVdcLevel(), SmartHomeUnits.VOLT));
- updateState(PANEL_BOARD_VOLTAGE,
- new QuantityType<ElectricPotential>(panel.getDcLevel(), SmartHomeUnits.VOLT));
+ updateState(PANEL_INPUT_VOLTAGE, new QuantityType<ElectricPotential>(panel.getVdcLevel(), Units.VOLT));
+ updateState(PANEL_BOARD_VOLTAGE, new QuantityType<ElectricPotential>(panel.getDcLevel(), Units.VOLT));
updateState(PANEL_BATTERY_VOLTAGE,
- new QuantityType<ElectricPotential>(panel.getBatteryLevel(), SmartHomeUnits.VOLT));
+ new QuantityType<ElectricPotential>(panel.getBatteryLevel(), Units.VOLT));
}
}
}
import org.openhab.core.io.net.http.HttpUtil;
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.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
ThingTypeUID thingtype = getThing().getThingTypeUID();
if (THING_TYPE_ENERGYMETER.equals(thingtype)) {
- QuantityType<Energy> state = new QuantityType<>(meterState.getReadingValue(),
- SmartHomeUnits.KILOWATT_HOUR);
+ QuantityType<Energy> state = new QuantityType<>(meterState.getReadingValue(), Units.KILOWATT_HOUR);
updateState(CHANNEL_LAST_READING_VALUE, state);
}
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.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
mostRecentEnergy.setInterval(configuration.getMeasurementInterval());
energy = mostRecentEnergy;
logger.trace("Updating {} ({}) energy with: {}", deviceType, macAddress, mostRecentEnergy);
- updateState(CHANNEL_ENERGY, new QuantityType<>(correctSign(mostRecentEnergy.tokWh(localCalibration)),
- SmartHomeUnits.KILOWATT_HOUR));
+ updateState(CHANNEL_ENERGY,
+ new QuantityType<>(correctSign(mostRecentEnergy.tokWh(localCalibration)), Units.KILOWATT_HOUR));
LocalDateTime start = mostRecentEnergy.getStart();
updateState(CHANNEL_ENERGY_STAMP,
start != null ? PlugwiseUtils.newDateTimeType(start) : UnDefType.NULL);
return;
}
- updateState(CHANNEL_POWER, new QuantityType<>(correctSign(watt), SmartHomeUnits.WATT));
+ updateState(CHANNEL_POWER, new QuantityType<>(correctSign(watt), Units.WATT));
}
private void handleRealTimeClockGetResponse(RealTimeClockGetResponseMessage message) {
import org.openhab.core.config.core.Configuration;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
private void handleSenseReportRequestMessage(SenseReportRequestMessage message) {
updateLastSeen();
- updateState(CHANNEL_HUMIDITY, new QuantityType<>(message.getHumidity().getValue(), SmartHomeUnits.PERCENT));
+ updateState(CHANNEL_HUMIDITY, new QuantityType<>(message.getHumidity().getValue(), Units.PERCENT));
updateState(CHANNEL_TEMPERATURE, new QuantityType<>(message.getTemperature().getValue(), SIUnits.CELSIUS));
}
import org.eclipse.jdt.annotation.NonNullByDefault;
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.thing.ThingTypeUID;
/**
// Units of measurement of the data delivered by the API
public static final Unit<Temperature> API_TEMPERATURE_UNIT = ImperialUnits.FAHRENHEIT;
- public static final Unit<Dimensionless> API_HUMIDITY_UNIT = SmartHomeUnits.PERCENT;
- public static final Unit<Time> API_MINUTES_UNIT = SmartHomeUnits.MINUTE;
+ public static final Unit<Dimensionless> API_HUMIDITY_UNIT = Units.PERCENT;
+ public static final Unit<Time> API_MINUTES_UNIT = Units.MINUTE;
}
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.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;
switch (dataType) {
case 0x00: // Degrees
- updateState(channelID, new QuantityType<>(value / 10.0, SmartHomeUnits.DEGREE_ANGLE));
+ updateState(channelID, new QuantityType<>(value / 10.0, Units.DEGREE_ANGLE));
break;
case 0x02: // Number
break;
case 0x03: // Percent
- updateState(channelID, new QuantityType<>(value / 10.0, SmartHomeUnits.PERCENT));
+ updateState(channelID, new QuantityType<>(value / 10.0, Units.PERCENT));
break;
case 0x04: // Ampere
- updateState(channelID, new QuantityType<>(value / 10.0, SmartHomeUnits.AMPERE));
+ updateState(channelID, new QuantityType<>(value / 10.0, Units.AMPERE));
break;
case 0x05: // kWh
- updateState(channelID, new QuantityType<>(value / 10.0, SmartHomeUnits.KILOWATT_HOUR));
+ updateState(channelID, new QuantityType<>(value / 10.0, Units.KILOWATT_HOUR));
break;
case 0x06: // Hours
- updateState(channelID, new QuantityType<>(value, SmartHomeUnits.HOUR));
+ updateState(channelID, new QuantityType<>(value, Units.HOUR));
break;
case 0x07: // Minutes
- updateState(channelID, new QuantityType<>(value, SmartHomeUnits.MINUTE));
+ updateState(channelID, new QuantityType<>(value, Units.MINUTE));
break;
case 0x09: // kw
- updateState(channelID, new QuantityType<>(value, MetricPrefix.KILO(SmartHomeUnits.WATT)));
+ updateState(channelID, new QuantityType<>(value, MetricPrefix.KILO(Units.WATT)));
break;
case 0x01: // Switch
import javax.measure.Unit;
import org.openhab.core.library.unit.SIUnits;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
/**
* The {@link RegoRegisterMapper} is responsible for mapping rego 6xx registers into channels.
}
static Channel hours(short address) {
- return new ChannelImpl(address, 1, SmartHomeUnits.HOUR) {
+ return new ChannelImpl(address, 1, Units.HOUR) {
@Override
public int convertValue(short value) {
return Short.toUnsignedInt(value);
}
static Channel percent(short address) {
- return new ChannelImpl(address, 0.1, SmartHomeUnits.PERCENT);
+ return new ChannelImpl(address, 0.1, Units.PERCENT);
}
static Channel unitless(short address, double scaleFactor) {
package org.openhab.binding.revogi.internal;
import static org.openhab.core.library.unit.MetricPrefix.MILLI;
-import static org.openhab.core.library.unit.SmartHomeUnits.AMPERE;
-import static org.openhab.core.library.unit.SmartHomeUnits.WATT;
+import static org.openhab.core.library.unit.Units.AMPERE;
+import static org.openhab.core.library.unit.Units.WATT;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledFuture;
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;
updateState(CHANNEL_MOWER_NAME, new StringType(info.getName()));
updateState(CHANNEL_STATUS_BATTERY, new DecimalType(info.getStatus().getBattery()));
updateState(CHANNEL_STATUS, new DecimalType(info.getStatus().getStatus().getStatusCode()));
- updateState(CHANNEL_STATUS_DURATION,
- new QuantityType<>(info.getStatus().getDuration(), SmartHomeUnits.SECOND));
- updateState(CHANNEL_STATUS_HOURS, new QuantityType<>(info.getStatus().getHours(), SmartHomeUnits.HOUR));
+ updateState(CHANNEL_STATUS_DURATION, new QuantityType<>(info.getStatus().getDuration(), Units.SECOND));
+ updateState(CHANNEL_STATUS_HOURS, new QuantityType<>(info.getStatus().getHours(), Units.HOUR));
updateState(CHANNEL_STATUS_MODE, new StringType(info.getStatus().getMode().name()));
updateState(CHANNEL_MOWER_START, info.getStatus().isStopped() ? OnOffType.OFF : OnOffType.ON);
if (info.getHealth() != null) {
updateState(CHANNEL_HEALTH_TEMP,
new QuantityType<>(info.getHealth().getTemperature(), SIUnits.CELSIUS));
- updateState(CHANNEL_HEALTH_HUM,
- new QuantityType(info.getHealth().getHumidity(), SmartHomeUnits.PERCENT));
+ updateState(CHANNEL_HEALTH_HUM, new QuantityType(info.getHealth().getHumidity(), Units.PERCENT));
}
if (info.getTimer() != null) {
if (info.getTimer().getNext() != null) {
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
.setScale(0, RoundingMode.HALF_UP);
updateState(SenecHomeBindingConstants.CHANNEL_SENEC_POWER_LIMITATION,
- new QuantityType<Dimensionless>(pvLimitation, SmartHomeUnits.PERCENT));
+ new QuantityType<Dimensionless>(pvLimitation, Units.PERCENT));
Channel channelLimitationState = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_POWER_LIMITATION_STATE);
updateState(channelConsumption.getUID(),
new QuantityType<Power>(
getSenecValue(response.energy.homePowerConsumption).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT));
+ Units.WATT));
}
Channel channelEnergyProduction = getThing()
if (channelEnergyProduction != null) {
updateState(channelEnergyProduction.getUID(), new QuantityType<Power>(
getSenecValue(response.energy.inverterPowerGeneration).setScale(0, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT));
+ Units.WATT));
}
Channel channelBatteryPower = getThing().getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_BATTERY_POWER);
if (channelBatteryPower != null) {
- updateState(channelBatteryPower.getUID(),
- new QuantityType<Power>(
- getSenecValue(response.energy.batteryPower).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT));
+ updateState(channelBatteryPower.getUID(), new QuantityType<Power>(
+ getSenecValue(response.energy.batteryPower).setScale(2, RoundingMode.HALF_UP), Units.WATT));
}
Channel channelBatteryFuelCharge = getThing()
updateState(channelBatteryFuelCharge.getUID(),
new QuantityType<Dimensionless>(
getSenecValue(response.energy.batteryFuelCharge).setScale(0, RoundingMode.HALF_UP),
- SmartHomeUnits.PERCENT));
+ Units.PERCENT));
}
Channel channelGridCurrentPhase1 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_CURRENT_PH1);
updateState(channelGridCurrentPhase1.getUID(), new QuantityType<ElectricCurrent>(
getSenecValue(response.grid.currentGridCurrentPerPhase[0]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.AMPERE));
+ Units.AMPERE));
Channel channelGridCurrentPhase2 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_CURRENT_PH2);
updateState(channelGridCurrentPhase2.getUID(), new QuantityType<ElectricCurrent>(
getSenecValue(response.grid.currentGridCurrentPerPhase[1]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.AMPERE));
+ Units.AMPERE));
Channel channelGridCurrentPhase3 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_CURRENT_PH3);
updateState(channelGridCurrentPhase3.getUID(), new QuantityType<ElectricCurrent>(
getSenecValue(response.grid.currentGridCurrentPerPhase[2]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.AMPERE));
+ Units.AMPERE));
Channel channelGridPowerPhase1 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_POWER_PH1);
updateState(channelGridPowerPhase1.getUID(),
new QuantityType<Power>(
getSenecValue(response.grid.currentGridPowerPerPhase[0]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT));
+ Units.WATT));
Channel channelGridPowerPhase2 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_POWER_PH2);
updateState(channelGridPowerPhase2.getUID(),
new QuantityType<Power>(
getSenecValue(response.grid.currentGridPowerPerPhase[1]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT));
+ Units.WATT));
Channel channelGridPowerPhase3 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_POWER_PH3);
updateState(channelGridPowerPhase3.getUID(),
new QuantityType<Power>(
getSenecValue(response.grid.currentGridPowerPerPhase[2]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT));
+ Units.WATT));
Channel channelGridVoltagePhase1 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_VOLTAGE_PH1);
updateState(channelGridVoltagePhase1.getUID(), new QuantityType<ElectricPotential>(
getSenecValue(response.grid.currentGridVoltagePerPhase[0]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.VOLT));
+ Units.VOLT));
Channel channelGridVoltagePhase2 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_VOLTAGE_PH2);
updateState(channelGridVoltagePhase2.getUID(), new QuantityType<ElectricPotential>(
getSenecValue(response.grid.currentGridVoltagePerPhase[1]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.VOLT));
+ Units.VOLT));
Channel channelGridVoltagePhase3 = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_VOLTAGE_PH3);
updateState(channelGridVoltagePhase3.getUID(), new QuantityType<ElectricPotential>(
getSenecValue(response.grid.currentGridVoltagePerPhase[2]).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.VOLT));
+ Units.VOLT));
Channel channelGridFrequency = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_FREQUENCY);
- updateState(channelGridFrequency.getUID(),
- new QuantityType<Frequency>(
- getSenecValue(response.grid.currentGridFrequency).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.HERTZ));
+ updateState(channelGridFrequency.getUID(), new QuantityType<Frequency>(
+ getSenecValue(response.grid.currentGridFrequency).setScale(2, RoundingMode.HALF_UP), Units.HERTZ));
Channel channelBatteryStateValue = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_BATTERY_STATE_VALUE);
updateState(channelLiveBatCharge.getUID(),
new QuantityType<Energy>(
getSenecValue(response.statistics.liveBatCharge).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT_HOUR));
+ Units.WATT_HOUR));
Channel channelLiveBatDischarge = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_LIVE_BAT_DISCHARGE);
updateState(channelLiveBatDischarge.getUID(),
new QuantityType<Energy>(
getSenecValue(response.statistics.liveBatDischarge).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT_HOUR));
+ Units.WATT_HOUR));
Channel channelLiveGridImport = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_LIVE_GRID_IMPORT);
updateState(channelLiveGridImport.getUID(),
new QuantityType<Energy>(
getSenecValue(response.statistics.liveGridImport).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT_HOUR));
+ Units.WATT_HOUR));
Channel channelLiveGridExport = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_LIVE_GRID_EXPORT);
updateState(channelLiveGridExport.getUID(),
new QuantityType<Energy>(
getSenecValue(response.statistics.liveGridExport).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.WATT_HOUR));
+ Units.WATT_HOUR));
Channel channelBatteryVoltage = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_BATTERY_VOLTAGE);
- updateState(channelBatteryVoltage.getUID(),
- new QuantityType<ElectricPotential>(
- getSenecValue(response.energy.batteryVoltage).setScale(2, RoundingMode.HALF_UP),
- SmartHomeUnits.VOLT));
+ updateState(channelBatteryVoltage.getUID(), new QuantityType<ElectricPotential>(
+ getSenecValue(response.energy.batteryVoltage).setScale(2, RoundingMode.HALF_UP), Units.VOLT));
Channel channelBatteryState = getThing().getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_BATTERY_STATE);
if (channelBatteryState != null) {
Channel channelGridPower = getThing().getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_POWER);
if (channelGridPower != null) {
- updateState(channelGridPower.getUID(), new QuantityType<Power>(gridTotal, SmartHomeUnits.WATT));
+ updateState(channelGridPower.getUID(), new QuantityType<Power>(gridTotal, Units.WATT));
}
Channel channelGridPowerSupply = getThing()
.getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_POWER_SUPPLY);
if (channelGridPowerSupply != null) {
BigDecimal gridSupply = gridTotal.compareTo(BigDecimal.ZERO) < 0 ? gridTotal.abs() : BigDecimal.ZERO;
- updateState(channelGridPowerSupply.getUID(), new QuantityType<Power>(gridSupply, SmartHomeUnits.WATT));
+ updateState(channelGridPowerSupply.getUID(), new QuantityType<Power>(gridSupply, Units.WATT));
}
Channel channelGridPowerDraw = getThing().getChannel(SenecHomeBindingConstants.CHANNEL_SENEC_GRID_POWER_DRAW);
if (channelGridPowerDraw != null) {
BigDecimal gridDraw = gridTotal.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : gridTotal.abs();
- updateState(channelGridPowerDraw.getUID(), new QuantityType<Power>(gridDraw, SmartHomeUnits.WATT));
+ updateState(channelGridPowerDraw.getUID(), new QuantityType<Power>(gridDraw, Units.WATT));
}
}
}
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
BigDecimal bd = new BigDecimal(sensorData.getLastMeasurement().getValue());
switch (sensorData.getUnit()) {
case "%":
- result = new QuantityType<>(bd, SmartHomeUnits.PERCENT);
+ result = new QuantityType<>(bd, Units.PERCENT);
break;
case "°C":
result = new QuantityType<>(bd, SIUnits.CELSIUS);
result = new QuantityType<>(bd, MetricPrefix.HECTO(SIUnits.PASCAL));
break;
case "lx":
- result = new QuantityType<>(bd, SmartHomeUnits.LUX);
+ result = new QuantityType<>(bd, Units.LUX);
break;
case "\u00b5g/m³":
- result = new QuantityType<>(bd, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE);
+ result = new QuantityType<>(bd, Units.MICROGRAM_PER_CUBICMETRE);
break;
case "\u00b5W/cm²":
- result = new QuantityType<>(bd, SmartHomeUnits.MICROWATT_PER_SQUARE_CENTIMETRE);
+ result = new QuantityType<>(bd, Units.MICROWATT_PER_SQUARE_CENTIMETRE);
break;
default:
// The data provider might have configured some unknown unit, accept at least the
// measurement
logger.debug("Could not determine unit for '{}', using default", sensorData.getUnit());
- result = new QuantityType<>(bd, SmartHomeUnits.ONE);
+ result = new QuantityType<>(bd, Units.ONE);
}
logger.debug("State: '{}'", result);
}
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;
private void handleCurrentHumidityCommand(ChannelUID channelUID, Command command, SensiboSky sensiboSky) {
if (command instanceof RefreshType) {
- updateState(channelUID, new QuantityType<>(sensiboSky.getHumidity(), SmartHomeUnits.PERCENT));
+ updateState(channelUID, new QuantityType<>(sensiboSky.getHumidity(), Units.PERCENT));
}
}
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
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.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
switch (sen.type.toLowerCase()) {
case "b": // BatteryLevel +
updateChannel(updates, CHANNEL_GROUP_BATTERY, CHANNEL_SENSOR_BAT_LEVEL,
- toQuantityType(s.value, DIGITS_PERCENT, SmartHomeUnits.PERCENT));
+ toQuantityType(s.value, DIGITS_PERCENT, Units.PERCENT));
break;
case "h" /* Humidity */:
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_HUM,
- toQuantityType(s.value, DIGITS_PERCENT, SmartHomeUnits.PERCENT));
+ toQuantityType(s.value, DIGITS_PERCENT, Units.PERCENT));
break;
case "m" /* Motion */:
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_MOTION,
break;
case "l": // Luminosity +
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_LUX,
- toQuantityType(s.value, DIGITS_LUX, SmartHomeUnits.LUX));
+ toQuantityType(s.value, DIGITS_LUX, Units.LUX));
break;
case "s": // CatchAll
switch (sen.desc.toLowerCase()) {
// work around: Roller reports 101% instead max 100
double pos = Math.max(SHELLY_MIN_ROLLER_POS, Math.min(s.value, SHELLY_MAX_ROLLER_POS));
updateChannel(updates, CHANNEL_GROUP_ROL_CONTROL, CHANNEL_ROL_CONTROL_CONTROL,
- toQuantityType(SHELLY_MAX_ROLLER_POS - pos, SmartHomeUnits.PERCENT));
+ toQuantityType(SHELLY_MAX_ROLLER_POS - pos, Units.PERCENT));
updateChannel(updates, CHANNEL_GROUP_ROL_CONTROL, CHANNEL_ROL_CONTROL_POS,
- toQuantityType(pos, SmartHomeUnits.PERCENT));
+ toQuantityType(pos, Units.PERCENT));
break;
case "flood":
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_FLOOD,
}
if (brightness != -1) {
updateChannel(updates, group, channel + "$Value",
- toQuantityType(power == 1 ? brightness : 0, DIGITS_NONE, SmartHomeUnits.PERCENT));
+ toQuantityType(power == 1 ? brightness : 0, DIGITS_NONE, Units.PERCENT));
}
} else if (profile.hasRelays) {
group = profile.numRelays <= 1 ? CHANNEL_GROUP_RELAY_CONTROL : CHANNEL_GROUP_RELAY_CONTROL + id;
import org.openhab.core.library.types.OnOffType;
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;
String mGroup = profile.numMeters == 1 ? CHANNEL_GROUP_METER
: CHANNEL_GROUP_METER + (profile.isEMeter ? sen.links : rIndex);
updateChannel(updates, mGroup, CHANNEL_METER_CURRENTWATTS,
- toQuantityType(s.value, DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(s.value, DIGITS_WATT, Units.WATT));
updateChannel(updates, mGroup, CHANNEL_LAST_UPDATE, getTimestamp());
break;
case "s" /* CatchAll */:
break;
case "energy counter 0 [w-min]":
updateChannel(updates, rGroup, CHANNEL_METER_LASTMIN1,
- toQuantityType(s.value, DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(s.value, DIGITS_WATT, Units.WATT));
break;
case "energy counter 1 [w-min]":
case "energy counter 2 [w-min]":
case "energy counter total [w-min]":
Double total = profile.isEMeter ? s.value / 1000 : s.value / 60 / 1000;
updateChannel(updates, rGroup, CHANNEL_METER_TOTALKWH,
- toQuantityType(total, DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ toQuantityType(total, DIGITS_KWH, Units.KILOWATT_HOUR));
break;
case "voltage":
updateChannel(updates, rGroup, CHANNEL_EMETER_VOLTAGE,
- toQuantityType(getDouble(s.value), DIGITS_VOLT, SmartHomeUnits.VOLT));
+ toQuantityType(getDouble(s.value), DIGITS_VOLT, Units.VOLT));
break;
case "current":
updateChannel(updates, rGroup, CHANNEL_EMETER_CURRENT,
- toQuantityType(getDouble(s.value), DIGITS_VOLT, SmartHomeUnits.AMPERE));
+ toQuantityType(getDouble(s.value), DIGITS_VOLT, Units.AMPERE));
break;
case "pf":
updateChannel(updates, rGroup, CHANNEL_EMETER_PFACTOR, getDecimal(s.value));
// work around: Roller reports 101% instead max 100
double pos = Math.max(SHELLY_MIN_ROLLER_POS, Math.min(s.value, SHELLY_MAX_ROLLER_POS));
updateChannel(updates, CHANNEL_GROUP_ROL_CONTROL, CHANNEL_ROL_CONTROL_CONTROL,
- toQuantityType(SHELLY_MAX_ROLLER_POS - pos, SmartHomeUnits.PERCENT));
+ toQuantityType(SHELLY_MAX_ROLLER_POS - pos, Units.PERCENT));
updateChannel(updates, CHANNEL_GROUP_ROL_CONTROL, CHANNEL_ROL_CONTROL_POS,
- toQuantityType(pos, SmartHomeUnits.PERCENT));
+ toQuantityType(pos, Units.PERCENT));
break;
case "input event": // Shelly Button 1
handleInputEvent(sen, getString(s.valueStr), -1, updates);
break;
case "tilt": // DW with FW1.6.5+ //+
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_TILT,
- toQuantityType(s.value, DIGITS_NONE, SmartHomeUnits.DEGREE_ANGLE));
+ toQuantityType(s.value, DIGITS_NONE, Units.DEGREE_ANGLE));
break;
case "vibration": // DW with FW1.6.5+
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_VIBRATION,
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
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;
case "1103": // roller_0: S, rollerPos, 0-100, unknown -1
int pos = Math.max(SHELLY_MIN_ROLLER_POS, Math.min((int) value, SHELLY_MAX_ROLLER_POS));
updateChannel(updates, CHANNEL_GROUP_ROL_CONTROL, CHANNEL_ROL_CONTROL_CONTROL,
- toQuantityType(new Double(SHELLY_MAX_ROLLER_POS - pos), SmartHomeUnits.PERCENT));
+ toQuantityType(new Double(SHELLY_MAX_ROLLER_POS - pos), Units.PERCENT));
break;
case "1105": // S, valvle, closed/opened/not_connected/failure/closing/opening/checking or unbknown
updateChannel(updates, CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_VALVE, getStringType(s.valueStr));
case "4102": // roller_0: P, rollerPower, W, 0-2300, unknown -1
case "4202": // roller_1: P, rollerPower, W, 0-2300, unknown -1
updateChannel(updates, mGroup, CHANNEL_METER_CURRENTWATTS,
- toQuantityType(s.value, DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(s.value, DIGITS_WATT, Units.WATT));
updateChannel(updates, mGroup, CHANNEL_LAST_UPDATE, getTimestamp());
break;
case "4306": // emeter_2: E, energy, Wh, U32
double total = profile.isEMeter ? s.value / 1000 : s.value / 60 / 1000;
updateChannel(updates, mGroup, CHANNEL_METER_TOTALKWH,
- toQuantityType(total, DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ toQuantityType(total, DIGITS_KWH, Units.KILOWATT_HOUR));
break;
case "4107": // emeter_0: E, energyReturned, Wh, U32, -1
case "4207": // emeter_1: E, energyReturned, Wh, U32, -1
case "4307": // emeter_2: E, energyReturned, Wh, U32, -1
updateChannel(updates, mGroup, CHANNEL_EMETER_TOTALRET,
- toQuantityType(getDouble(s.value) / 1000, DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ toQuantityType(getDouble(s.value) / 1000, DIGITS_KWH, Units.KILOWATT_HOUR));
break;
case "4108": // emeter_0: V, voltage, 0-265V, U32, -1
case "4208": // emeter_1: V, voltage, 0-265V, U32, -1
case "4308": // emeter_2: V, voltage, 0-265V, U32, -1
updateChannel(updates, mGroup, CHANNEL_EMETER_VOLTAGE,
- toQuantityType(getDouble(s.value), DIGITS_VOLT, SmartHomeUnits.VOLT));
+ toQuantityType(getDouble(s.value), DIGITS_VOLT, Units.VOLT));
break;
case "4109": // emeter_0: A, current, 0/120A, -1
case "4209": // emeter_1: A, current, 0/120A, -1
case "4309": // emeter_2: A, current, 0/120A, -1
updateChannel(updates, rGroup, CHANNEL_EMETER_CURRENT,
- toQuantityType(getDouble(s.value), DIGITS_VOLT, SmartHomeUnits.AMPERE));
+ toQuantityType(getDouble(s.value), DIGITS_VOLT, Units.AMPERE));
break;
case "4110": // emeter_0: S, powerFactor, 0/1, -1
import org.openhab.core.library.types.OpenClosedType;
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{@link ShellyComponents} implements updates for supplemental components
Integer rssi = getInteger(status.wifiSta.rssi);
thingHandler.updateChannel(CHANNEL_GROUP_DEV_STATUS, CHANNEL_DEVST_UPTIME,
- toQuantityType(new Double(getLong(status.uptime)), DIGITS_NONE, SmartHomeUnits.SECOND));
+ toQuantityType(new Double(getLong(status.uptime)), DIGITS_NONE, Units.SECOND));
thingHandler.updateChannel(CHANNEL_GROUP_DEV_STATUS, CHANNEL_DEVST_RSSI, mapSignalStrength(rssi));
if (status.tmp != null) {
thingHandler.updateChannel(CHANNEL_GROUP_DEV_STATUS, CHANNEL_DEVST_ITEMP,
}
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_CURRENTWATTS,
- toQuantityType(getDouble(meter.power), DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(getDouble(meter.power), DIGITS_WATT, Units.WATT));
accumulatedWatts += getDouble(meter.power);
// convert Watt/Min to kw/h
if (meter.total != null) {
double kwh = getDouble(meter.total) / 60 / 1000;
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_TOTALKWH,
- toQuantityType(kwh, DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ toQuantityType(kwh, DIGITS_KWH, Units.KILOWATT_HOUR));
accumulatedTotal += kwh;
}
if (meter.counters != null) {
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_LASTMIN1,
- toQuantityType(getDouble(meter.counters[0]), DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(getDouble(meter.counters[0]), DIGITS_WATT, Units.WATT));
}
thingHandler.updateChannel(groupName, CHANNEL_LAST_UPDATE,
getTimestamp(getString(profile.settings.timezone), getLong(meter.timestamp)));
// convert Watt/Hour tok w/h
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_CURRENTWATTS,
- toQuantityType(getDouble(emeter.power), DIGITS_WATT, SmartHomeUnits.WATT));
- updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_TOTALKWH, toQuantityType(
- getDouble(emeter.total) / 1000, DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ toQuantityType(getDouble(emeter.power), DIGITS_WATT, Units.WATT));
+ updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_TOTALKWH,
+ toQuantityType(getDouble(emeter.total) / 1000, DIGITS_KWH, Units.KILOWATT_HOUR));
updated |= thingHandler.updateChannel(groupName, CHANNEL_EMETER_TOTALRET, toQuantityType(
- getDouble(emeter.totalReturned) / 1000, DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ getDouble(emeter.totalReturned) / 1000, DIGITS_KWH, Units.KILOWATT_HOUR));
updated |= thingHandler.updateChannel(groupName, CHANNEL_EMETER_REACTWATTS,
- toQuantityType(getDouble(emeter.reactive), DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(getDouble(emeter.reactive), DIGITS_WATT, Units.WATT));
updated |= thingHandler.updateChannel(groupName, CHANNEL_EMETER_VOLTAGE,
- toQuantityType(getDouble(emeter.voltage), DIGITS_VOLT, SmartHomeUnits.VOLT));
+ toQuantityType(getDouble(emeter.voltage), DIGITS_VOLT, Units.VOLT));
if (emeter.current != null) {
// Shelly
updated |= thingHandler.updateChannel(groupName, CHANNEL_EMETER_CURRENT,
- toQuantityType(getDouble(emeter.current), DIGITS_VOLT, SmartHomeUnits.AMPERE));
+ toQuantityType(getDouble(emeter.current), DIGITS_VOLT, Units.AMPERE));
updated |= thingHandler.updateChannel(groupName, CHANNEL_EMETER_PFACTOR,
getDecimal(emeter.pf));
}
}
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_LASTMIN1,
- toQuantityType(getDouble(lastMin1), DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(getDouble(lastMin1), DIGITS_WATT, Units.WATT));
// convert totalWatts into kw/h
totalWatts = totalWatts / (60.0 * 1000.0);
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_CURRENTWATTS,
- toQuantityType(getDouble(currentWatts), DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(getDouble(currentWatts), DIGITS_WATT, Units.WATT));
updated |= thingHandler.updateChannel(groupName, CHANNEL_METER_TOTALKWH,
- toQuantityType(getDouble(totalWatts), DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ toQuantityType(getDouble(totalWatts), DIGITS_KWH, Units.KILOWATT_HOUR));
if (updated) {
thingHandler.updateChannel(groupName, CHANNEL_LAST_UPDATE,
if (updated && !profile.isRoller && !profile.isRGBW2) {
thingHandler.updateChannel(CHANNEL_GROUP_DEV_STATUS, CHANNEL_DEVST_ACCUWATTS,
- toQuantityType(accumulatedWatts, DIGITS_WATT, SmartHomeUnits.WATT));
+ toQuantityType(accumulatedWatts, DIGITS_WATT, Units.WATT));
thingHandler.updateChannel(CHANNEL_GROUP_DEV_STATUS, CHANNEL_DEVST_ACCUTOTAL,
- toQuantityType(accumulatedTotal, DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ toQuantityType(accumulatedTotal, DIGITS_KWH, Units.KILOWATT_HOUR));
thingHandler.updateChannel(CHANNEL_GROUP_DEV_STATUS, CHANNEL_DEVST_ACCURETURNED,
- toQuantityType(accumulatedReturned, DIGITS_KWH, SmartHomeUnits.KILOWATT_HOUR));
+ toQuantityType(accumulatedReturned, DIGITS_KWH, Units.KILOWATT_HOUR));
}
}
if (sdata.hum != null) {
thingHandler.logger.trace("{}: Updating humidity", thingHandler.thingName);
updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_HUM,
- toQuantityType(getDouble(sdata.hum.value), DIGITS_PERCENT, SmartHomeUnits.PERCENT));
+ toQuantityType(getDouble(sdata.hum.value), DIGITS_PERCENT, Units.PERCENT));
}
if ((sdata.lux != null) && getBool(sdata.lux.isValid)) {
// “lux”:{“value”:30, “illumination”: “dark”, “is_valid”:true},
thingHandler.logger.trace("{}: Updating lux", thingHandler.thingName);
updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_LUX,
- toQuantityType(getDouble(sdata.lux.value), DIGITS_LUX, SmartHomeUnits.LUX));
+ toQuantityType(getDouble(sdata.lux.value), DIGITS_LUX, Units.LUX));
if (sdata.lux.illumination != null) {
updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_ILLUM,
getStringType(sdata.lux.illumination));
}
}
if (sdata.accel != null) {
- updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_TILT, toQuantityType(
- getDouble(sdata.accel.tilt.doubleValue()), DIGITS_NONE, SmartHomeUnits.DEGREE_ANGLE));
+ updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_TILT,
+ toQuantityType(getDouble(sdata.accel.tilt.doubleValue()), DIGITS_NONE, Units.DEGREE_ANGLE));
updated |= thingHandler.updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_VIBRATION,
getInteger(sdata.accel.vibration) == 1 ? OnOffType.ON : OnOffType.OFF);
}
if (sdata.bat != null) { // no update for Sense
thingHandler.logger.trace("{}: Updating battery", thingHandler.thingName);
updated |= thingHandler.updateChannel(CHANNEL_GROUP_BATTERY, CHANNEL_SENSOR_BAT_LEVEL,
- toQuantityType(getDouble(sdata.bat.value), DIGITS_PERCENT, SmartHomeUnits.PERCENT));
+ toQuantityType(getDouble(sdata.bat.value), DIGITS_PERCENT, Units.PERCENT));
boolean changed = thingHandler.updateChannel(CHANNEL_GROUP_BATTERY, CHANNEL_SENSOR_BAT_LOW,
getDouble(sdata.bat.value) < thingHandler.config.lowBattery ? OnOffType.ON : OnOffType.OFF);
updated |= changed;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
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.types.Command;
updateChannel(CHANNEL_COLOR_WHITE, CHANNEL_BRIGHTNESS + "$Switch", col.power);
updateChannel(CHANNEL_COLOR_WHITE, CHANNEL_BRIGHTNESS + "$Value",
toQuantityType(new Double(col.power == OnOffType.ON ? col.brightness : 0), DIGITS_NONE,
- SmartHomeUnits.PERCENT));
+ Units.PERCENT));
update = false;
break;
}
updated |= updateChannel(whiteGroup, CHANNEL_BRIGHTNESS + "$Switch", col.power);
updated |= updateChannel(whiteGroup, CHANNEL_BRIGHTNESS + "$Value",
toQuantityType(col.power == OnOffType.ON ? col.percentBrightness.doubleValue() : new Double(0),
- DIGITS_NONE, SmartHomeUnits.PERCENT));
+ DIGITS_NONE, Units.PERCENT));
if ((profile.isBulb || profile.isDuo) && (light.temp != null)) {
col.setTemp(getInteger(light.temp));
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.types.UpDownType;
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.types.Command;
api.setRelayTurn(lightId, power == OnOffType.ON ? SHELLY_API_ON : SHELLY_API_OFF);
}
updateChannel(CHANNEL_COLOR_WHITE, CHANNEL_BRIGHTNESS + "$Switch", power);
- updateChannel(CHANNEL_COLOR_WHITE, CHANNEL_BRIGHTNESS + "$Value", toQuantityType(
- new Double(power == OnOffType.ON ? brightness : 0), DIGITS_NONE, SmartHomeUnits.PERCENT));
+ updateChannel(CHANNEL_COLOR_WHITE, CHANNEL_BRIGHTNESS + "$Value",
+ toQuantityType(new Double(power == OnOffType.ON ? brightness : 0), DIGITS_NONE, Units.PERCENT));
}
@Override
}
if ((rstatus.extHumidity != null) && (rstatus.extHumidity.sensor1 != null)) {
updated |= updateChannel(CHANNEL_GROUP_SENSOR, CHANNEL_SENSOR_HUM, toQuantityType(
- getDouble(rstatus.extHumidity.sensor1.hum), DIGITS_PERCENT, SmartHomeUnits.PERCENT));
+ getDouble(rstatus.extHumidity.sensor1.hum), DIGITS_PERCENT, Units.PERCENT));
}
// Update Auto-ON/OFF timer
ShellySettingsRelay rsettings = profile.settings.relays.get(i);
if (rsettings != null) {
updated |= updateChannel(groupName, CHANNEL_TIMER_AUTOON,
- toQuantityType(getDouble(rsettings.autoOn), SmartHomeUnits.SECOND));
+ toQuantityType(getDouble(rsettings.autoOn), Units.SECOND));
updated |= updateChannel(groupName, CHANNEL_TIMER_AUTOOFF,
- toQuantityType(getDouble(rsettings.autoOff), SmartHomeUnits.SECOND));
+ toQuantityType(getDouble(rsettings.autoOff), Units.SECOND));
}
// Update input(s) state
if (state.equals(SHELLY_ALWD_ROLLER_TURN_STOP)) { // only valid in stop state
int pos = Math.max(SHELLY_MIN_ROLLER_POS, Math.min(control.currentPos, SHELLY_MAX_ROLLER_POS));
updated |= updateChannel(groupName, CHANNEL_ROL_CONTROL_CONTROL,
- toQuantityType(new Double(SHELLY_MAX_ROLLER_POS - pos), SmartHomeUnits.PERCENT));
+ toQuantityType(new Double(SHELLY_MAX_ROLLER_POS - pos), Units.PERCENT));
updated |= updateChannel(groupName, CHANNEL_ROL_CONTROL_POS,
- toQuantityType(new Double(pos), SmartHomeUnits.PERCENT));
+ toQuantityType(new Double(pos), Units.PERCENT));
scheduledUpdates = 1; // one more poll and then stop
}
// When the device's brightness is > 0 we send the new value to the channel and a ON command
if (dimmer.ison) {
updated |= updateChannel(groupName, CHANNEL_BRIGHTNESS + "$Switch", OnOffType.ON);
- updated |= updateChannel(groupName, CHANNEL_BRIGHTNESS + "$Value", toQuantityType(
- new Double(getInteger(dimmer.brightness)), DIGITS_NONE, SmartHomeUnits.PERCENT));
+ updated |= updateChannel(groupName, CHANNEL_BRIGHTNESS + "$Value",
+ toQuantityType(new Double(getInteger(dimmer.brightness)), DIGITS_NONE, Units.PERCENT));
} else {
updated |= updateChannel(groupName, CHANNEL_BRIGHTNESS + "$Switch", OnOffType.OFF);
updated |= updateChannel(groupName, CHANNEL_BRIGHTNESS + "$Value",
- toQuantityType(new Double(0), DIGITS_NONE, SmartHomeUnits.PERCENT));
+ toQuantityType(new Double(0), DIGITS_NONE, Units.PERCENT));
}
ShellySettingsDimmer dsettings = profile.settings.dimmers.get(l);
if (dsettings != null) {
updated |= updateChannel(groupName, CHANNEL_TIMER_AUTOON,
- toQuantityType(getDouble(dsettings.autoOn), SmartHomeUnits.SECOND));
+ toQuantityType(getDouble(dsettings.autoOn), Units.SECOND));
updated |= updateChannel(groupName, CHANNEL_TIMER_AUTOOFF,
- toQuantityType(getDouble(dsettings.autoOff), SmartHomeUnits.SECOND));
+ toQuantityType(getDouble(dsettings.autoOff), Units.SECOND));
}
updated |= updateInputs(groupName, orgStatus, l);
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.types.State;
import org.openhab.core.types.UnDefType;
return ImperialUnits.FAHRENHEIT;
}
case DEGREES_KELVIN: {
- return SmartHomeUnits.KELVIN;
+ return Units.KELVIN;
}
case PERCENT_RELATIVE_HUMIDITY: {
- return SmartHomeUnits.PERCENT;
+ return Units.PERCENT;
}
}
}
- return SmartHomeUnits.ONE;
+ return Units.ONE;
}
/*
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.types.State;
/**
state = dataPoints.getPointByClass("'SpTRShft").getState();
assertTrue(state instanceof QuantityType<?>);
- QuantityType<?> kelvin = ((QuantityType<?>) state).toUnit(SmartHomeUnits.KELVIN);
+ QuantityType<?> kelvin = ((QuantityType<?>) state).toUnit(Units.KELVIN);
assertNotNull(kelvin);
assertEquals(0, kelvin.floatValue(), 0.01);
state = dataPoints.getPointByClass("'RHuRel").getState();
assertTrue(state instanceof QuantityType<?>);
- QuantityType<?> relativeHumidity = ((QuantityType<?>) state).toUnit(SmartHomeUnits.PERCENT);
+ QuantityType<?> relativeHumidity = ((QuantityType<?>) state).toUnit(Units.PERCENT);
assertNotNull(relativeHumidity);
assertEquals(46.86865, relativeHumidity.floatValue(), 0.1);
state = dataPoints.getPointByClass("'TRBltnMsvAdj").getState();
assertTrue(state instanceof QuantityType<?>);
- kelvin = ((QuantityType<?>) state).toUnit(SmartHomeUnits.KELVIN);
+ kelvin = ((QuantityType<?>) state).toUnit(Units.KELVIN);
assertNotNull(kelvin);
assertEquals(35.0, celsius.floatValue(), 0.01);
tempPoint = dataPoints.getPointByClass("'SpTRShft");
assertTrue(tempPoint instanceof BasePoint);
- assertEquals(SmartHomeUnits.KELVIN, tempPoint.getUnit());
+ assertEquals(Units.KELVIN, tempPoint.getUnit());
} catch (RdsCloudException e) {
fail(e.getMessage());
}
import org.openhab.binding.smartmeter.internal.ObisCode;
import org.openhab.binding.smartmeter.internal.conformity.negate.NegateHandler;
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.Thing;
import org.openhab.core.types.State;
String channelObis = channel.getProperties().get(SmartMeterBindingConstants.CHANNEL_PROPERTY_OBIS);
if (channelObis != null) {
MeterValue<?> value = device.getMeterValue(channelObis);
- if (value != null && SmartHomeUnits.WATT.isCompatible(value.getUnit())) {
+ if (value != null && Units.WATT.isCompatible(value.getUnit())) {
for (String obis : device.getObisCodes()) {
try {
MeterValue<?> otherValue = device.getMeterValue(obis);
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.unit.SIUnits;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.openmuc.jsml.EUnit;
/**
Unit<?> javaUnit = null;
switch (unit) {
case AMPERE:
- javaUnit = SmartHomeUnits.AMPERE;
+ javaUnit = Units.AMPERE;
break;
case AMPERE_HOUR:
- javaUnit = SmartHomeUnits.AMPERE.divide(SmartHomeUnits.HOUR);
+ javaUnit = Units.AMPERE.divide(Units.HOUR);
break;
case AMPERE_PER_METRE:
- javaUnit = SmartHomeUnits.AMPERE.multiply(SIUnits.METRE);
+ javaUnit = Units.AMPERE.multiply(SIUnits.METRE);
break;
case AMPERE_SQUARED_HOURS:
- javaUnit = SmartHomeUnits.AMPERE.pow(2).multiply(SmartHomeUnits.HOUR);
+ javaUnit = Units.AMPERE.pow(2).multiply(Units.HOUR);
break;
case BAR:
javaUnit = SIUnits.PASCAL.multiply(100000);
break;
case COULOMB:
- javaUnit = SmartHomeUnits.COULOMB;
+ javaUnit = Units.COULOMB;
break;
case CUBIC_METRE:
break;
case CUBIC_METRE_PER_DAY:
case CUBIC_METRE_PER_DAY_CORRECTED:
- javaUnit = SIUnits.CUBIC_METRE.divide(SmartHomeUnits.DAY);
+ javaUnit = SIUnits.CUBIC_METRE.divide(Units.DAY);
break;
case CUBIC_METRE_PER_HOUR:
case CUBIC_METRE_PER_HOUR_CORRECTED:
- javaUnit = SIUnits.CUBIC_METRE.divide(SmartHomeUnits.HOUR);
+ javaUnit = SIUnits.CUBIC_METRE.divide(Units.HOUR);
break;
case DAY:
- javaUnit = SmartHomeUnits.DAY;
+ javaUnit = Units.DAY;
break;
case DEGREE:
- javaUnit = SmartHomeUnits.DEGREE_ANGLE;
+ javaUnit = Units.DEGREE_ANGLE;
break;
case DEGREE_CELSIUS:
javaUnit = SIUnits.CELSIUS;
break;
case FARAD:
- javaUnit = SmartHomeUnits.FARAD;
+ javaUnit = Units.FARAD;
break;
case HENRY:
- javaUnit = SmartHomeUnits.HENRY;
+ javaUnit = Units.HENRY;
break;
case HERTZ:
- javaUnit = SmartHomeUnits.HERTZ;
+ javaUnit = Units.HERTZ;
break;
case HOUR:
- javaUnit = SmartHomeUnits.HOUR;
+ javaUnit = Units.HOUR;
break;
case JOULE:
- javaUnit = SmartHomeUnits.JOULE;
+ javaUnit = Units.JOULE;
break;
case JOULE_PER_HOUR:
- javaUnit = SmartHomeUnits.JOULE.divide(SmartHomeUnits.HOUR);
+ javaUnit = Units.JOULE.divide(Units.HOUR);
break;
case KELVIN:
- javaUnit = SmartHomeUnits.KELVIN;
+ javaUnit = Units.KELVIN;
break;
case KILOGRAM:
javaUnit = SIUnits.KILOGRAM;
case KILOGRAM_PER_SECOND:
- javaUnit = SIUnits.KILOGRAM.divide(SmartHomeUnits.SECOND);
+ javaUnit = SIUnits.KILOGRAM.divide(Units.SECOND);
break;
case LITRE:
- javaUnit = SmartHomeUnits.LITRE;
+ javaUnit = Units.LITRE;
break;
case MASS_DENSITY:
break;
javaUnit = SIUnits.METRE;
break;
case METRE_PER_SECOND:
- javaUnit = SmartHomeUnits.METRE_PER_SECOND;
+ javaUnit = Units.METRE_PER_SECOND;
break;
case MOLE_PERCENT:
- javaUnit = SmartHomeUnits.MOLE;
+ javaUnit = Units.MOLE;
break;
case MONTH:
- javaUnit = SmartHomeUnits.YEAR.divide(12);
+ javaUnit = Units.YEAR.divide(12);
break;
case NEWTON:
- javaUnit = SmartHomeUnits.NEWTON;
+ javaUnit = Units.NEWTON;
case NEWTONMETER:
- javaUnit = SmartHomeUnits.NEWTON.multiply(SIUnits.METRE);
+ javaUnit = Units.NEWTON.multiply(SIUnits.METRE);
break;
case OHM:
- javaUnit = SmartHomeUnits.OHM;
+ javaUnit = Units.OHM;
break;
case OHM_METRE:
- javaUnit = SmartHomeUnits.OHM.multiply(SIUnits.METRE);
+ javaUnit = Units.OHM.multiply(SIUnits.METRE);
break;
case PASCAL:
javaUnit = SIUnits.PASCAL;
break;
case PASCAL_SECOND:
- javaUnit = SIUnits.PASCAL.multiply(SmartHomeUnits.SECOND);
+ javaUnit = SIUnits.PASCAL.multiply(Units.SECOND);
break;
case PERCENTAGE:
- javaUnit = SmartHomeUnits.PERCENT;
+ javaUnit = Units.PERCENT;
break;
case SECOND:
- javaUnit = SmartHomeUnits.SECOND;
+ javaUnit = Units.SECOND;
break;
case TESLA:
- javaUnit = SmartHomeUnits.TESLA;
+ javaUnit = Units.TESLA;
break;
case VAR:
- javaUnit = SmartHomeUnits.WATT.alternate("Var");
+ javaUnit = Units.WATT.alternate("Var");
break;
case VAR_HOUR:
- javaUnit = SmartHomeUnits.WATT.alternate("Var").multiply(SmartHomeUnits.HOUR);
+ javaUnit = Units.WATT.alternate("Var").multiply(Units.HOUR);
break;
case VOLT:
- javaUnit = SmartHomeUnits.VOLT;
+ javaUnit = Units.VOLT;
break;
case VOLT_AMPERE:
- javaUnit = SmartHomeUnits.VOLT.multiply(SmartHomeUnits.AMPERE);
+ javaUnit = Units.VOLT.multiply(Units.AMPERE);
break;
case VOLT_AMPERE_HOUR:
- javaUnit = SmartHomeUnits.VOLT.multiply(SmartHomeUnits.AMPERE).multiply(SmartHomeUnits.HOUR);
+ javaUnit = Units.VOLT.multiply(Units.AMPERE).multiply(Units.HOUR);
break;
case VOLT_PER_METRE:
- javaUnit = SmartHomeUnits.WATT.divide(SIUnits.METRE);
+ javaUnit = Units.WATT.divide(SIUnits.METRE);
break;
case VOLT_SQUARED_HOURS:
- javaUnit = SmartHomeUnits.VOLT.pow(2).multiply(SmartHomeUnits.HOUR);
+ javaUnit = Units.VOLT.pow(2).multiply(Units.HOUR);
break;
case WATT:
- javaUnit = SmartHomeUnits.WATT;
+ javaUnit = Units.WATT;
break;
case WATT_HOUR:
- javaUnit = SmartHomeUnits.WATT.multiply(SmartHomeUnits.HOUR);
+ javaUnit = Units.WATT.multiply(Units.HOUR);
break;
case WEBER:
- javaUnit = SmartHomeUnits.WEBER;
+ javaUnit = Units.WEBER;
break;
case WEEK:
- javaUnit = SmartHomeUnits.WEEK;
+ javaUnit = Units.WEEK;
break;
case YEAR:
- javaUnit = SmartHomeUnits.YEAR;
+ javaUnit = Units.YEAR;
break;
// not clearly defined yet:
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.Channel;
import org.openhab.core.thing.ChannelGroupUID;
import org.openhab.core.thing.ChannelUID;
newState = new QuantityType<>(value, MetricPrefix.KILO(SIUnits.METRE));
break;
case WIND_DIRECTION:
- newState = new QuantityType<>(value, SmartHomeUnits.DEGREE_ANGLE);
+ newState = new QuantityType<>(value, Units.DEGREE_ANGLE);
break;
case WIND_SPEED:
case GUST:
- newState = new QuantityType<>(value, SmartHomeUnits.METRE_PER_SECOND);
+ newState = new QuantityType<>(value, Units.METRE_PER_SECOND);
break;
case RELATIVE_HUMIDITY:
case THUNDER_PROBABILITY:
- newState = new QuantityType<>(value, SmartHomeUnits.PERCENT);
+ newState = new QuantityType<>(value, Units.PERCENT);
break;
case PERCENT_FROZEN:
// Smhi returns -9 for spp if there's no precipitation, convert to UNDEF
if (value.intValue() == -9) {
newState = UnDefType.UNDEF;
} else {
- newState = new QuantityType<>(value, SmartHomeUnits.PERCENT);
+ newState = new QuantityType<>(value, Units.PERCENT);
}
break;
case HIGH_CLOUD_COVER:
case MEDIUM_CLOUD_COVER:
case LOW_CLOUD_COVER:
case TOTAL_CLOUD_COVER:
- newState = new QuantityType<>(value.multiply(OCTAS_TO_PERCENT), SmartHomeUnits.PERCENT);
+ newState = new QuantityType<>(value.multiply(OCTAS_TO_PERCENT), Units.PERCENT);
break;
case PRECIPITATION_MAX:
case PRECIPITATION_MEAN:
case PRECIPITATION_MEDIAN:
case PRECIPITATION_MIN:
- newState = new QuantityType<>(value, SmartHomeUnits.MILLIMETRE_PER_HOUR);
+ newState = new QuantityType<>(value, Units.MILLIMETRE_PER_HOUR);
break;
default:
newState = new DecimalType(value);
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.types.State;
import org.openhab.core.types.UnDefType;
private final @Nullable Unit<Energy> determineEnergyUnit(@Nullable String unit) {
if (unit != null) {
if (unit.equals(UNIT_WH)) {
- return SmartHomeUnits.WATT_HOUR;
+ return Units.WATT_HOUR;
} else if (unit.toLowerCase().equals(UNIT_KWH.toLowerCase())) {
- return MetricPrefix.KILO(SmartHomeUnits.WATT_HOUR);
+ return MetricPrefix.KILO(Units.WATT_HOUR);
} else if (unit.equals(UNIT_MWH)) {
- return MetricPrefix.MEGA(SmartHomeUnits.WATT_HOUR);
+ return MetricPrefix.MEGA(Units.WATT_HOUR);
}
}
logger.debug("Could not determine energy unit: '{}'", unit);
private final @Nullable Unit<Power> determinePowerUnit(@Nullable String unit) {
if (unit != null) {
if (unit.equals(UNIT_W)) {
- return SmartHomeUnits.WATT;
+ return Units.WATT;
} else if (unit.toLowerCase().equals(UNIT_KW.toLowerCase())) {
- return MetricPrefix.KILO(SmartHomeUnits.WATT);
+ return MetricPrefix.KILO(Units.WATT);
} else if (unit.equals(UNIT_MW)) {
- return MetricPrefix.MEGA(SmartHomeUnits.WATT);
+ return MetricPrefix.MEGA(Units.WATT);
}
}
logger.debug("Could not determine power unit: '{}'", unit);
State result = UnDefType.UNDEF;
if (value != null) {
- result = new QuantityType<>(value * factor, SmartHomeUnits.PERCENT);
+ result = new QuantityType<>(value * factor, Units.PERCENT);
} else {
logger.debug("Channel {}: no value provided.", channel.getUID().getAsString());
}
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;
/**
* The {@link Synop} is the ancestor common class for analyzing
public Unit<Speed> getWindUnit() {
return (getWindIndicator() == WS_WILDTYPE_IN_MPS || getWindIndicator() == WS_ANEMOMETER_IN_MPS)
- ? SmartHomeUnits.METRE_PER_SECOND
- : SmartHomeUnits.KNOT;
+ ? Units.METRE_PER_SECOND
+ : Units.KNOT;
}
}
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;
import org.openhab.core.thing.ThingTypeUID;
/**
// Default units
public static final Unit<Temperature> TEMPERATURE_UNIT = SIUnits.CELSIUS;
public static final Unit<Pressure> PRESSURE_UNIT = HECTO(SIUnits.PASCAL);
- public static final Unit<Angle> WIND_DIRECTION_UNIT = SmartHomeUnits.DEGREE_ANGLE;
+ public static final Unit<Angle> WIND_DIRECTION_UNIT = Units.DEGREE_ANGLE;
// Synop message origin station codes
public static final String LAND_STATION_CODE = "AAXX";
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.binding.builder.ChannelBuilder;
} else if ("%".equals(valParts[1])) {
// channelType = "Number:Percent"; Number:Percent is currently not handled...
channelType = "Number:Dimensionless";
- state = new QuantityType<>(bd, SmartHomeUnits.PERCENT);
+ state = new QuantityType<>(bd, Units.PERCENT);
} else if ("Imp".equals(valParts[1])) {
// impulses - no idea how to map this to something useful here?
channelType = "Number";
state = new DecimalType(bd);
} else if ("V".equals(valParts[1])) {
channelType = "Number:Voltage";
- state = new QuantityType<>(bd, SmartHomeUnits.VOLT);
+ state = new QuantityType<>(bd, Units.VOLT);
} else if ("A".equals(valParts[1])) {
channelType = "Number:Current";
- state = new QuantityType<>(bd, SmartHomeUnits.AMPERE);
+ state = new QuantityType<>(bd, Units.AMPERE);
} else if ("Hz".equals(valParts[1])) {
channelType = "Number:Frequency";
- state = new QuantityType<>(bd, SmartHomeUnits.HERTZ);
+ state = new QuantityType<>(bd, Units.HERTZ);
} else if ("kW".equals(valParts[1])) {
channelType = "Number:Power";
bd = bd.multiply(new BigDecimal(1000));
- state = new QuantityType<>(bd, SmartHomeUnits.WATT);
+ state = new QuantityType<>(bd, Units.WATT);
} else if ("kWh".equals(valParts[1])) {
channelType = "Number:Power";
bd = bd.multiply(new BigDecimal(1000));
- state = new QuantityType<>(bd, SmartHomeUnits.KILOWATT_HOUR);
+ state = new QuantityType<>(bd, Units.KILOWATT_HOUR);
} else if ("l/h".equals(valParts[1])) {
channelType = "Number:Volume";
bd = bd.divide(new BigDecimal(60));
- state = new QuantityType<>(bd, SmartHomeUnits.LITRE_PER_MINUTE);
+ state = new QuantityType<>(bd, Units.LITRE_PER_MINUTE);
} else {
channelType = "Number";
state = new DecimalType(bd);
import org.openhab.binding.teleinfo.internal.dto.common.FrameTempoOption;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
}
protected void updateStatesForBaseFrameOption(FrameBaseOption frameBaseOption) {
- updateState(CHANNEL_BASE_FRAME_BASE, QuantityType.valueOf(frameBaseOption.getBase(), SmartHomeUnits.WATT_HOUR));
+ updateState(CHANNEL_BASE_FRAME_BASE, QuantityType.valueOf(frameBaseOption.getBase(), Units.WATT_HOUR));
}
protected void updateStatesForHcFrameOption(FrameHcOption frameHcOption) {
- updateState(CHANNEL_HC_FRAME_HCHC, QuantityType.valueOf(frameHcOption.getHchc(), SmartHomeUnits.WATT_HOUR));
- updateState(CHANNEL_HC_FRAME_HCHP, QuantityType.valueOf(frameHcOption.getHchp(), SmartHomeUnits.WATT_HOUR));
+ updateState(CHANNEL_HC_FRAME_HCHC, QuantityType.valueOf(frameHcOption.getHchc(), Units.WATT_HOUR));
+ updateState(CHANNEL_HC_FRAME_HCHP, QuantityType.valueOf(frameHcOption.getHchp(), Units.WATT_HOUR));
updateState(CHANNEL_HC_FRAME_HHPHC, new StringType(frameHcOption.getHhphc().name()));
}
protected void updateStatesForTempoFrameOption(FrameTempoOption frameTempoOption) {
- updateState(CHANNEL_TEMPO_FRAME_BBRHPJR,
- QuantityType.valueOf(frameTempoOption.getBbrhpjr(), SmartHomeUnits.WATT_HOUR));
- updateState(CHANNEL_TEMPO_FRAME_BBRHCJR,
- QuantityType.valueOf(frameTempoOption.getBbrhcjr(), SmartHomeUnits.WATT_HOUR));
- updateState(CHANNEL_TEMPO_FRAME_BBRHPJW,
- QuantityType.valueOf(frameTempoOption.getBbrhpjw(), SmartHomeUnits.WATT_HOUR));
- updateState(CHANNEL_TEMPO_FRAME_BBRHCJW,
- QuantityType.valueOf(frameTempoOption.getBbrhcjw(), SmartHomeUnits.WATT_HOUR));
- updateState(CHANNEL_TEMPO_FRAME_BBRHPJB,
- QuantityType.valueOf(frameTempoOption.getBbrhpjb(), SmartHomeUnits.WATT_HOUR));
- updateState(CHANNEL_TEMPO_FRAME_BBRHCJB,
- QuantityType.valueOf(frameTempoOption.getBbrhcjb(), SmartHomeUnits.WATT_HOUR));
+ updateState(CHANNEL_TEMPO_FRAME_BBRHPJR, QuantityType.valueOf(frameTempoOption.getBbrhpjr(), Units.WATT_HOUR));
+ updateState(CHANNEL_TEMPO_FRAME_BBRHCJR, QuantityType.valueOf(frameTempoOption.getBbrhcjr(), Units.WATT_HOUR));
+ updateState(CHANNEL_TEMPO_FRAME_BBRHPJW, QuantityType.valueOf(frameTempoOption.getBbrhpjw(), Units.WATT_HOUR));
+ updateState(CHANNEL_TEMPO_FRAME_BBRHCJW, QuantityType.valueOf(frameTempoOption.getBbrhcjw(), Units.WATT_HOUR));
+ updateState(CHANNEL_TEMPO_FRAME_BBRHPJB, QuantityType.valueOf(frameTempoOption.getBbrhpjb(), Units.WATT_HOUR));
+ updateState(CHANNEL_TEMPO_FRAME_BBRHCJB, QuantityType.valueOf(frameTempoOption.getBbrhcjb(), Units.WATT_HOUR));
updateState(CHANNEL_TEMPO_FRAME_HHPHC, new StringType(frameTempoOption.getHhphc().name()));
updateState(CHANNEL_TEMPO_FRAME_PROGRAMME_CIRCUIT_1,
new StringType(frameTempoOption.getProgrammeCircuit1().name()));
}
protected void updateStatesForEjpFrameOption(FrameEjpOption frameEjpOption) {
- updateState(CHANNEL_EJP_FRAME_EJPHN, QuantityType.valueOf(frameEjpOption.getEjphn(), SmartHomeUnits.WATT_HOUR));
- updateState(CHANNEL_EJP_FRAME_EJPHPM,
- QuantityType.valueOf(frameEjpOption.getEjphpm(), SmartHomeUnits.WATT_HOUR));
+ updateState(CHANNEL_EJP_FRAME_EJPHN, QuantityType.valueOf(frameEjpOption.getEjphn(), Units.WATT_HOUR));
+ updateState(CHANNEL_EJP_FRAME_EJPHPM, QuantityType.valueOf(frameEjpOption.getEjphpm(), Units.WATT_HOUR));
if (frameEjpOption.getPejp() == null) {
updateState(CHANNEL_EJP_FRAME_PEJP, UnDefType.NULL);
} else {
- updateState(CHANNEL_EJP_FRAME_PEJP, QuantityType.valueOf(frameEjpOption.getPejp(), SmartHomeUnits.MINUTE));
+ updateState(CHANNEL_EJP_FRAME_PEJP, QuantityType.valueOf(frameEjpOption.getPejp(), Units.MINUTE));
}
}
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.UnDefType;
protected void updateStatesForCommonCbemmChannels(FrameCbemm frame) {
// update common channels
- updateState(CHANNEL_CBEMM_ISOUSC, QuantityType.valueOf(frame.getIsousc(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBEMM_ISOUSC, QuantityType.valueOf(frame.getIsousc(), Units.AMPERE));
updateState(CHANNEL_CBEMM_PTEC, new StringType(frame.getPtec().name()));
if (frame.getImax() == null) {
updateState(CHANNEL_CBEMM_IMAX, UnDefType.NULL);
} else {
- updateState(CHANNEL_CBEMM_IMAX, QuantityType.valueOf(frame.getImax(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBEMM_IMAX, QuantityType.valueOf(frame.getImax(), Units.AMPERE));
}
if (frame.getAdps() == null) {
updateState(CHANNEL_CBEMM_ADPS, UnDefType.NULL);
} else {
- updateState(CHANNEL_CBEMM_ADPS, QuantityType.valueOf(frame.getAdps(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBEMM_ADPS, QuantityType.valueOf(frame.getAdps(), Units.AMPERE));
}
- updateState(CHANNEL_CBEMM_IINST, QuantityType.valueOf(frame.getIinst(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBEMM_IINST, QuantityType.valueOf(frame.getIinst(), Units.AMPERE));
updateState(CHANNEL_LAST_UPDATE, new DateTimeType());
}
import org.openhab.binding.teleinfo.internal.dto.cbemm.evoicc.FrameCbemmEvolutionIcc;
import org.openhab.binding.teleinfo.internal.handler.cbemm.TeleinfoAbstractCbemmElectricityMeterHandler;
import org.openhab.core.library.types.QuantityType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
/**
protected void updateStatesForCommonCbemmEvolutionIccChannels(FrameCbemmEvolutionIcc frame) {
updateStatesForCommonCbemmChannels(frame);
- updateState(CHANNEL_CBEMM_EVOLUTION_ICC_PAPP, QuantityType.valueOf(frame.getPapp(), SmartHomeUnits.WATT));
+ updateState(CHANNEL_CBEMM_EVOLUTION_ICC_PAPP, QuantityType.valueOf(frame.getPapp(), Units.WATT));
}
}
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.types.StringType;
-import org.openhab.core.library.unit.SmartHomeUnits;
+import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.UnDefType;
}
protected void updateStatesForCommonCbetmChannels(FrameCbetm frameCbetm) {
- updateState(CHANNEL_CBETM_IINST1, QuantityType.valueOf(frameCbetm.getIinst1(), SmartHomeUnits.AMPERE));
- updateState(CHANNEL_CBETM_IINST2, QuantityType.valueOf(frameCbetm.getIinst2(), SmartHomeUnits.AMPERE));
- updateState(CHANNEL_CBETM_IINST3, QuantityType.valueOf(frameCbetm.getIinst3(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBETM_IINST1, QuantityType.valueOf(frameCbetm.getIinst1(), Units.AMPERE));
+ updateState(CHANNEL_CBETM_IINST2, QuantityType.valueOf(frameCbetm.getIinst2(), Units.AMPERE));
+ updateState(CHANNEL_CBETM_IINST3, QuantityType.valueOf(frameCbetm.getIinst3(), Units.AMPERE));
if (frameCbetm instanceof FrameCbetmLong) {
FrameCbetmLong frameCbetmLong = (FrameCbetmLong) frameCbetm;
updateState(CHANNEL_CBETM_FRAME_TYPE, new StringType("LONG"));
- updateState(CHANNEL_CBETM_LONG_ISOUSC,
- QuantityType.valueOf(frameCbetmLong.getIsousc(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBETM_LONG_ISOUSC, QuantityType.valueOf(frameCbetmLong.getIsousc(), Units.AMPERE));
updateState(CHANNEL_CBETM_LONG_PTEC, new StringType(frameCbetmLong.getPtec().name()));
if (frameCbetmLong.getImax1() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX1, UnDefType.NULL);
} else {
- updateState(CHANNEL_CBETM_LONG_IMAX1,
- QuantityType.valueOf(frameCbetmLong.getImax1(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBETM_LONG_IMAX1, QuantityType.valueOf(frameCbetmLong.getImax1(), Units.AMPERE));
}
if (frameCbetmLong.getImax2() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX2, UnDefType.NULL);
} else {
- updateState(CHANNEL_CBETM_LONG_IMAX2,
- QuantityType.valueOf(frameCbetmLong.getImax2(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBETM_LONG_IMAX2, QuantityType.valueOf(frameCbetmLong.getImax2(), Units.AMPERE));
}
if (frameCbetmLong.getImax3() == null) {
updateState(CHANNEL_CBETM_LONG_IMAX3, UnDefType.NULL);
} else {
- updateState(CHANNEL_CBETM_LONG_IMAX3,
- QuantityType.valueOf(frameCbetmLong.getImax3(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBETM_LONG_IMAX3, QuantityType.valueOf(frameCbetmLong.getImax3(), Units.AMPERE));
}
- updateState(CHANNEL_CBETM_LONG_PMAX, QuantityType.valueOf(frameCbetmLong.getPmax(), SmartHomeUnits.WATT));
- updateState(CHANNEL_CBETM_LONG_PAPP, QuantityType.valueOf(frameCbetmLong.getPapp(), SmartHomeUnits.WATT));
+ updateState(CHANNEL_CBETM_LONG_PMAX, QuantityType.valueOf(frameCbetmLong.getPmax(), Units.WATT));
+ updateState(CHANNEL_CBETM_LONG_PAPP, QuantityType.valueOf(frameCbetmLong.getPapp(), Units.WATT));
updateState(CHANNEL_CBETM_LONG_PPOT, new StringType(frameCbetmLong.getPpot()));
updateState(CHANNEL_CBETM_SHORT_ADIR1, UnDefType.NULL);
if (frameCbetmShort.getAdir1() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR1, UnDefType.NULL);
} else {
- updateState(CHANNEL_CBETM_SHORT_ADIR1,
- QuantityType.valueOf(frameCbetmShort.getAdir1(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBETM_SHORT_ADIR1, QuantityType.valueOf(frameCbetmShort.getAdir1(), Units.AMPERE));
}
if (frameCbetmShort.getAdir2() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR2, UnDefType.NULL);
} else {
- updateState(CHANNEL_CBETM_SHORT_ADIR2,
- QuantityType.valueOf(frameCbetmShort.getAdir2(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBETM_SHORT_ADIR2, QuantityType.valueOf(frameCbetmShort.getAdir2(), Units.AMPERE));
}
if (frameCbetmShort.getAdir3() == null) {
updateState(CHANNEL_CBETM_SHORT_ADIR3, UnDefType.NULL);
} else {
- updateState(CHANNEL_CBETM_SHORT_ADIR3,
- QuantityType.valueOf(frameCbetmShort.getAdir3(), SmartHomeUnits.AMPERE));
+ updateState(CHANNEL_CBETM_SHORT_ADIR3, QuantityType.valueOf(frameCbetmShort.getAdir3(), Units.AMPERE));
}
updateState(CHANNEL_CBETM_LONG_ISOUSC, UnDefType.NULL);
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;
import org.openhab.core.thing.ThingTypeUID;
/**
public static final String BINDING_ID = "tellstick";
- public static final Unit<Dimensionless> HUMIDITY_UNIT = SmartHomeUnits.PERCENT;
+ public static final Unit<Dimensionless> HUMIDITY_UNIT = Units.PERCENT;
public static final Unit<Temperature> TEMPERATURE_UNIT = SIUnits.CELSIUS;
public static final Unit<Pressure> PRESSURE_UNIT = HECTO(SIUnits.PASCAL);
- public static final Unit<Speed> WIND_SPEED_UNIT_MS = SmartHomeUnits.METRE_PER_SECOND;
- public static final Unit<Angle> WIND_DIRECTION_UNIT = SmartHomeUnits.DEGREE_ANGLE;
+ public static final Unit<Speed> WIND_SPEED_UNIT_MS = Units.METRE_PER_SECOND;
+ public static final Unit<Angle> WIND_DIRECTION_UNIT = Units.DEGREE_ANGLE;
public static final Unit<Length> RAIN_UNIT = MILLI(SIUnits.METRE);
- public static final Unit<Illuminance> LUX_UNIT = SmartHomeUnits.LUX;
- public static final Unit<ElectricCurrent> ELECTRIC_UNIT = SmartHomeUnits.AMPERE;
- public static final Unit<Power> POWER_UNIT = KILO(SmartHomeUnits.WATT);
+ public static final Unit<Illuminance> LUX_UNIT = Units.LUX;
+ public static final Unit<ElectricCurrent> ELECTRIC_UNIT = Units.AMPERE;
+ public static final Unit<Power> POWER_UNIT = KILO(Units.WATT);
public static final String CONFIGPATH_ID = "location";
public static final String DEVICE_ID = "deviceId";
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 org.openhab.core.types.State;
import org.openhab.core.types.Type;
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
State someState = super.getState(s);
BigDecimal value = ((DecimalType) someState).toBigDecimal();
- return new QuantityType<>(value, SmartHomeUnits.DEGREE_ANGLE);
+ return new QuantityType<>(value, Units.DEGREE_ANGLE);
}
},
EST_RANGE("est_range", "estimatedrange", DecimalType.class, false) {
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
State someState = super.getState(s);
BigDecimal value = ((DecimalType) someState).toBigDecimal();
- return new QuantityType<>(value, SmartHomeUnits.DEGREE_ANGLE);
+ return new QuantityType<>(value, Units.DEGREE_ANGLE);
}
},
HONK_HORN(null, "honkhorn", OnOffType.class, false) {
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
if (!channelValue.contains("null")) {
if (channelID.contains("consumption") || channelID.contains("Consumption")
|| channelID.contains("accumulatedProduction")) {
- updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), SmartHomeUnits.KILOWATT_HOUR));
+ updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), Units.KILOWATT_HOUR));
} else if (channelID.contains("power") || channelID.contains("Power")) {
- updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), SmartHomeUnits.WATT));
+ updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), Units.WATT));
} else if (channelID.contains("voltage")) {
- updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), SmartHomeUnits.VOLT));
+ updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), Units.VOLT));
} else if (channelID.contains("live_current")) {
- updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), SmartHomeUnits.AMPERE));
+ updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), Units.AMPERE));
} else {
updateState(channelID, new DecimalType(channelValue));
}
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.Channel;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.binding.builder.ThingBuilder;
void updateIllumination(TouchWandUnitDataAlarmSensor unitData) {
for (Sensor sensor : unitData.getCurrStatus().getSensorsStatus()) {
if (sensor.type == SENSOR_TYPE_LUMINANCE) {
- updateState(CHANNEL_ILLUMINATION, new QuantityType<Illuminance>(sensor.value, SmartHomeUnits.LUX));
+ updateState(CHANNEL_ILLUMINATION, new QuantityType<Illuminance>(sensor.value, Units.LUX));
}
}
}
import org.openhab.binding.tplinksmarthome.internal.Commands;
import org.openhab.binding.tplinksmarthome.internal.model.Realtime;
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.types.State;
import org.openhab.core.types.UnDefType;
switch (channelId) {
case CHANNEL_ENERGY_CURRENT:
- value = new QuantityType<>(realtime.getCurrent(), SmartHomeUnits.AMPERE);
+ value = new QuantityType<>(realtime.getCurrent(), Units.AMPERE);
break;
case CHANNEL_ENERGY_TOTAL:
- value = new QuantityType<>(realtime.getTotal(), SmartHomeUnits.KILOWATT_HOUR);
+ value = new QuantityType<>(realtime.getTotal(), Units.KILOWATT_HOUR);
break;
case CHANNEL_ENERGY_VOLTAGE:
- value = new QuantityType<>(realtime.getVoltage(), SmartHomeUnits.VOLT);
+ value = new QuantityType<>(realtime.getVoltage(), Units.VOLT);
break;
case CHANNEL_ENERGY_POWER:
- value = new QuantityType<>(realtime.getPower(), SmartHomeUnits.WATT);
+ value = new QuantityType<>(realtime.getPower(), Units.WATT);
break;
default:
value = UnDefType.UNDEF;
import org.openhab.core.cache.ExpiringCache;
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
if (deviceState == null) {
state = UnDefType.UNDEF;
} else if (CHANNEL_RSSI.equals(channelId)) {
- state = new QuantityType<>(deviceState.getSysinfo().getRssi(), SmartHomeUnits.DECIBEL_MILLIWATTS);
+ state = new QuantityType<>(deviceState.getSysinfo().getRssi(), Units.DECIBEL_MILLIWATTS);
} else {
state = smartHomeDevice.updateChannel(channelUID, deviceState);
}
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.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
if (OnOffType.ON.equals(command)) {
updateState(CONTROL, PlayPauseType.PAUSE);
stop();
- updateState(TRACK_POSITION, new QuantityType<>(0, SmartHomeUnits.SECOND));
+ updateState(TRACK_POSITION, new QuantityType<>(0, Units.SECOND));
}
}
private void handleCommandTrackPosition(ChannelUID channelUID, Command command) {
if (command instanceof RefreshType) {
- updateState(channelUID, new QuantityType<>(trackPosition, SmartHomeUnits.SECOND));
+ updateState(channelUID, new QuantityType<>(trackPosition, Units.SECOND));
} else if (command instanceof QuantityType<?>) {
- QuantityType<?> position = ((QuantityType<?>) command).toUnit(SmartHomeUnits.SECOND);
+ QuantityType<?> position = ((QuantityType<?>) command).toUnit(Units.SECOND);
if (position != null) {
int pos = Integer.min(trackDuration, position.intValue());
seek(String.format("%02d:%02d:%02d", pos / 3600, (pos % 3600) / 60, pos % 60));
try {
trackDuration = Arrays.stream(value.split("\\.")[0].split(":")).mapToInt(n -> Integer.parseInt(n))
.reduce(0, (n, m) -> n * 60 + m);
- updateState(TRACK_DURATION, new QuantityType<>(trackDuration, SmartHomeUnits.SECOND));
+ updateState(TRACK_DURATION, new QuantityType<>(trackDuration, Units.SECOND));
} catch (NumberFormatException e) {
logger.debug("Illegal format for track duration {}", value);
return;
try {
trackPosition = Arrays.stream(value.split("\\.")[0].split(":")).mapToInt(n -> Integer.parseInt(n))
.reduce(0, (n, m) -> n * 60 + m);
- updateState(TRACK_POSITION, new QuantityType<>(trackPosition, SmartHomeUnits.SECOND));
+ updateState(TRACK_POSITION, new QuantityType<>(trackPosition, Units.SECOND));
int relPosition = (trackDuration != 0) ? trackPosition * 100 / trackDuration : 0;
updateState(REL_TRACK_POSITION, new PercentType(relPosition));
} catch (NumberFormatException e) {
trackPositionRefresh = null;
trackPosition = 0;
- updateState(TRACK_POSITION, new QuantityType<>(trackPosition, SmartHomeUnits.SECOND));
+ updateState(TRACK_POSITION, new QuantityType<>(trackPosition, Units.SECOND));
int relPosition = (trackDuration != 0) ? trackPosition / trackDuration : 0;
updateState(REL_TRACK_POSITION, new PercentType(relPosition));
}
import org.openhab.core.library.types.PlayPauseType;
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.ThingStatus;
checkSetURI(0, null, false);
checkMetadataChannels(0, false);
verify(handler, times(3)).setVolume(new PercentType(50));
- verify(callback, times(2)).stateUpdated(trackPositionChannelUID, new QuantityType<>(10, SmartHomeUnits.SECOND));
+ verify(callback, times(2)).stateUpdated(trackPositionChannelUID, new QuantityType<>(10, Units.SECOND));
}
@Test
import org.eclipse.jetty.websocket.client.WebSocketClient;
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.thing.ThingStatus;
} else if (ValloxMVBindingConstants.WRITABLE_CHANNELS_TEMPERATURE.contains(channelUID.getId())) {
if (command instanceof QuantityType) {
// Convert temperature to centiKelvin (= (Celsius * 100) + 27315 )
- QuantityType<Temperature> quantity = ((QuantityType<Temperature>) command)
- .toUnit(SmartHomeUnits.KELVIN);
+ QuantityType<Temperature> quantity = ((QuantityType<Temperature>) command).toUnit(Units.KELVIN);
if (quantity == null) {
return;
}
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.ChannelUID;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
// Update channels with read values
updateChannel(ValloxMVBindingConstants.CHANNEL_ONOFF, ooOnOff);
updateChannel(ValloxMVBindingConstants.CHANNEL_STATE, new DecimalType(bdState));
- updateChannel(ValloxMVBindingConstants.CHANNEL_FAN_SPEED,
- new QuantityType<>(iFanspeed, SmartHomeUnits.PERCENT));
+ updateChannel(ValloxMVBindingConstants.CHANNEL_FAN_SPEED, new QuantityType<>(iFanspeed, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_FAN_SPEED_EXTRACT, new DecimalType(iFanspeedExtract));
updateChannel(ValloxMVBindingConstants.CHANNEL_FAN_SPEED_SUPPLY, new DecimalType(iFanspeedSupply));
updateChannel(ValloxMVBindingConstants.CHANNEL_TEMPERATURE_INSIDE,
new QuantityType<>(bdTempIncomingBeforeHeating, SIUnits.CELSIUS));
updateChannel(ValloxMVBindingConstants.CHANNEL_TEMPERATURE_INCOMING,
new QuantityType<>(bdTempIncoming, SIUnits.CELSIUS));
- updateChannel(ValloxMVBindingConstants.CHANNEL_HUMIDITY,
- new QuantityType<>(iHumidity, SmartHomeUnits.PERCENT));
+ updateChannel(ValloxMVBindingConstants.CHANNEL_HUMIDITY, new QuantityType<>(iHumidity, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_CELLSTATE, new DecimalType(iCellstate));
updateChannel(ValloxMVBindingConstants.CHANNEL_UPTIME_YEARS, new DecimalType(iUptimeYears));
updateChannel(ValloxMVBindingConstants.CHANNEL_UPTIME_HOURS, new DecimalType(iUptimeHours));
updateChannel(ValloxMVBindingConstants.CHANNEL_FILTER_CHANGED_DATE, new DateTimeType(
ZonedDateTime.ofInstant(cFilterChangedDate.toInstant(), TimeZone.getDefault().toZoneId())));
updateChannel(ValloxMVBindingConstants.CHANNEL_REMAINING_FILTER_DAYS,
- new QuantityType<>(iRemainingTimeForFilter, SmartHomeUnits.DAY));
+ new QuantityType<>(iRemainingTimeForFilter, Units.DAY));
updateChannel(ValloxMVBindingConstants.CHANNEL_EXTR_FAN_BALANCE_BASE,
- new QuantityType<>(iExtrFanBalanceBase, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iExtrFanBalanceBase, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_SUPP_FAN_BALANCE_BASE,
- new QuantityType<>(iSuppFanBalanceBase, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iSuppFanBalanceBase, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_HOME_SPEED_SETTING,
- new QuantityType<>(iHomeSpeedSetting, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iHomeSpeedSetting, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_AWAY_SPEED_SETTING,
- new QuantityType<>(iAwaySpeedSetting, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iAwaySpeedSetting, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_BOOST_SPEED_SETTING,
- new QuantityType<>(iBoostSpeedSetting, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iBoostSpeedSetting, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_HOME_AIR_TEMP_TARGET,
new QuantityType<>(bdHomeAirTempTarget, SIUnits.CELSIUS));
updateChannel(ValloxMVBindingConstants.CHANNEL_AWAY_AIR_TEMP_TARGET,
updateChannel(ValloxMVBindingConstants.CHANNEL_BOOST_TIME, new DecimalType(iBoostTime));
updateChannel(ValloxMVBindingConstants.CHANNEL_BOOST_TIMER_ENABLED, ooBoostTimerEnabled);
updateChannel(ValloxMVBindingConstants.CHANNEL_FIREPLACE_EXTR_FAN,
- new QuantityType<>(iFireplaceExtrFan, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iFireplaceExtrFan, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_FIREPLACE_SUPP_FAN,
- new QuantityType<>(iFireplaceSuppFan, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iFireplaceSuppFan, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_FIREPLACE_TIME, new DecimalType(iFireplaceTime));
updateChannel(ValloxMVBindingConstants.CHANNEL_FIREPLACE_TIMER_ENABLED, ooFireplaceTimerEnabled);
updateChannel(ValloxMVBindingConstants.CHANNEL_EXTRA_AIR_TEMP_TARGET,
new QuantityType<>(bdExtraAirTempTarget, SIUnits.CELSIUS));
updateChannel(ValloxMVBindingConstants.CHANNEL_EXTRA_EXTR_FAN,
- new QuantityType<>(iExtraExtrFan, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iExtraExtrFan, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_EXTRA_SUPP_FAN,
- new QuantityType<>(iExtraSuppFan, SmartHomeUnits.PERCENT));
+ new QuantityType<>(iExtraSuppFan, Units.PERCENT));
updateChannel(ValloxMVBindingConstants.CHANNEL_EXTRA_TIME, new DecimalType(iExtraTime));
updateChannel(ValloxMVBindingConstants.CHANNEL_EXTRA_TIMER_ENABLED, ooExtraTimerEnabled);
updateChannel(ValloxMVBindingConstants.CHANNEL_WEEKLY_TIMER_ENABLED, ooWeeklyTimerEnabled);
// Fetch 2 byte number out of bytearray representing the temperature in centiKelvin
BigDecimal bdTemperatureCentiKelvin = new BigDecimal(getNumberBE(bytes, pos));
// Return number converted to degree celsius (= (centiKelvin - 27315) / 100 )
- return (new QuantityType<>(bdTemperatureCentiKelvin, MetricPrefix.CENTI(SmartHomeUnits.KELVIN))
+ return (new QuantityType<>(bdTemperatureCentiKelvin, MetricPrefix.CENTI(Units.KELVIN))
.toUnit(SIUnits.CELSIUS)).toBigDecimal();
}
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
double voltageResolution = 0.25;
double voltageSensorValueState = sensorValue * voltageResolution;
updateState(channelUID,
- new QuantityType<>(voltageSensorValueState, MetricPrefix.MILLI(SmartHomeUnits.VOLT)));
+ new QuantityType<>(voltageSensorValueState, MetricPrefix.MILLI(Units.VOLT)));
break;
case CURRENT_SENSOR_TYPE:
double currentResolution = 5;
double currentSensorValueState = sensorValue * currentResolution;
updateState(channelUID,
- new QuantityType<>(currentSensorValueState, MetricPrefix.MICRO(SmartHomeUnits.AMPERE)));
+ new QuantityType<>(currentSensorValueState, MetricPrefix.MICRO(Units.AMPERE)));
break;
case RESISTANCE_SENSOR_TYPE:
double resistanceResolution = 0.25;
double resistanceSensorValueState = sensorValue * resistanceResolution;
- updateState(channelUID, new QuantityType<>(resistanceSensorValueState, SmartHomeUnits.OHM));
+ updateState(channelUID, new QuantityType<>(resistanceSensorValueState, Units.OHM));
break;
case PERIOD_MEASUREMENT_SENSOR_TYPE:
double periodResolution = 0.5;
double periodSensorValueState = sensorValue * periodResolution;
updateState(channelUID,
- new QuantityType<>(periodSensorValueState, MetricPrefix.MICRO(SmartHomeUnits.SECOND)));
+ new QuantityType<>(periodSensorValueState, MetricPrefix.MICRO(Units.SECOND)));
break;
}
} else if (command == COMMAND_TEXT) {
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
double windValue = (((highByteCurrentWindValue & 0xff) << 8) + (lowByteCurrentWindValue & 0xff)) / 10;
QuantityType<Length> rainValueState = new QuantityType<>(rainValue, MetricPrefix.MILLI(SIUnits.METRE));
- QuantityType<Illuminance> lightValueState = new QuantityType<>(lightValue, SmartHomeUnits.LUX);
+ QuantityType<Illuminance> lightValueState = new QuantityType<>(lightValue, Units.LUX);
QuantityType<Speed> windValueState = new QuantityType<>(windValue, SIUnits.KILOMETRE_PER_HOUR);
updateState(rainfallChannel, rainValueState);
import org.openhab.binding.velbus.internal.packets.VelbusLightValueRequestPacket;
import org.openhab.binding.velbus.internal.packets.VelbusPacket;
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;
byte lowByteCurrentLightValue = packet[7];
double lightValue = (((highByteCurrentLightValue & 0xff) << 8) + (lowByteCurrentLightValue & 0xff));
- QuantityType<Illuminance> lightValueState = new QuantityType<>(lightValue, SmartHomeUnits.LUX);
+ QuantityType<Illuminance> lightValueState = new QuantityType<>(lightValue, Units.LUX);
updateState(illuminanceChannel, lightValueState);
}
}
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
Optional<VenstarSensor> optSensor = sensorData.stream()
.filter(sensor -> sensor.getName().equalsIgnoreCase("Thermostat")).findAny();
if (optSensor.isPresent()) {
- return new QuantityType<Dimensionless>(optSensor.get().getHum(), SmartHomeUnits.PERCENT);
+ return new QuantityType<Dimensionless>(optSensor.get().getHum(), Units.PERCENT);
}
return UnDefType.UNDEF;
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.Thing;
import org.openhab.core.thing.ThingStatus;
case CHANNEL_HUMIDITY:
if (climateJSON.getData().getInstallation().getClimates().get(0).isHumidityEnabled()) {
double humidity = climateJSON.getData().getInstallation().getClimates().get(0).getHumidityValue();
- return new QuantityType<Dimensionless>(humidity, SmartHomeUnits.PERCENT);
+ return new QuantityType<Dimensionless>(humidity, Units.PERCENT);
}
case CHANNEL_HUMIDITY_ENABLED:
boolean humidityEnabled = climateJSON.getData().getInstallation().getClimates().get(0)
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.Thing;
import org.openhab.core.thing.ThingStatus;
}
case CHANNEL_DURATION_LATEST_DETECTION:
if (mouse.getDetections().size() == 0) {
- return new QuantityType<Time>(0, SmartHomeUnits.SECOND);
+ return new QuantityType<Time>(0, Units.SECOND);
} else {
- return new QuantityType<Time>(mouse.getDetections().get(0).getDuration(), SmartHomeUnits.SECOND);
+ return new QuantityType<Time>(mouse.getDetections().get(0).getDuration(), Units.SECOND);
}
case CHANNEL_DURATION_LAST_24_HOURS:
if (mouse.getDetections().size() == 0) {
- return new QuantityType<Time>(0, SmartHomeUnits.SECOND);
+ return new QuantityType<Time>(0, Units.SECOND);
} else {
return new QuantityType<Time>(mouse.getDetections().stream().mapToInt(Detection::getDuration).sum(),
- SmartHomeUnits.SECOND);
+ Units.SECOND);
}
case CHANNEL_LOCATION:
String location = mouse.getDevice().getArea();
import org.openhab.core.library.types.RawType;
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;
updateRelativeMeasure(RELATIVE_HEIGHT, referenceHeights, height);
});
field.getFlow().ifPresent(flow -> {
- updateQuantity(FLOW, flow, SmartHomeUnits.CUBICMETRE_PER_SECOND);
+ updateQuantity(FLOW, flow, Units.CUBICMETRE_PER_SECOND);
updateRelativeMeasure(RELATIVE_FLOW, referenceFlows, flow);
});
field.getTimestamp().ifPresent(date -> updateDate(OBSERVATION_TIME, date));
private void updateRelativeMeasure(String channelId, List<QuantityType<?>> reference, double value) {
if (reference.size() > 0) {
double percent = value / reference.get(0).doubleValue() * 100;
- updateQuantity(channelId, percent, SmartHomeUnits.PERCENT);
+ updateQuantity(channelId, percent, Units.PERCENT);
}
}
import static org.openhab.binding.volvooncall.internal.VolvoOnCallBindingConstants.*;
import static org.openhab.core.library.unit.MetricPrefix.KILO;
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.ZonedDateTime;
import java.util.Collection;
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.Thing;
import org.openhab.core.thing.ThingStatus;
}
protected Unit<?> getSpeedUnit() {
- return isImperial() ? ImperialUnits.MILES_PER_HOUR : SmartHomeUnits.METRE_PER_SECOND;
+ return isImperial() ? ImperialUnits.MILES_PER_HOUR : Units.METRE_PER_SECOND;
}
protected Unit<?> getLengthUnit() {
import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.i18n.UnitProvider;
import org.openhab.core.library.types.RawType;
-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;
updateDaypart(i, dOrN, CH_DP_TEMP, undefOrQuantity(dp.temperature[i], getTempUnit()));
updateDaypart(i, dOrN, CH_DP_TEMP_HEAT_INDEX, undefOrQuantity(dp.temperatureHeatIndex[i], getTempUnit()));
updateDaypart(i, dOrN, CH_DP_TEMP_WIND_CHILL, undefOrQuantity(dp.temperatureWindChill[i], getTempUnit()));
- updateDaypart(i, dOrN, CH_DP_HUMIDITY, undefOrQuantity(dp.relativeHumidity[i], SmartHomeUnits.PERCENT));
- updateDaypart(i, dOrN, CH_DP_CLOUD_COVER, undefOrQuantity(dp.cloudCover[i], SmartHomeUnits.PERCENT));
- updateDaypart(i, dOrN, CH_DP_PRECIP_CHANCE, undefOrQuantity(dp.precipChance[i], SmartHomeUnits.PERCENT));
+ updateDaypart(i, dOrN, CH_DP_HUMIDITY, undefOrQuantity(dp.relativeHumidity[i], Units.PERCENT));
+ updateDaypart(i, dOrN, CH_DP_CLOUD_COVER, undefOrQuantity(dp.cloudCover[i], Units.PERCENT));
+ updateDaypart(i, dOrN, CH_DP_PRECIP_CHANCE, undefOrQuantity(dp.precipChance[i], Units.PERCENT));
updateDaypart(i, dOrN, CH_DP_PRECIP_TYPE, undefOrString(dp.precipType[i]));
updateDaypart(i, dOrN, CH_DP_PRECIP_RAIN, undefOrQuantity(dp.qpf[i], getLengthUnit()));
updateDaypart(i, dOrN, CH_DP_PRECIP_SNOW, undefOrQuantity(dp.qpfSnow[i], getLengthUnit()));
updateDaypart(i, dOrN, CH_DP_WIND_SPEED, undefOrQuantity(dp.windSpeed[i], getSpeedUnit()));
updateDaypart(i, dOrN, CH_DP_WIND_DIR_CARDINAL, undefOrString(dp.windDirectionCardinal[i]));
updateDaypart(i, dOrN, CH_DP_WIND_PHRASE, undefOrString(dp.windPhrase[i]));
- updateDaypart(i, dOrN, CH_DP_WIND_DIR, undefOrQuantity(dp.windDirection[i], SmartHomeUnits.DEGREE_ANGLE));
+ updateDaypart(i, dOrN, CH_DP_WIND_DIR, undefOrQuantity(dp.windDirection[i], Units.DEGREE_ANGLE));
updateDaypart(i, dOrN, CH_DP_THUNDER_CATEGORY, undefOrString(dp.thunderCategory[i]));
updateDaypart(i, dOrN, CH_DP_THUNDER_INDEX, undefOrDecimal(dp.thunderIndex[i]));
updateDaypart(i, dOrN, CH_DP_UV_DESCRIPTION, undefOrString(dp.uvDescription[i]));
import org.openhab.core.i18n.TimeZoneProvider;
import org.openhab.core.i18n.UnitProvider;
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.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
updateChannel(CH_PWS_TEMP_HEAT_INDEX, undefOrQuantity(obs.imperial.heatIndex, ImperialUnits.FAHRENHEIT));
updateChannel(CH_PWS_TEMP_WIND_CHILL, undefOrQuantity(obs.imperial.windChill, ImperialUnits.FAHRENHEIT));
updateChannel(CH_PWS_TEMP_DEW_POINT, undefOrQuantity(obs.imperial.dewpt, ImperialUnits.FAHRENHEIT));
- updateChannel(CH_PWS_HUMIDITY, undefOrQuantity(obs.humidity, SmartHomeUnits.PERCENT));
+ updateChannel(CH_PWS_HUMIDITY, undefOrQuantity(obs.humidity, Units.PERCENT));
updateChannel(CH_PWS_PRESSURE, undefOrQuantity(obs.imperial.pressure, ImperialUnits.INCH_OF_MERCURY));
- updateChannel(CH_PWS_PRECIPTATION_RATE,
- undefOrQuantity(obs.imperial.precipRate, SmartHomeUnits.INCHES_PER_HOUR));
+ updateChannel(CH_PWS_PRECIPTATION_RATE, undefOrQuantity(obs.imperial.precipRate, Units.INCHES_PER_HOUR));
updateChannel(CH_PWS_PRECIPITATION_TOTAL, undefOrQuantity(obs.imperial.precipTotal, ImperialUnits.INCH));
updateChannel(CH_PWS_WIND_SPEED, undefOrQuantity(obs.imperial.windSpeed, ImperialUnits.MILES_PER_HOUR));
updateChannel(CH_PWS_WIND_GUST, undefOrQuantity(obs.imperial.windGust, ImperialUnits.MILES_PER_HOUR));
- updateChannel(CH_PWS_WIND_DIRECTION, undefOrQuantity(obs.winddir, SmartHomeUnits.DEGREE_ANGLE));
- updateChannel(CH_PWS_SOLAR_RADIATION, undefOrQuantity(obs.solarRadiation, SmartHomeUnits.IRRADIANCE));
+ updateChannel(CH_PWS_WIND_DIRECTION, undefOrQuantity(obs.winddir, Units.DEGREE_ANGLE));
+ updateChannel(CH_PWS_SOLAR_RADIATION, undefOrQuantity(obs.solarRadiation, Units.IRRADIANCE));
updateChannel(CH_PWS_UV, undefOrDecimal(obs.uv));
updateChannel(CH_PWS_OBSERVATION_TIME_LOCAL, undefOrDate(obs.obsTimeUtc));
updateChannel(CH_PWS_NEIGHBORHOOD, undefOrString(obs.neighborhood));
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;
return undefOrQuantity(quantity);
case "relativeHumidity":
return undefOrState(current.getRelativeHumidity(),
- new QuantityType<>(current.getRelativeHumidity(), SmartHomeUnits.PERCENT));
+ new QuantityType<>(current.getRelativeHumidity(), Units.PERCENT));
case "windDirection":
return undefOrState(current.getWindDirection(), new StringType(current.getWindDirection()));
case "windDirectionDegrees":
return undefOrState(current.getWindDirectionDegrees(),
- new QuantityType<>(current.getWindDirectionDegrees(), SmartHomeUnits.DEGREE_ANGLE));
+ new QuantityType<>(current.getWindDirectionDegrees(), Units.DEGREE_ANGLE));
case "windSpeed":
quantity = getSpeed(current.getWindSpeedKmh(), current.getWindSpeedMph());
return undefOrQuantity(quantity);
current.getVisibilityMi());
return undefOrQuantity(quantity);
case "solarRadiation":
- return undefOrQuantity(new WUQuantity(current.getSolarRadiation(), SmartHomeUnits.IRRADIANCE));
+ return undefOrQuantity(new WUQuantity(current.getSolarRadiation(), Units.IRRADIANCE));
case "UVIndex":
return undefOrDecimal(current.getUVIndex());
case "precipitationDay":
return undefOrQuantity(quantity);
case "relativeHumidity":
return undefOrState(dayForecast.getRelativeHumidity(),
- new QuantityType<>(dayForecast.getRelativeHumidity(), SmartHomeUnits.PERCENT));
+ new QuantityType<>(dayForecast.getRelativeHumidity(), Units.PERCENT));
case "probaPrecipitation":
return undefOrState(dayForecast.getProbaPrecipitation(),
- new QuantityType<>(dayForecast.getProbaPrecipitation(), SmartHomeUnits.PERCENT));
+ new QuantityType<>(dayForecast.getProbaPrecipitation(), Units.PERCENT));
case "precipitationDay":
quantity = getPrecipitation(dayForecast.getPrecipitationDayMm(), dayForecast.getPrecipitationDayIn());
return undefOrQuantity(quantity);
new StringType(dayForecast.getMaxWindDirection()));
case "maxWindDirectionDegrees":
return undefOrState(dayForecast.getMaxWindDirectionDegrees(),
- new QuantityType<>(dayForecast.getMaxWindDirectionDegrees(), SmartHomeUnits.DEGREE_ANGLE));
+ new QuantityType<>(dayForecast.getMaxWindDirectionDegrees(), Units.DEGREE_ANGLE));
case "maxWindSpeed":
quantity = getSpeed(dayForecast.getMaxWindSpeedKmh(), dayForecast.getMaxWindSpeedMph());
return undefOrQuantity(quantity);
new StringType(dayForecast.getAverageWindDirection()));
case "averageWindDirectionDegrees":
return undefOrState(dayForecast.getAverageWindDirectionDegrees(),
- new QuantityType<>(dayForecast.getAverageWindDirectionDegrees(), SmartHomeUnits.DEGREE_ANGLE));
+ new QuantityType<>(dayForecast.getAverageWindDirectionDegrees(), Units.DEGREE_ANGLE));
case "averageWindSpeed":
quantity = getSpeed(dayForecast.getAverageWindSpeedKmh(), dayForecast.getAverageWindSpeedMph());
return undefOrQuantity(quantity);
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.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
updateState(CHANNEL_WIND_SPEED, new DecimalType(millData.get(CHANNEL_WIND_SPEED).getAsString()));
updateState(CHANNEL_WIND_DIRECTION, new StringType(millData.get(CHANNEL_WIND_DIRECTION).getAsString()));
updateState(CHANNEL_POWER_TOTAL,
- new QuantityType<>(millData.get(CHANNEL_POWER_TOTAL).getAsBigDecimal(), KILO(SmartHomeUnits.WATT)));
+ new QuantityType<>(millData.get(CHANNEL_POWER_TOTAL).getAsBigDecimal(), KILO(Units.WATT)));
updateState(CHANNEL_POWER_PER_WD,
new QuantityType<>(
millData.get(CHANNEL_POWER_PER_WD).getAsBigDecimal().multiply(new BigDecimal(config.wd)),
- SmartHomeUnits.WATT));
+ Units.WATT));
updateState(CHANNEL_POWER_RELATIVE,
- new QuantityType<>(millData.get(CHANNEL_POWER_RELATIVE).getAsBigDecimal(), SmartHomeUnits.PERCENT));
+ new QuantityType<>(millData.get(CHANNEL_POWER_RELATIVE).getAsBigDecimal(), Units.PERCENT));
updateState(CHANNEL_ENERGY,
- new QuantityType<>(millData.get(CHANNEL_ENERGY).getAsBigDecimal(), SmartHomeUnits.KILOWATT_HOUR));
- updateState(CHANNEL_ENERGY_FC, new QuantityType<>(millData.get(CHANNEL_ENERGY_FC).getAsBigDecimal(),
- SmartHomeUnits.KILOWATT_HOUR));
+ new QuantityType<>(millData.get(CHANNEL_ENERGY).getAsBigDecimal(), Units.KILOWATT_HOUR));
+ updateState(CHANNEL_ENERGY_FC,
+ new QuantityType<>(millData.get(CHANNEL_ENERGY_FC).getAsBigDecimal(), Units.KILOWATT_HOUR));
updateState(CHANNEL_RUNTIME,
- new QuantityType<>(millData.get(HOURS_RUN_THIS_YEAR).getAsBigDecimal(), SmartHomeUnits.HOUR));
+ new QuantityType<>(millData.get(HOURS_RUN_THIS_YEAR).getAsBigDecimal(), Units.HOUR));
updateState(CHANNEL_RUNTIME_PER,
- new QuantityType<>(millData.get(CHANNEL_RUNTIME_PER).getAsBigDecimal(), SmartHomeUnits.PERCENT));
+ new QuantityType<>(millData.get(CHANNEL_RUNTIME_PER).getAsBigDecimal(), Units.PERCENT));
updateState(CHANNEL_LAST_UPDATE, new DateTimeType(millData.get(CHANNEL_LAST_UPDATE).getAsString()));
if (!getThing().getStatus().equals(ThingStatus.ONLINE)) {
import org.openhab.core.library.types.PercentType;
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;
break;
case CHANNEL_PRESET_DURATION:
if (command instanceof QuantityType) {
- QuantityType<?> seconds = ((QuantityType<?>) command).toUnit(SmartHomeUnits.SECOND);
+ QuantityType<?> seconds = ((QuantityType<?>) command).toUnit(Units.SECOND);
if (seconds != null) {
bigTemp = new BigDecimal(seconds.intValue()).multiply(new BigDecimal(1000));
sendGetRequest("/win&PT=" + bigTemp.intValue());
break;
case CHANNEL_TRANS_TIME:
if (command instanceof QuantityType) {
- QuantityType<?> seconds = ((QuantityType<?>) command).toUnit(SmartHomeUnits.SECOND);
+ QuantityType<?> seconds = ((QuantityType<?>) command).toUnit(Units.SECOND);
if (seconds != null) {
bigTemp = new BigDecimal(seconds.intValue()).multiply(new BigDecimal(1000));
sendGetRequest("/win&TT=" + bigTemp.intValue());
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.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
if (progress > 100 || progress < 0) {
logger.debug("Outstanding process");
}
- updateState(channelUID, new QuantityType<>(progress, SmartHomeUnits.PERCENT));
+ updateState(channelUID, new QuantityType<>(progress, Units.PERCENT));
break;
}
private QuantityType<?> getDurationInSeconds(Instant from, Instant to) {
Duration elapsed = Duration.between(from, to);
long secondsElapsed = TimeUnit.MILLISECONDS.toSeconds(elapsed.toMillis());
- return new QuantityType<>(secondsElapsed, SmartHomeUnits.SECOND);
+ return new QuantityType<>(secondsElapsed, Units.SECOND);
}
private @Nullable RawType downloadIcon(List<Icon> icons) {
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;
ZonedDateTime.ofInstant(event.getEnd().toInstant(), timeZoneProvider.getTimeZone())));
updateChannelState(CHANNEL_EVENT_FRAMES, new DecimalType(event.getFrames()));
updateChannelState(CHANNEL_EVENT_ALARM_FRAMES, new DecimalType(event.getAlarmFrames()));
- updateChannelState(CHANNEL_EVENT_LENGTH, new QuantityType<Time>(event.getLength(), SmartHomeUnits.SECOND));
+ updateChannelState(CHANNEL_EVENT_LENGTH, new QuantityType<Time>(event.getLength(), Units.SECOND));
}
}
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.types.State;
import org.openhab.persistence.mapdb.internal.StateTypeAdapter;
PercentType.valueOf("0.0000001"), PercentType.valueOf("12"), PercentType.valueOf("99.999"));
private static final List<QuantityType<?>> QUANTITY_TYPE_VALUES = List.of(QuantityType.valueOf("0 W"),
- QuantityType.valueOf("1 kW"), QuantityType.valueOf(20, SmartHomeUnits.AMPERE),
+ QuantityType.valueOf("1 kW"), QuantityType.valueOf(20, Units.AMPERE),
new QuantityType<>(new BigDecimal("21.23"), SIUnits.CELSIUS),
new QuantityType<>(new BigDecimal("75"), ImperialUnits.MILES_PER_HOUR),
- QuantityType.valueOf(1000, SmartHomeUnits.KELVIN),
- QuantityType.valueOf(100, SmartHomeUnits.METRE_PER_SQUARE_SECOND));
+ QuantityType.valueOf(1000, Units.KELVIN), QuantityType.valueOf(100, Units.METRE_PER_SQUARE_SECOND));
private static final List<StringType> STRING_TYPE_VALUES = List.of(StringType.valueOf("test"),
StringType.valueOf("a b c 1 2 3"), StringType.valueOf(""), StringType.valueOf("@@@### @@@"));
import org.openhab.binding.astro.test.AstroStateTest;
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;
/**
* Test cases used in the {@link AstroStateTest}
cases[2][0] = TEST_SUN_THING_ID;
cases[2][1] = "rise#duration";
- cases[2][2] = new QuantityType<>(2, SmartHomeUnits.MINUTE);
+ cases[2][2] = new QuantityType<>(2, Units.MINUTE);
cases[3][0] = TEST_SUN_THING_ID;
cases[3][1] = "set#start";
cases[5][0] = TEST_SUN_THING_ID;
cases[5][1] = "set#duration";
- cases[5][2] = new QuantityType<>(2, SmartHomeUnits.MINUTE);
+ cases[5][2] = new QuantityType<>(2, Units.MINUTE);
cases[6][0] = TEST_SUN_THING_ID;
cases[6][1] = "noon#start";
cases[8][0] = TEST_SUN_THING_ID;
cases[8][1] = "noon#duration";
- cases[8][2] = new QuantityType<>(1, SmartHomeUnits.MINUTE);
+ cases[8][2] = new QuantityType<>(1, Units.MINUTE);
cases[9][0] = TEST_SUN_THING_ID;
cases[9][1] = "night#start";
cases[11][0] = TEST_SUN_THING_ID;
cases[11][1] = "night#duration";
- cases[11][2] = new QuantityType<>(589, SmartHomeUnits.MINUTE);
+ cases[11][2] = new QuantityType<>(589, Units.MINUTE);
cases[12][0] = TEST_SUN_THING_ID;
cases[12][1] = "morningNight#start";
cases[14][0] = TEST_SUN_THING_ID;
cases[14][1] = "morningNight#duration";
- cases[14][2] = new QuantityType<>(272, SmartHomeUnits.MINUTE);
+ cases[14][2] = new QuantityType<>(272, Units.MINUTE);
cases[15][0] = TEST_SUN_THING_ID;
cases[15][1] = "astroDawn#start";
cases[17][0] = TEST_SUN_THING_ID;
cases[17][1] = "astroDawn#duration";
- cases[17][2] = new QuantityType<>(26, SmartHomeUnits.MINUTE);
+ cases[17][2] = new QuantityType<>(26, Units.MINUTE);
cases[18][0] = TEST_SUN_THING_ID;
cases[18][1] = "nauticDawn#start";
cases[20][0] = TEST_SUN_THING_ID;
cases[20][1] = "nauticDawn#duration";
- cases[20][2] = new QuantityType<>(26, SmartHomeUnits.MINUTE);
+ cases[20][2] = new QuantityType<>(26, Units.MINUTE);
cases[21][0] = TEST_SUN_THING_ID;
cases[21][1] = "civilDawn#start";
cases[23][0] = TEST_SUN_THING_ID;
cases[23][1] = "civilDawn#duration";
- cases[23][2] = new QuantityType<>(22, SmartHomeUnits.MINUTE);
+ cases[23][2] = new QuantityType<>(22, Units.MINUTE);
cases[24][0] = TEST_SUN_THING_ID;
cases[24][1] = "astroDusk#start";
cases[26][0] = TEST_SUN_THING_ID;
cases[26][1] = "astroDusk#duration";
- cases[26][2] = new QuantityType<>(26, SmartHomeUnits.MINUTE);
+ cases[26][2] = new QuantityType<>(26, Units.MINUTE);
cases[27][0] = TEST_SUN_THING_ID;
cases[27][1] = "nauticDusk#start";
cases[29][0] = TEST_SUN_THING_ID;
cases[29][1] = "nauticDusk#duration";
- cases[29][2] = new QuantityType<>(26, SmartHomeUnits.MINUTE);
+ cases[29][2] = new QuantityType<>(26, Units.MINUTE);
cases[30][0] = TEST_SUN_THING_ID;
cases[30][1] = "civilDusk#start";
cases[32][0] = TEST_SUN_THING_ID;
cases[32][1] = "civilDusk#duration";
- cases[32][2] = new QuantityType<>(23, SmartHomeUnits.MINUTE);
+ cases[32][2] = new QuantityType<>(23, Units.MINUTE);
cases[33][0] = TEST_SUN_THING_ID;
cases[33][1] = "eveningNight#start";
cases[35][0] = TEST_SUN_THING_ID;
cases[35][1] = "eveningNight#duration";
- cases[35][2] = new QuantityType<>(318, SmartHomeUnits.MINUTE);
+ cases[35][2] = new QuantityType<>(318, Units.MINUTE);
cases[36][0] = TEST_SUN_THING_ID;
cases[36][1] = "daylight#start";
cases[38][0] = TEST_SUN_THING_ID;
cases[38][1] = "daylight#duration";
- cases[38][2] = new QuantityType<>(697, SmartHomeUnits.MINUTE);
+ cases[38][2] = new QuantityType<>(697, Units.MINUTE);
cases[39][0] = TEST_MOON_THING_ID;
cases[39][1] = "rise#start";
cases[41][0] = TEST_MOON_THING_ID;
cases[41][1] = "rise#duration";
- cases[41][2] = new QuantityType<>(0, SmartHomeUnits.MINUTE);
+ cases[41][2] = new QuantityType<>(0, Units.MINUTE);
}
public List<Object[]> getCases() {
import org.openhab.core.config.core.Configuration;
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.Thing;
import org.openhab.core.thing.ThingStatus;
assertThatItemHasState(CHANNEL_ECO_MAX_SET_POINT, new QuantityType<>(24, CELSIUS));
assertThatItemHasState(CHANNEL_ECO_MIN_SET_POINT, new QuantityType<>(12.5, CELSIUS));
assertThatItemHasState(CHANNEL_FAN_TIMER_ACTIVE, OFF);
- assertThatItemHasState(CHANNEL_FAN_TIMER_DURATION, new QuantityType<>(15, SmartHomeUnits.MINUTE));
+ assertThatItemHasState(CHANNEL_FAN_TIMER_DURATION, new QuantityType<>(15, Units.MINUTE));
assertThatItemHasState(CHANNEL_FAN_TIMER_TIMEOUT, parseDateTimeType("1970-01-01T00:00:00.000Z"));
assertThatItemHasState(CHANNEL_HAS_FAN, ON);
assertThatItemHasState(CHANNEL_HAS_LEAF, ON);
- assertThatItemHasState(CHANNEL_HUMIDITY, new QuantityType<>(25, SmartHomeUnits.PERCENT));
+ assertThatItemHasState(CHANNEL_HUMIDITY, new QuantityType<>(25, Units.PERCENT));
assertThatItemHasState(CHANNEL_LAST_CONNECTION, parseDateTimeType("2017-02-02T21:00:06.000Z"));
assertThatItemHasState(CHANNEL_LOCKED, OFF);
assertThatItemHasState(CHANNEL_LOCKED_MAX_SET_POINT, new QuantityType<>(22, CELSIUS));
assertThatItemHasState(CHANNEL_SUNLIGHT_CORRECTION_ACTIVE, OFF);
assertThatItemHasState(CHANNEL_SUNLIGHT_CORRECTION_ENABLED, ON);
assertThatItemHasState(CHANNEL_TEMPERATURE, new QuantityType<>(19, CELSIUS));
- assertThatItemHasState(CHANNEL_TIME_TO_TARGET, new QuantityType<>(0, SmartHomeUnits.MINUTE));
+ assertThatItemHasState(CHANNEL_TIME_TO_TARGET, new QuantityType<>(0, Units.MINUTE));
assertThatItemHasState(CHANNEL_USING_EMERGENCY_HEAT, OFF);
assertThatAllItemStatesAreNotNull();
assertThatItemHasState(CHANNEL_ECO_MAX_SET_POINT, new QuantityType<>(76, FAHRENHEIT));
assertThatItemHasState(CHANNEL_ECO_MIN_SET_POINT, new QuantityType<>(55, FAHRENHEIT));
assertThatItemHasState(CHANNEL_FAN_TIMER_ACTIVE, OFF);
- assertThatItemHasState(CHANNEL_FAN_TIMER_DURATION, new QuantityType<>(15, SmartHomeUnits.MINUTE));
+ assertThatItemHasState(CHANNEL_FAN_TIMER_DURATION, new QuantityType<>(15, Units.MINUTE));
assertThatItemHasState(CHANNEL_FAN_TIMER_TIMEOUT, parseDateTimeType("1970-01-01T00:00:00.000Z"));
assertThatItemHasState(CHANNEL_HAS_FAN, ON);
assertThatItemHasState(CHANNEL_HAS_LEAF, ON);
- assertThatItemHasState(CHANNEL_HUMIDITY, new QuantityType<>(25, SmartHomeUnits.PERCENT));
+ assertThatItemHasState(CHANNEL_HUMIDITY, new QuantityType<>(25, Units.PERCENT));
assertThatItemHasState(CHANNEL_LAST_CONNECTION, parseDateTimeType("2017-02-02T21:00:06.000Z"));
assertThatItemHasState(CHANNEL_LOCKED, OFF);
assertThatItemHasState(CHANNEL_LOCKED_MAX_SET_POINT, new QuantityType<>(72, FAHRENHEIT));
assertThatItemHasState(CHANNEL_SUNLIGHT_CORRECTION_ACTIVE, OFF);
assertThatItemHasState(CHANNEL_SUNLIGHT_CORRECTION_ENABLED, ON);
assertThatItemHasState(CHANNEL_TEMPERATURE, new QuantityType<>(66, FAHRENHEIT));
- assertThatItemHasState(CHANNEL_TIME_TO_TARGET, new QuantityType<>(0, SmartHomeUnits.MINUTE));
+ assertThatItemHasState(CHANNEL_TIME_TO_TARGET, new QuantityType<>(0, Units.MINUTE));
assertThatItemHasState(CHANNEL_USING_EMERGENCY_HEAT, OFF);
assertThatAllItemStatesAreNotNull();
public void handleFanTimerDurationCommands() throws IOException {
int[] durations = { 15, 30, 45, 60, 120, 240, 480, 960, 15 };
for (int duration : durations) {
- handleCommand(CHANNEL_FAN_TIMER_DURATION, new QuantityType<>(duration, SmartHomeUnits.MINUTE));
+ handleCommand(CHANNEL_FAN_TIMER_DURATION, new QuantityType<>(duration, Units.MINUTE));
assertNestApiPropertyState(THERMOSTAT1_DEVICE_ID, "fan_timer_duration", String.valueOf(duration));
}
}