* @author Kai Kreuzer - Added Airthings Wave Mini support
*/
@NonNullByDefault
-abstract public class AbstractAirthingsHandler extends BeaconBluetoothHandler {
+public abstract class AbstractAirthingsHandler extends BeaconBluetoothHandler {
private static final int CHECK_PERIOD_SEC = 10;
*
* @param is the content of the bluetooth characteristic
*/
- abstract protected void updateChannels(int[] is);
+ protected abstract void updateChannels(int[] is);
}
*/
package org.openhab.binding.bluetooth.airthings.internal;
-import java.math.BigInteger;
import java.util.Set;
-import javax.measure.Unit;
-import javax.measure.quantity.Dimensionless;
-
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.bluetooth.BluetoothBindingConstants;
-import org.openhab.core.library.dimension.Density;
-import org.openhab.core.library.unit.SIUnits;
-import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.ThingTypeUID;
-import tech.units.indriya.format.SimpleUnitFormat;
-import tech.units.indriya.function.MultiplyConverter;
-import tech.units.indriya.unit.ProductUnit;
-import tech.units.indriya.unit.TransformedUnit;
-
/**
* The {@link AirthingsBindingConstants} class defines common constants, which are
* used across the whole binding.
public static final String CHANNEL_ID_TVOC = "tvoc";
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<>(Units.ONE,
- MultiplyConverter.ofRational(BigInteger.ONE, BigInteger.valueOf(1000000000)));
- public static final Unit<Density> BECQUEREL_PER_CUBIC_METRE = new ProductUnit<>(
- Units.BECQUEREL.divide(SIUnits.CUBIC_METRE));
-
- static {
- SimpleUnitFormat.getInstance().label(PARTS_PER_BILLION, "ppb");
- SimpleUnitFormat.getInstance().label(BECQUEREL_PER_CUBIC_METRE, "Bq/m³");
- }
}
private boolean isAirthingsDevice(BluetoothDiscoveryDevice device) {
Integer manufacturerId = device.getManufacturerId();
- if (manufacturerId != null && manufacturerId == AIRTHINGS_COMPANY_ID) {
- return true;
- }
- return false;
+ return manufacturerId != null && manufacturerId == AIRTHINGS_COMPANY_ID;
}
private DiscoveryResult createResult(BluetoothDiscoveryDevice device, ThingUID thingUID, String label) {
logger.debug("Change next readSensor to: {}", readSensor);
logger.debug("Update channel 3");
updateState(CHANNEL_ID_RADON_ST_AVG,
- QuantityType.valueOf(Double.valueOf(intResult), BECQUEREL_PER_CUBIC_METRE));
+ QuantityType.valueOf(Double.valueOf(intResult), Units.BECQUEREL_PER_CUBIC_METRE));
logger.debug("Update channel 3 done");
break;
case RADON_LTA:
logger.debug("Change next readSensor to: {}", readSensor);
logger.debug("Update channel 4");
updateState(CHANNEL_ID_RADON_LT_AVG,
- QuantityType.valueOf(Double.valueOf(intResult), BECQUEREL_PER_CUBIC_METRE));
+ QuantityType.valueOf(Double.valueOf(intResult), Units.BECQUEREL_PER_CUBIC_METRE));
logger.debug("Update channel 4 done");
break;
}
}
Number tvoc = data.get(AirthingsDataParser.TVOC);
if (tvoc != null) {
- updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, PARTS_PER_BILLION));
+ updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, Units.PARTS_PER_BILLION));
}
} catch (AirthingsParserException e) {
logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage());
}
Number tvoc = data.get(AirthingsDataParser.TVOC);
if (tvoc != null) {
- updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, PARTS_PER_BILLION));
+ updateState(CHANNEL_ID_TVOC, new QuantityType<Dimensionless>(tvoc, Units.PARTS_PER_BILLION));
}
Number radonShortTermAvg = data.get(AirthingsDataParser.RADON_SHORT_TERM_AVG);
if (radonShortTermAvg != null) {
updateState(CHANNEL_ID_RADON_ST_AVG,
- new QuantityType<Density>(radonShortTermAvg, BECQUEREL_PER_CUBIC_METRE));
+ new QuantityType<Density>(radonShortTermAvg, Units.BECQUEREL_PER_CUBIC_METRE));
}
Number radonLongTermAvg = data.get(AirthingsDataParser.RADON_LONG_TERM_AVG);
if (radonLongTermAvg != null) {
updateState(CHANNEL_ID_RADON_LT_AVG,
- new QuantityType<Density>(radonLongTermAvg, BECQUEREL_PER_CUBIC_METRE));
+ new QuantityType<Density>(radonLongTermAvg, Units.BECQUEREL_PER_CUBIC_METRE));
}
} catch (AirthingsParserException e) {
logger.error("Failed to parse data received from Airthings sensor: {}", e.getMessage());