]> git.basschouten.com Git - openhab-addons.git/blob
bb20d495ed3753ef8c373c5240076cbcf2ed866d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.bluetooth.airthings.internal;
14
15 import java.math.BigInteger;
16 import java.util.Set;
17
18 import javax.measure.Unit;
19 import javax.measure.quantity.Dimensionless;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.openhab.binding.bluetooth.BluetoothBindingConstants;
23 import org.openhab.core.library.dimension.Density;
24 import org.openhab.core.library.unit.SIUnits;
25 import org.openhab.core.library.unit.Units;
26 import org.openhab.core.thing.ThingTypeUID;
27
28 import tech.units.indriya.format.SimpleUnitFormat;
29 import tech.units.indriya.function.MultiplyConverter;
30 import tech.units.indriya.unit.ProductUnit;
31 import tech.units.indriya.unit.TransformedUnit;
32
33 /**
34  * The {@link AirthingsBindingConstants} class defines common constants, which are
35  * used across the whole binding.
36  *
37  * @author Pauli Anttila - Initial contribution
38  * @author Kai Kreuzer - Added Airthings Wave Mini support
39  * @author Davy Wong - Added Airthings Wave Gen 1 support
40  */
41 @NonNullByDefault
42 public class AirthingsBindingConstants {
43
44     // List of all Thing Type UIDs
45     public static final ThingTypeUID THING_TYPE_AIRTHINGS_WAVE_PLUS = new ThingTypeUID(
46             BluetoothBindingConstants.BINDING_ID, "airthings_wave_plus");
47     public static final ThingTypeUID THING_TYPE_AIRTHINGS_WAVE_MINI = new ThingTypeUID(
48             BluetoothBindingConstants.BINDING_ID, "airthings_wave_mini");
49     public static final ThingTypeUID THING_TYPE_AIRTHINGS_WAVE_GEN1 = new ThingTypeUID(
50             BluetoothBindingConstants.BINDING_ID, "airthings_wave_gen1");
51
52     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_AIRTHINGS_WAVE_PLUS,
53             THING_TYPE_AIRTHINGS_WAVE_MINI, THING_TYPE_AIRTHINGS_WAVE_GEN1);
54
55     // Channel IDs
56     public static final String CHANNEL_ID_HUMIDITY = "humidity";
57     public static final String CHANNEL_ID_TEMPERATURE = "temperature";
58     public static final String CHANNEL_ID_PRESSURE = "pressure";
59     public static final String CHANNEL_ID_CO2 = "co2";
60     public static final String CHANNEL_ID_TVOC = "tvoc";
61     public static final String CHANNEL_ID_RADON_ST_AVG = "radon_st_avg";
62     public static final String CHANNEL_ID_RADON_LT_AVG = "radon_lt_avg";
63
64     public static final Unit<Dimensionless> PARTS_PER_BILLION = new TransformedUnit<>(Units.ONE,
65             MultiplyConverter.ofRational(BigInteger.ONE, BigInteger.valueOf(1000000000)));
66     public static final Unit<Density> BECQUEREL_PER_CUBIC_METRE = new ProductUnit<>(
67             Units.BECQUEREL.divide(SIUnits.CUBIC_METRE));
68
69     static {
70         SimpleUnitFormat.getInstance().label(PARTS_PER_BILLION, "ppb");
71         SimpleUnitFormat.getInstance().label(BECQUEREL_PER_CUBIC_METRE, "Bq/m³");
72     }
73 }