private BigDecimal getQuantityTypeAsDecimal(QuantityType<?> qType) {
BigDecimal val = qType.toBigDecimal();
if (!qType.getUnit().isCompatible(Units.ONE)) {
- QuantityType<?> convertedType = qType.toUnit(unit);
+ QuantityType<?> convertedType = qType.toInvertibleUnit(unit);
if (convertedType != null) {
val = convertedType.toBigDecimal();
}
assertThat(v.getChannelState(), is(new QuantityType<>(20, Units.WATT)));
}
+ @Test
+ public void numberUpdateMireds() {
+ NumberValue v = new NumberValue(null, null, new BigDecimal(10), Units.MIRED);
+
+ v.update(new QuantityType<>(2700, Units.KELVIN));
+ assertThat(v.getMQTTpublishValue("%.0f"), is("370"));
+ }
+
@Test
public void numberPercentageUpdate() {
NumberValue v = new NumberValue(null, null, new BigDecimal(10), Units.PERCENT);