]> git.basschouten.com Git - openhab-addons.git/blob
726ca276c8076c82c0ad57f14307ca43a6729498
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.airgradient.internal.model;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * Data model class for a single measurement from AirGradients API.
20  *
21  * @author Jørgen Austvik - Initial contribution
22  */
23 @NonNullByDefault
24 public class Measure {
25
26     /**
27      * Returns a location id that is guaranteed to not be null.
28      * 
29      * @return A non null location id.
30      */
31     public String getLocationId() {
32         String loc = locationId;
33         if (loc != null) {
34             return loc;
35         }
36
37         return "";
38     }
39
40     /**
41      * Returns a location name that is guaranteed to not be null.
42      *
43      * @return A non null location name.
44      */
45     public String getLocationName() {
46         String name = locationName;
47         return (name != null) ? name : "";
48     }
49
50     /**
51      * Returns a serial number that is guaranteed to not be null.
52      *
53      * @return A non null serial number.
54      */
55     public String getSerialNo() {
56         String serial = serialno;
57         if (serial != null) {
58             return serial;
59         }
60
61         return "";
62     }
63
64     /**
65      * Returns a firmware version that is guaranteed to not be null.
66      *
67      * @return A non null firmware version.
68      */
69     public String getFirmwareVersion() {
70         String fw = firmwareVersion;
71         if (fw != null) {
72             return fw;
73         }
74
75         return "";
76     }
77
78     public @Nullable String getModel() {
79         // model from cloud API
80         String m = model;
81         if (m != null) {
82             return m;
83         }
84
85         // model from local API
86         m = fwMode;
87         if (m != null) {
88             return m;
89         }
90
91         return null;
92     }
93
94     @Nullable
95     public String locationId;
96
97     @Nullable
98     public String locationName;
99
100     @Nullable
101     public String serialno;
102
103     @Nullable
104     public Double pm01; // The raw PM 1 value in ug
105
106     @Nullable
107     public Double pm02; // The raw PM 2.5 value in ug
108
109     @Nullable
110     public Double pm10; // The raw PM 10 value in ug
111
112     @Nullable
113     public Double pm003Count; // The number of particles with a diameter beyond 0.3 microns in 1 deciliter of air
114
115     @Nullable
116     public Double atmp; // The ambient temperature in celsius
117
118     @Nullable
119     public Double rhum; // The relative humidity in percent
120
121     @Nullable
122     public Double rco2; // The CO2 value in ppm
123
124     @Nullable
125     public Double tvoc; // The TVOC value in ppb, provided in case that the sensor delivers an absolute value
126
127     @Nullable
128     public Double tvocIndex; // The value of the TVOC index, sensor model dependent
129
130     @Nullable
131     public Double noxIndex; // The value of the NOx index, sensor model dependent
132
133     @Nullable
134     public Double wifi; // The wifi signal strength in dBm
135
136     @Nullable
137     public Integer datapoints; // The number of datapoints, present only for aggregated data
138
139     @Nullable
140     public String timestamp; // Timestamp of the measures in ISO 8601 format with UTC offset, e.g. 2022-03-28T12:07:40Z
141
142     @Nullable
143     public String firmwareVersion; // The firmware version running on the device, e.g. "9.2.6", not present for averages
144
145     @Nullable
146     public String ledMode; // co2, pm, off, default
147
148     @Nullable
149     public String ledCo2Threshold1;
150
151     @Nullable
152     public String ledCo2Threshold2;
153
154     @Nullable
155     public String ledCo2ThresholdEnd;
156
157     @Nullable
158     public Long boot; // Number of times sensor has uploaded data since last reboot
159
160     @Nullable
161     public String fwMode; // Model of sensor from local API
162
163     @Nullable
164     public String model; // Model of sensor from cloud API
165 }