import static org.openhab.binding.airvisualnode.internal.AirVisualNodeBindingConstants.*;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.airvisualnode.internal.handler.AirVisualNodeHandler;
import org.openhab.core.thing.Thing;
*
* @author Victor Antonovich - Initial contribution
*/
+@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.airvisualnode")
public class AirVisualNodeHandlerFactory extends BaseThingHandlerFactory {
*/
package org.openhab.binding.airvisualnode.internal.config;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
/**
* Configuration for AirVisual Node.
*
* @author Victor Antonovich - Initial contribution
*/
+@NonNullByDefault
public class AirVisualNodeConfig {
public static final String ADDRESS = "address";
- public String address;
+ public String address = "";
- public String username;
+ public String username = "";
- public String password;
+ public String password = "";
- public String share;
+ public String share = "";
public long refresh;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.airvisualnode.internal.AirVisualNodeBindingConstants;
import org.openhab.binding.airvisualnode.internal.config.AirVisualNodeConfig;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
*
* @author Victor Antonovich - Initial contribution
*/
+@NonNullByDefault
@Component(service = DiscoveryService.class)
public class AirVisualNodeDiscoveryService extends AbstractDiscoveryService {
private final Logger logger = LoggerFactory.getLogger(AirVisualNodeDiscoveryService.class);
+ private static final int REFRESH_MINUTES = 5;
public static final String AVISUAL_WORKGROUP_NAME = "MSHOME";
private static final Pattern AVISUAL_NAME_PATTERN = Pattern.compile("^AVISUAL-([^/]+)$");
- private ScheduledFuture<?> backgroundDiscoveryFuture;
+ private @Nullable ScheduledFuture<?> backgroundDiscoveryFuture;
public AirVisualNodeDiscoveryService() {
super(Collections.singleton(AirVisualNodeBindingConstants.THING_TYPE_AVNODE), 600, true);
@Override
protected void startBackgroundDiscovery() {
logger.debug("Starting background discovery");
- backgroundDiscoveryFuture = scheduler.scheduleWithFixedDelay(this::scan, 0, 5, TimeUnit.MINUTES);
+ ScheduledFuture<?> localDiscoveryFuture = backgroundDiscoveryFuture;
+ if (localDiscoveryFuture == null || localDiscoveryFuture.isCancelled()) {
+ backgroundDiscoveryFuture = scheduler.scheduleWithFixedDelay(this::scan, 0, REFRESH_MINUTES,
+ TimeUnit.MINUTES);
+ }
}
@Override
protected void stopBackgroundDiscovery() {
logger.debug("Stopping background discovery");
- cancelBackgroundDiscoveryFuture();
- super.stopBackgroundDiscovery();
- }
- private void cancelBackgroundDiscoveryFuture() {
- if (backgroundDiscoveryFuture != null && !backgroundDiscoveryFuture.isDone()) {
- backgroundDiscoveryFuture.cancel(true);
+ ScheduledFuture<?> localDiscoveryFuture = backgroundDiscoveryFuture;
+ if (localDiscoveryFuture != null) {
+ localDiscoveryFuture.cancel(true);
backgroundDiscoveryFuture = null;
}
}
String workgroupUrl = "smb://" + AVISUAL_WORKGROUP_NAME + "/";
workgroupMembers = new SmbFile(workgroupUrl).listFiles();
} catch (IOException e) {
- // Can't get workgroup member list
+ logger.debug("IOException while trying to get workgroup member list", e);
return;
}
// Extract the Node serial number from device name
String nodeSerialNumber = m.group(1);
+ if (nodeSerialNumber != null) {
+ logger.debug("Extracting the Node serial number failed");
+ return;
+ }
// The Node Thing UID is serial number converted to lower case
ThingUID thingUID = new ThingUID(AirVisualNodeBindingConstants.THING_TYPE_AVNODE,
nodeSerialNumber.toLowerCase());
// Create discovery result
String nodeAddress = nodeNbtAddress.getInetAddress().getHostAddress();
- DiscoveryResult result = DiscoveryResultBuilder.create(thingUID)
- .withProperty(AirVisualNodeConfig.ADDRESS, nodeAddress)
- .withRepresentationProperty(AirVisualNodeConfig.ADDRESS)
- .withLabel("AirVisual Node (" + nodeSerialNumber + ")").build();
- thingDiscovered(result);
+ if (nodeAddress != null) {
+ DiscoveryResult result = DiscoveryResultBuilder.create(thingUID)
+ .withProperty(AirVisualNodeConfig.ADDRESS, nodeAddress)
+ .withRepresentationProperty(AirVisualNodeConfig.ADDRESS)
+ .withLabel("AirVisual Node (" + nodeSerialNumber + ")").build();
+ thingDiscovered(result);
+ } else {
+ logger.debug("Getting the node address from the host failed");
+ }
} catch (UnknownHostException e) {
logger.debug("The Node address resolving failed ", e);
}
+
}
}
}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto;
+
+/**
+ * Date and time / timestamp data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class DateAndTime {
+
+ private String date;
+ private String time;
+ private String timestamp;
+
+ public DateAndTime(String date, String time, String timestamp) {
+ this.date = date;
+ this.time = time;
+ this.timestamp = timestamp;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ public String getTime() {
+ return time;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ public String getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(String timestamp) {
+ this.timestamp = timestamp;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * Interface for AirVisual and AirVisual Pro models measurements data
+ *
+ * @author Oleg Davydyuk - Initial contribution
+ */
+@NonNullByDefault
+public interface MeasurementsInterface {
+ int getCo2Ppm();
+
+ int getHumidityRH();
+
+ int getPm25AQICN();
+
+ int getPm25AQIUS();
+
+ float getPm01Ugm3();
+
+ float getPm10Ugm3();
+
+ float getPm25Ugm3();
+
+ float getTemperatureC();
+
+ float getTemperatureF();
+
+ int getVocPpb();
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.airvisualnode.internal.dto.airvisual.Settings;
+import org.openhab.binding.airvisualnode.internal.dto.airvisual.Status;
+
+/**
+ * Interface for AirVisual and AirVisual Pro models
+ *
+ * @author Oleg Davydyuk - Initial contribution
+ */
+@NonNullByDefault
+public interface NodeDataInterface {
+ DateAndTime getDateAndTime();
+
+ MeasurementsInterface getMeasurements();
+
+ String getSerialNumber();
+
+ Settings getSettings();
+
+ Status getStatus();
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto;
+
+/**
+ * Power saving time data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class PowerSavingTime {
+
+ private int hour;
+ private int minute;
+
+ public PowerSavingTime(int hour, int minute) {
+ this.hour = hour;
+ this.minute = minute;
+ }
+
+ public int getHour() {
+ return hour;
+ }
+
+ public void setHour(int hour) {
+ this.hour = hour;
+ }
+
+ public int getMinute() {
+ return minute;
+ }
+
+ public void setMinute(int minute) {
+ this.minute = minute;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto;
+
+/**
+ * Power saving time slot data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class PowerSavingTimeSlot {
+
+ private int hourOff;
+ private int hourOn;
+
+ public PowerSavingTimeSlot(int hourOff, int hourOn) {
+ this.hourOff = hourOff;
+ this.hourOn = hourOn;
+ }
+
+ public int getHourOff() {
+ return hourOff;
+ }
+
+ public void setHourOff(int hourOff) {
+ this.hourOff = hourOff;
+ }
+
+ public int getHourOn() {
+ return hourOn;
+ }
+
+ public void setHourOn(int hourOn) {
+ this.hourOn = hourOn;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisual;
+
+import org.openhab.binding.airvisualnode.internal.dto.MeasurementsInterface;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Measurements data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class Measurements implements MeasurementsInterface {
+
+ private int co2Ppm;
+ @SerializedName("humidity_RH")
+ private int humidityRH;
+ @SerializedName("pm25_AQICN")
+ private int pm25AQICN;
+ @SerializedName("pm25_AQIUS")
+ private int pm25AQIUS;
+ private float pm25Ugm3;
+ @SerializedName("temperature_C")
+ private float temperatureC;
+ @SerializedName("temperature_F")
+ private float temperatureF;
+ private int vocPpb;
+
+ public Measurements(int co2Ppm, int humidityRH, int pm25AQICN, int pm25AQIUS, float pm25Ugm3, float temperatureC,
+ float temperatureF, int vocPpb) {
+ this.co2Ppm = co2Ppm;
+ this.humidityRH = humidityRH;
+ this.pm25AQICN = pm25AQICN;
+ this.pm25AQIUS = pm25AQIUS;
+ this.pm25Ugm3 = pm25Ugm3;
+ this.temperatureC = temperatureC;
+ this.temperatureF = temperatureF;
+ this.vocPpb = vocPpb;
+ }
+
+ public int getCo2Ppm() {
+ return co2Ppm;
+ }
+
+ public void setCo2Ppm(int co2Ppm) {
+ this.co2Ppm = co2Ppm;
+ }
+
+ public int getHumidityRH() {
+ return humidityRH;
+ }
+
+ public void setHumidityRH(int humidityRH) {
+ this.humidityRH = humidityRH;
+ }
+
+ public int getPm25AQICN() {
+ return pm25AQICN;
+ }
+
+ public void setPm25AQICN(int pm25AQICN) {
+ this.pm25AQICN = pm25AQICN;
+ }
+
+ public int getPm25AQIUS() {
+ return pm25AQIUS;
+ }
+
+ public void setPm25AQIUS(int pm25AQIUS) {
+ this.pm25AQIUS = pm25AQIUS;
+ }
+
+ @Override
+ public float getPm01Ugm3() {
+ return 0;
+ }
+
+ @Override
+ public float getPm10Ugm3() {
+ return 0;
+ }
+
+ public float getPm25Ugm3() {
+ return pm25Ugm3;
+ }
+
+ public void setPm25Ugm3(float pm25Ugm3) {
+ this.pm25Ugm3 = pm25Ugm3;
+ }
+
+ public float getTemperatureC() {
+ return temperatureC;
+ }
+
+ public void setTemperatureC(float temperatureC) {
+ this.temperatureC = temperatureC;
+ }
+
+ public float getTemperatureF() {
+ return temperatureF;
+ }
+
+ public void setTemperatureF(float temperatureF) {
+ this.temperatureF = temperatureF;
+ }
+
+ public int getVocPpb() {
+ return vocPpb;
+ }
+
+ public void setVocPpb(int vocPpb) {
+ this.vocPpb = vocPpb;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisual;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.airvisualnode.internal.dto.DateAndTime;
+import org.openhab.binding.airvisualnode.internal.dto.MeasurementsInterface;
+import org.openhab.binding.airvisualnode.internal.dto.NodeDataInterface;
+
+/**
+ * Top level object for AirVisual Node JSON data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+@NonNullByDefault
+public class NodeData implements NodeDataInterface {
+
+ private DateAndTime dateAndTime;
+ private Measurements measurements;
+ private String serialNumber;
+ private Settings settings;
+ private Status status;
+
+ public NodeData(DateAndTime dateAndTime, Measurements measurements, String serialNumber, Settings settings,
+ Status status) {
+ this.dateAndTime = dateAndTime;
+ this.measurements = measurements;
+ this.serialNumber = serialNumber;
+ this.settings = settings;
+ this.status = status;
+ }
+
+ public DateAndTime getDateAndTime() {
+ return dateAndTime;
+ }
+
+ public void setDateAndTime(DateAndTime dateAndTime) {
+ this.dateAndTime = dateAndTime;
+ }
+
+ public MeasurementsInterface getMeasurements() {
+ return measurements;
+ }
+
+ public void setMeasurements(Measurements measurements) {
+ this.measurements = measurements;
+ }
+
+ public String getSerialNumber() {
+ return serialNumber;
+ }
+
+ public void setSerialNumber(String serialNumber) {
+ this.serialNumber = serialNumber;
+ }
+
+ public Settings getSettings() {
+ return settings;
+ }
+
+ public void setSettings(Settings settings) {
+ this.settings = settings;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisual;
+
+import java.util.List;
+
+import org.openhab.binding.airvisualnode.internal.dto.PowerSavingTime;
+import org.openhab.binding.airvisualnode.internal.dto.PowerSavingTimeSlot;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Power saving data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class PowerSaving {
+
+ @SerializedName("2slots")
+ private List<PowerSavingTimeSlot> timeSlots = null;
+ private String mode;
+ @SerializedName("yes")
+ private List<PowerSavingTime> times = null;
+
+ public PowerSaving(List<PowerSavingTimeSlot> timeSlots, String mode, List<PowerSavingTime> times) {
+ this.mode = mode;
+ this.times = times;
+ this.timeSlots = timeSlots;
+ }
+
+ public List<PowerSavingTimeSlot> getTimeSlots() {
+ return timeSlots;
+ }
+
+ public void setTimeSlots(List<PowerSavingTimeSlot> timeSlots) {
+ this.timeSlots = timeSlots;
+ }
+
+ public List<PowerSavingTime> getTimes() {
+ return times;
+ }
+
+ public void setTimes(List<PowerSavingTime> times) {
+ this.times = times;
+ }
+
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisual;
+
+/**
+ * Settings data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class Settings {
+
+ private String followedStation;
+ private boolean isAqiUsa;
+ private boolean isConcentrationShowed;
+ private boolean isIndoor;
+ private boolean isLcdOn;
+ private boolean isNetworkTime;
+ private boolean isTemperatureCelsius;
+ private String language;
+ private int lcdBrightness;
+ private String nodeName;
+ private PowerSaving powerSaving;
+ private String speedUnit;
+ private String timezone;
+
+ public Settings(String followedStation, boolean isAqiUsa, boolean isConcentrationShowed, boolean isIndoor,
+ boolean isLcdOn, boolean isNetworkTime, boolean isTemperatureCelsius, String language, int lcdBrightness,
+ String nodeName, PowerSaving powerSaving, String speedUnit, String timezone) {
+ this.followedStation = followedStation;
+ this.isAqiUsa = isAqiUsa;
+ this.isConcentrationShowed = isConcentrationShowed;
+ this.isIndoor = isIndoor;
+ this.isLcdOn = isLcdOn;
+ this.isNetworkTime = isNetworkTime;
+ this.isTemperatureCelsius = isTemperatureCelsius;
+ this.language = language;
+ this.lcdBrightness = lcdBrightness;
+ this.nodeName = nodeName;
+ this.powerSaving = powerSaving;
+ this.speedUnit = speedUnit;
+ this.timezone = timezone;
+ }
+
+ public String getFollowedStation() {
+ return followedStation;
+ }
+
+ public void setFollowedStation(String followedStation) {
+ this.followedStation = followedStation;
+ }
+
+ public boolean isIsAqiUsa() {
+ return isAqiUsa;
+ }
+
+ public void setIsAqiUsa(boolean isAqiUsa) {
+ this.isAqiUsa = isAqiUsa;
+ }
+
+ public boolean isIsConcentrationShowed() {
+ return isConcentrationShowed;
+ }
+
+ public void setIsConcentrationShowed(boolean isConcentrationShowed) {
+ this.isConcentrationShowed = isConcentrationShowed;
+ }
+
+ public boolean isIsIndoor() {
+ return isIndoor;
+ }
+
+ public void setIsIndoor(boolean isIndoor) {
+ this.isIndoor = isIndoor;
+ }
+
+ public boolean isIsLcdOn() {
+ return isLcdOn;
+ }
+
+ public void setIsLcdOn(boolean isLcdOn) {
+ this.isLcdOn = isLcdOn;
+ }
+
+ public boolean isIsNetworkTime() {
+ return isNetworkTime;
+ }
+
+ public void setIsNetworkTime(boolean isNetworkTime) {
+ this.isNetworkTime = isNetworkTime;
+ }
+
+ public boolean isIsTemperatureCelsius() {
+ return isTemperatureCelsius;
+ }
+
+ public void setIsTemperatureCelsius(boolean isTemperatureCelsius) {
+ this.isTemperatureCelsius = isTemperatureCelsius;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public int getLcdBrightness() {
+ return lcdBrightness;
+ }
+
+ public void setLcdBrightness(int lcdBrightness) {
+ this.lcdBrightness = lcdBrightness;
+ }
+
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ public void setNodeName(String nodeName) {
+ this.nodeName = nodeName;
+ }
+
+ public PowerSaving getPowerSaving() {
+ return powerSaving;
+ }
+
+ public void setPowerSaving(PowerSaving powerSaving) {
+ this.powerSaving = powerSaving;
+ }
+
+ public String getSpeedUnit() {
+ return speedUnit;
+ }
+
+ public void setSpeedUnit(String speedUnit) {
+ this.speedUnit = speedUnit;
+ }
+
+ public String getTimezone() {
+ return timezone;
+ }
+
+ public void setTimezone(String timezone) {
+ this.timezone = timezone;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisual;
+
+/**
+ * Status data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class Status {
+
+ private String appVersion;
+ private int battery;
+ private long datetime;
+ private String model;
+ private String sensorPm25Serial;
+ private int syncTime;
+ private String systemVersion;
+ private int usedMemory;
+ private int wifiStrength;
+
+ public Status(String appVersion, int battery, long datetime, String model, String sensorPm25Serial, int syncTime,
+ String systemVersion, int usedMemory, int wifiStrength) {
+ this.appVersion = appVersion;
+ this.battery = battery;
+ this.datetime = datetime;
+ this.model = model;
+ this.sensorPm25Serial = sensorPm25Serial;
+ this.syncTime = syncTime;
+ this.systemVersion = systemVersion;
+ this.usedMemory = usedMemory;
+ this.wifiStrength = wifiStrength;
+ }
+
+ public String getAppVersion() {
+ return appVersion;
+ }
+
+ public void setAppVersion(String appVersion) {
+ this.appVersion = appVersion;
+ }
+
+ public int getBattery() {
+ return battery;
+ }
+
+ public void setBattery(int battery) {
+ this.battery = battery;
+ }
+
+ public long getDatetime() {
+ return datetime;
+ }
+
+ public void setDatetime(long datetime) {
+ this.datetime = datetime;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public String getSensorPm25Serial() {
+ return sensorPm25Serial;
+ }
+
+ public void setSensorPm25Serial(String sensorPm25Serial) {
+ this.sensorPm25Serial = sensorPm25Serial;
+ }
+
+ public int getSyncTime() {
+ return syncTime;
+ }
+
+ public void setSyncTime(int syncTime) {
+ this.syncTime = syncTime;
+ }
+
+ public String getSystemVersion() {
+ return systemVersion;
+ }
+
+ public void setSystemVersion(String systemVersion) {
+ this.systemVersion = systemVersion;
+ }
+
+ public int getUsedMemory() {
+ return usedMemory;
+ }
+
+ public void setUsedMemory(int usedMemory) {
+ this.usedMemory = usedMemory;
+ }
+
+ public int getWifiStrength() {
+ return wifiStrength;
+ }
+
+ public void setWifiStrength(int wifiStrength) {
+ this.wifiStrength = wifiStrength;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisualpro;
+
+import org.openhab.binding.airvisualnode.internal.dto.MeasurementsInterface;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Measurements data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class Measurements implements MeasurementsInterface {
+
+ @SerializedName("co2_ppm")
+ private int co2Ppm;
+
+ @SerializedName("humidity_RH")
+ private int humidityRH;
+
+ @SerializedName("pm25_AQICN")
+ private int pm25AQICN;
+
+ @SerializedName("pm25_AQIUS")
+ private int pm25AQIUS;
+
+ @SerializedName("pm01_ugm3")
+ private float pm01Ugm3;
+
+ @SerializedName("pm25_ugm3")
+ private float pm25Ugm3;
+
+ @SerializedName("pm10_ugm3")
+ private float pm10Ugm3;
+
+ @SerializedName("temperature_C")
+ private float temperatureC;
+
+ @SerializedName("temperature_F")
+ private float temperatureF;
+
+ private int vocPpb;
+
+ public Measurements(int co2Ppm, int humidityRH, int pm25AQICN, int pm25AQIUS, float pm01Ugm3, float pm10Ugm3,
+ float pm25Ugm3, float temperatureC, float temperatureF, int vocPpb) {
+ this.co2Ppm = co2Ppm;
+ this.humidityRH = humidityRH;
+ this.pm25AQICN = pm25AQICN;
+ this.pm25AQIUS = pm25AQIUS;
+ this.pm01Ugm3 = pm01Ugm3;
+ this.pm10Ugm3 = pm10Ugm3;
+ this.pm25Ugm3 = pm25Ugm3;
+ this.temperatureC = temperatureC;
+ this.temperatureF = temperatureF;
+ this.vocPpb = vocPpb;
+ }
+
+ public int getCo2Ppm() {
+ return co2Ppm;
+ }
+
+ public void setCo2Ppm(int co2Ppm) {
+ this.co2Ppm = co2Ppm;
+ }
+
+ public int getHumidityRH() {
+ return humidityRH;
+ }
+
+ public void setHumidityRH(int humidityRH) {
+ this.humidityRH = humidityRH;
+ }
+
+ public int getPm25AQICN() {
+ return pm25AQICN;
+ }
+
+ public void setPm25AQICN(int pm25AQICN) {
+ this.pm25AQICN = pm25AQICN;
+ }
+
+ public int getPm25AQIUS() {
+ return pm25AQIUS;
+ }
+
+ public void setPm25AQIUS(int pm25AQIUS) {
+ this.pm25AQIUS = pm25AQIUS;
+ }
+
+ public float getPm01Ugm3() {
+ return pm01Ugm3;
+ }
+
+ public void setPm01Ugm3(float pm01Ugm3) {
+ this.pm01Ugm3 = pm01Ugm3;
+ }
+
+ public float getPm10Ugm3() {
+ return pm10Ugm3;
+ }
+
+ public void setPm10Ugm3(float pm10Ugm3) {
+ this.pm10Ugm3 = pm10Ugm3;
+ }
+
+ public float getPm25Ugm3() {
+ return pm25Ugm3;
+ }
+
+ public void setPm25Ugm3(float pm25Ugm3) {
+ this.pm25Ugm3 = pm25Ugm3;
+ }
+
+ public float getTemperatureC() {
+ return temperatureC;
+ }
+
+ public void setTemperatureC(float temperatureC) {
+ this.temperatureC = temperatureC;
+ }
+
+ public float getTemperatureF() {
+ return temperatureF;
+ }
+
+ public void setTemperatureF(float temperatureF) {
+ this.temperatureF = temperatureF;
+ }
+
+ public int getVocPpb() {
+ return vocPpb;
+ }
+
+ public void setVocPpb(int vocPpb) {
+ this.vocPpb = vocPpb;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisualpro;
+
+import java.util.List;
+
+import org.openhab.binding.airvisualnode.internal.dto.PowerSavingTime;
+import org.openhab.binding.airvisualnode.internal.dto.PowerSavingTimeSlot;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Power saving data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class PowerSaving {
+
+ @SerializedName("2slots")
+ private List<PowerSavingTimeSlot> timeSlots = null;
+
+ private String mode;
+
+ private long runningTime;
+
+ @SerializedName("yes")
+ private List<PowerSavingTime> times = null;
+
+ public PowerSaving(List<PowerSavingTimeSlot> timeSlots, String mode, long runningTime,
+ List<PowerSavingTime> times) {
+ this.mode = mode;
+ this.runningTime = runningTime;
+ this.times = times;
+ this.timeSlots = timeSlots;
+ }
+
+ public List<PowerSavingTimeSlot> getTimeSlots() {
+ return timeSlots;
+ }
+
+ public void setTimeSlots(List<PowerSavingTimeSlot> timeSlots) {
+ this.timeSlots = timeSlots;
+ }
+
+ public List<PowerSavingTime> getTimes() {
+ return times;
+ }
+
+ public void setTimes(List<PowerSavingTime> times) {
+ this.times = times;
+ }
+
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
+ public long getRunningTime() {
+ return runningTime;
+ }
+
+ public void setRunningTime(long runningTime) {
+ this.runningTime = runningTime;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisualpro;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.airvisualnode.internal.dto.DateAndTime;
+import org.openhab.binding.airvisualnode.internal.dto.MeasurementsInterface;
+import org.openhab.binding.airvisualnode.internal.dto.NodeDataInterface;
+import org.openhab.binding.airvisualnode.internal.dto.airvisual.Settings;
+import org.openhab.binding.airvisualnode.internal.dto.airvisual.Status;
+
+/**
+ * Top level object for AirVisual Node JSON data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+@NonNullByDefault
+public class ProNodeData implements NodeDataInterface {
+
+ private DateAndTime dateAndTime;
+ private List<Measurements> measurements;
+ private String serialNumber;
+ private Settings settings;
+ private Status status;
+
+ public ProNodeData(DateAndTime dateAndTime, List<Measurements> measurements, String serialNumber, Settings settings,
+ Status status) {
+ this.dateAndTime = dateAndTime;
+ this.measurements = measurements;
+ this.serialNumber = serialNumber;
+ this.settings = settings;
+ this.status = status;
+ }
+
+ public DateAndTime getDateAndTime() {
+ return dateAndTime;
+ }
+
+ public void setDateAndTime(DateAndTime dateAndTime) {
+ this.dateAndTime = dateAndTime;
+ }
+
+ public MeasurementsInterface getMeasurements() {
+ return measurements.get(0);
+ }
+
+ public void setMeasurements(List<Measurements> measurements) {
+ this.measurements = measurements;
+ }
+
+ public String getSerialNumber() {
+ return serialNumber;
+ }
+
+ public void setSerialNumber(String serialNumber) {
+ this.serialNumber = serialNumber;
+ }
+
+ public Settings getSettings() {
+ return settings;
+ }
+
+ public void setSettings(Settings settings) {
+ this.settings = settings;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisualpro;
+
+/**
+ * Sensor Usage/Life data
+ *
+ * @author Oleg Davydyuk - Initial contribution
+ */
+public class SensorLife {
+
+ private long pm25;
+
+ public SensorLife(long pm25) {
+ this.pm25 = pm25;
+ }
+
+ public long getPm25() {
+ return pm25;
+ }
+
+ public void setPm25(long pm25) {
+ this.pm25 = pm25;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisualpro;
+
+/**
+ * Sensor Operating Mode
+ *
+ * @author Oleg Davydyuk - Initial contribution
+ */
+public class SensorMode {
+
+ private long customModeInterval;
+
+ private long mode;
+
+ public SensorMode(long customModeInterval, long mode) {
+ this.customModeInterval = customModeInterval;
+ this.mode = mode;
+ }
+
+ public long getCustomModeInterval() {
+ return customModeInterval;
+ }
+
+ public void setCustomModeInterval(long customModeInterval) {
+ this.customModeInterval = customModeInterval;
+ }
+
+ public long getMode() {
+ return mode;
+ }
+
+ public void setMode(long mode) {
+ this.mode = mode;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisualpro;
+
+import org.openhab.binding.airvisualnode.internal.dto.airvisual.PowerSaving;
+
+/**
+ * Settings data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class Settings {
+
+ private String followMode;
+ private String followedStation;
+ private boolean isAqiUsa;
+ private boolean isConcentrationShowed;
+ private boolean isIndoor;
+ private boolean isLcdOn;
+ private boolean isNetworkTime;
+ private boolean isTemperatureCelsius;
+ private String language;
+ private int lcdBrightness;
+ private String nodeName;
+ private PowerSaving powerSaving;
+ private SensorMode sensorMode;
+ private String speedUnit;
+ private String timezone;
+
+ public Settings(String followMode, String followedStation, boolean isAqiUsa, boolean isConcentrationShowed,
+ boolean isIndoor, boolean isLcdOn, boolean isNetworkTime, boolean isTemperatureCelsius, String language,
+ int lcdBrightness, String nodeName, PowerSaving powerSaving, SensorMode sensorMode, String speedUnit,
+ String timezone) {
+ this.followMode = followMode;
+ this.followedStation = followedStation;
+ this.isAqiUsa = isAqiUsa;
+ this.isConcentrationShowed = isConcentrationShowed;
+ this.isIndoor = isIndoor;
+ this.isLcdOn = isLcdOn;
+ this.isNetworkTime = isNetworkTime;
+ this.isTemperatureCelsius = isTemperatureCelsius;
+ this.language = language;
+ this.lcdBrightness = lcdBrightness;
+ this.nodeName = nodeName;
+ this.powerSaving = powerSaving;
+ this.sensorMode = sensorMode;
+ this.speedUnit = speedUnit;
+ this.timezone = timezone;
+ }
+
+ public String getFollowMode() {
+ return followMode;
+ }
+
+ public void setFollowMode(String followMode) {
+ this.followMode = followMode;
+ }
+
+ public String getFollowedStation() {
+ return followedStation;
+ }
+
+ public void setFollowedStation(String followedStation) {
+ this.followedStation = followedStation;
+ }
+
+ public boolean isIsAqiUsa() {
+ return isAqiUsa;
+ }
+
+ public void setIsAqiUsa(boolean isAqiUsa) {
+ this.isAqiUsa = isAqiUsa;
+ }
+
+ public boolean isIsConcentrationShowed() {
+ return isConcentrationShowed;
+ }
+
+ public void setIsConcentrationShowed(boolean isConcentrationShowed) {
+ this.isConcentrationShowed = isConcentrationShowed;
+ }
+
+ public boolean isIsIndoor() {
+ return isIndoor;
+ }
+
+ public void setIsIndoor(boolean isIndoor) {
+ this.isIndoor = isIndoor;
+ }
+
+ public boolean isIsLcdOn() {
+ return isLcdOn;
+ }
+
+ public void setIsLcdOn(boolean isLcdOn) {
+ this.isLcdOn = isLcdOn;
+ }
+
+ public boolean isIsNetworkTime() {
+ return isNetworkTime;
+ }
+
+ public void setIsNetworkTime(boolean isNetworkTime) {
+ this.isNetworkTime = isNetworkTime;
+ }
+
+ public boolean isIsTemperatureCelsius() {
+ return isTemperatureCelsius;
+ }
+
+ public void setIsTemperatureCelsius(boolean isTemperatureCelsius) {
+ this.isTemperatureCelsius = isTemperatureCelsius;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public int getLcdBrightness() {
+ return lcdBrightness;
+ }
+
+ public void setLcdBrightness(int lcdBrightness) {
+ this.lcdBrightness = lcdBrightness;
+ }
+
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ public void setNodeName(String nodeName) {
+ this.nodeName = nodeName;
+ }
+
+ public PowerSaving getPowerSaving() {
+ return powerSaving;
+ }
+
+ public void setPowerSaving(PowerSaving powerSaving) {
+ this.powerSaving = powerSaving;
+ }
+
+ public String getSpeedUnit() {
+ return speedUnit;
+ }
+
+ public void setSpeedUnit(String speedUnit) {
+ this.speedUnit = speedUnit;
+ }
+
+ public String getTimezone() {
+ return timezone;
+ }
+
+ public void setTimezone(String timezone) {
+ this.timezone = timezone;
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.airvisualnode.internal.dto.airvisualpro;
+
+/**
+ * Status data.
+ *
+ * @author Victor Antonovich - Initial contribution
+ */
+public class Status {
+
+ private String appVersion;
+ private int battery;
+ private long datetime;
+ private String deviceName;
+ private String ipAddress;
+ private String macAddress;
+ private String model;
+ private SensorLife sensorLife;
+ private String sensorPm25Serial;
+ private int syncTime;
+ private String systemVersion;
+ private int usedMemory;
+ private int wifiStrength;
+
+ public Status(String appVersion, int battery, long datetime, String deviceName, String ipAddress, String macAddress,
+ String model, SensorLife sensorLife, String sensorPm25Serial, int syncTime, String systemVersion,
+ int usedMemory, int wifiStrength) {
+ this.appVersion = appVersion;
+ this.battery = battery;
+ this.datetime = datetime;
+ this.deviceName = deviceName;
+ this.ipAddress = ipAddress;
+ this.macAddress = macAddress;
+ this.model = model;
+ this.sensorLife = sensorLife;
+ this.sensorPm25Serial = sensorPm25Serial;
+ this.syncTime = syncTime;
+ this.systemVersion = systemVersion;
+ this.usedMemory = usedMemory;
+ this.wifiStrength = wifiStrength;
+ }
+
+ public String getAppVersion() {
+ return appVersion;
+ }
+
+ public void setAppVersion(String appVersion) {
+ this.appVersion = appVersion;
+ }
+
+ public int getBattery() {
+ return battery;
+ }
+
+ public void setBattery(int battery) {
+ this.battery = battery;
+ }
+
+ public long getDatetime() {
+ return datetime;
+ }
+
+ public void setDatetime(long datetime) {
+ this.datetime = datetime;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ public void setMacAddress(String macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public SensorLife getSensorLife() {
+ return sensorLife;
+ }
+
+ public void setSensorLife(SensorLife sensorLife) {
+ this.sensorLife = sensorLife;
+ }
+
+ public String getSensorPm25Serial() {
+ return sensorPm25Serial;
+ }
+
+ public void setSensorPm25Serial(String sensorPm25Serial) {
+ this.sensorPm25Serial = sensorPm25Serial;
+ }
+
+ public int getSyncTime() {
+ return syncTime;
+ }
+
+ public void setSyncTime(int syncTime) {
+ this.syncTime = syncTime;
+ }
+
+ public String getSystemVersion() {
+ return systemVersion;
+ }
+
+ public void setSystemVersion(String systemVersion) {
+ this.systemVersion = systemVersion;
+ }
+
+ public int getUsedMemory() {
+ return usedMemory;
+ }
+
+ public void setUsedMemory(int usedMemory) {
+ this.usedMemory = usedMemory;
+ }
+
+ public int getWifiStrength() {
+ return wifiStrength;
+ }
+
+ public void setWifiStrength(int wifiStrength) {
+ this.wifiStrength = wifiStrength;
+ }
+}
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.airvisualnode.internal.config.AirVisualNodeConfig;
-import org.openhab.binding.airvisualnode.internal.json.MeasurementsInterface;
-import org.openhab.binding.airvisualnode.internal.json.NodeDataInterface;
-import org.openhab.binding.airvisualnode.internal.json.airvisual.NodeData;
-import org.openhab.binding.airvisualnode.internal.json.airvisualpro.ProNodeData;
+import org.openhab.binding.airvisualnode.internal.dto.MeasurementsInterface;
+import org.openhab.binding.airvisualnode.internal.dto.NodeDataInterface;
+import org.openhab.binding.airvisualnode.internal.dto.airvisual.NodeData;
+import org.openhab.binding.airvisualnode.internal.dto.airvisualpro.ProNodeData;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.QuantityType;
*
* @author Victor Antonovich - Initial contribution
*/
+@NonNullByDefault
public class AirVisualNodeHandler extends BaseThingHandler {
private final Logger logger = LoggerFactory.getLogger(AirVisualNodeHandler.class);
public static final String NODE_JSON_FILE = "latest_config_measurements.json";
+ private static final long DELAY_IN_MS = 500;
private final Gson gson;
-
- private ScheduledFuture<?> pollFuture;
-
+ private @Nullable ScheduledFuture<?> pollFuture;
private long refreshInterval;
-
- private String nodeAddress;
-
- private String nodeUsername;
-
- private String nodePassword;
-
- private String nodeShareName;
-
- private NodeDataInterface nodeData;
-
- private boolean isProVersion;
+ private String nodeAddress = "";
+ private String nodeUsername = "";
+ private String nodePassword = "";
+ private String nodeShareName = "";
+ private @Nullable NodeDataInterface nodeData;
+ private boolean isProVersion = false;
public AirVisualNodeHandler(Thing thing) {
super(thing);
AirVisualNodeConfig config = getConfigAs(AirVisualNodeConfig.class);
- if (config.address == null) {
+ if (config.address.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Node address must be set");
return;
}
- this.nodeAddress = config.address;
-
- this.nodeUsername = config.username;
-
- if (config.password == null) {
+ if (config.password.isBlank()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Node password must be set");
return;
}
- this.nodePassword = config.password;
+ this.nodeAddress = config.address;
+ this.nodeUsername = config.username;
+ this.nodePassword = config.password;
this.nodeShareName = config.share;
-
this.refreshInterval = config.refresh * 1000L;
try {
private void removeProChannels() {
List<Channel> channels = new ArrayList<>(getThing().getChannels());
- channels.removeIf(channel -> channel.getLabel().equals("PM0.1") || channel.getLabel().equals("PM10"));
+ channels.removeIf(channel -> isProChannel(channel.getLabel()));
replaceChannels(channels);
}
+ private boolean isProChannel(@Nullable String channelLabel) {
+ if (channelLabel == null || channelLabel.isBlank()) {
+ return false;
+ }
+ return "PM0.1".equals(channelLabel) || "PM10".equals(channelLabel);
+ }
+
private void replaceChannels(List<Channel> channels) {
ThingBuilder thingBuilder = editThing();
thingBuilder.withChannels(channels);
}
private synchronized void stopPoll() {
- if (pollFuture != null && !pollFuture.isCancelled()) {
- pollFuture.cancel(false);
+ ScheduledFuture<?> localFuture = pollFuture;
+ if (localFuture != null) {
+ localFuture.cancel(false);
}
}
private synchronized void schedulePoll() {
- logger.debug("Scheduling poll for 500ms out, then every {} ms", refreshInterval);
- pollFuture = scheduler.scheduleWithFixedDelay(this::poll, 500, refreshInterval, TimeUnit.MILLISECONDS);
+ logger.debug("Scheduling poll for {}}ms out, then every {} ms", DELAY_IN_MS, refreshInterval);
+ pollFuture = scheduler.scheduleWithFixedDelay(this::poll, DELAY_IN_MS, refreshInterval, TimeUnit.MILLISECONDS);
}
private void poll() {
} else {
currentNodeData = gson.fromJson(jsonData, NodeData.class);
}
-
- if (nodeData == null || currentNodeData.getStatus().getDatetime() > nodeData.getStatus().getDatetime()) {
+ NodeDataInterface localNodeDate = nodeData;
+ if (localNodeDate == null
+ || currentNodeData.getStatus().getDatetime() > localNodeDate.getStatus().getDatetime()) {
nodeData = currentNodeData;
// Update all channels from the updated Node data
for (Channel channel : getThing().getChannels()) {
}
private void updateChannel(String channelId, boolean force) {
- if (nodeData != null && (force || isLinked(channelId))) {
- State state = getChannelState(channelId, nodeData);
+ NodeDataInterface localnodeData = nodeData;
+ if (localnodeData != null && (force || isLinked(channelId))) {
+ State state = getChannelState(channelId, localnodeData);
logger.debug("Update channel {} with state {}", channelId, state);
updateState(channelId, state);
}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json;
-
-/**
- * Date and time / timestamp data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class DateAndTime {
-
- private String date;
- private String time;
- private String timestamp;
-
- public DateAndTime(String date, String time, String timestamp) {
- this.date = date;
- this.time = time;
- this.timestamp = timestamp;
- }
-
- public String getDate() {
- return date;
- }
-
- public void setDate(String date) {
- this.date = date;
- }
-
- public String getTime() {
- return time;
- }
-
- public void setTime(String time) {
- this.time = time;
- }
-
- public String getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(String timestamp) {
- this.timestamp = timestamp;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-/**
- * Interface for AirVisual and AirVisual Pro models measurements data
- *
- * @author Oleg Davydyuk - Initial contribution
- */
-@NonNullByDefault
-public interface MeasurementsInterface {
- int getCo2Ppm();
-
- int getHumidityRH();
-
- int getPm25AQICN();
-
- int getPm25AQIUS();
-
- float getPm01Ugm3();
-
- float getPm10Ugm3();
-
- float getPm25Ugm3();
-
- float getTemperatureC();
-
- float getTemperatureF();
-
- int getVocPpb();
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.openhab.binding.airvisualnode.internal.json.airvisual.Settings;
-import org.openhab.binding.airvisualnode.internal.json.airvisual.Status;
-
-/**
- * Interface for AirVisual and AirVisual Pro models
- *
- * @author Oleg Davydyuk - Initial contribution
- */
-@NonNullByDefault
-public interface NodeDataInterface {
- DateAndTime getDateAndTime();
-
- MeasurementsInterface getMeasurements();
-
- String getSerialNumber();
-
- Settings getSettings();
-
- Status getStatus();
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json;
-
-/**
- * Power saving time data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class PowerSavingTime {
-
- private int hour;
- private int minute;
-
- public PowerSavingTime(int hour, int minute) {
- this.hour = hour;
- this.minute = minute;
- }
-
- public int getHour() {
- return hour;
- }
-
- public void setHour(int hour) {
- this.hour = hour;
- }
-
- public int getMinute() {
- return minute;
- }
-
- public void setMinute(int minute) {
- this.minute = minute;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json;
-
-/**
- * Power saving time slot data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class PowerSavingTimeSlot {
-
- private int hourOff;
- private int hourOn;
-
- public PowerSavingTimeSlot(int hourOff, int hourOn) {
- this.hourOff = hourOff;
- this.hourOn = hourOn;
- }
-
- public int getHourOff() {
- return hourOff;
- }
-
- public void setHourOff(int hourOff) {
- this.hourOff = hourOff;
- }
-
- public int getHourOn() {
- return hourOn;
- }
-
- public void setHourOn(int hourOn) {
- this.hourOn = hourOn;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisual;
-
-import org.openhab.binding.airvisualnode.internal.json.MeasurementsInterface;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Measurements data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class Measurements implements MeasurementsInterface {
-
- private int co2Ppm;
- @SerializedName("humidity_RH")
- private int humidityRH;
- @SerializedName("pm25_AQICN")
- private int pm25AQICN;
- @SerializedName("pm25_AQIUS")
- private int pm25AQIUS;
- private float pm25Ugm3;
- @SerializedName("temperature_C")
- private float temperatureC;
- @SerializedName("temperature_F")
- private float temperatureF;
- private int vocPpb;
-
- public Measurements(int co2Ppm, int humidityRH, int pm25AQICN, int pm25AQIUS, float pm25Ugm3, float temperatureC,
- float temperatureF, int vocPpb) {
- this.co2Ppm = co2Ppm;
- this.humidityRH = humidityRH;
- this.pm25AQICN = pm25AQICN;
- this.pm25AQIUS = pm25AQIUS;
- this.pm25Ugm3 = pm25Ugm3;
- this.temperatureC = temperatureC;
- this.temperatureF = temperatureF;
- this.vocPpb = vocPpb;
- }
-
- public int getCo2Ppm() {
- return co2Ppm;
- }
-
- public void setCo2Ppm(int co2Ppm) {
- this.co2Ppm = co2Ppm;
- }
-
- public int getHumidityRH() {
- return humidityRH;
- }
-
- public void setHumidityRH(int humidityRH) {
- this.humidityRH = humidityRH;
- }
-
- public int getPm25AQICN() {
- return pm25AQICN;
- }
-
- public void setPm25AQICN(int pm25AQICN) {
- this.pm25AQICN = pm25AQICN;
- }
-
- public int getPm25AQIUS() {
- return pm25AQIUS;
- }
-
- public void setPm25AQIUS(int pm25AQIUS) {
- this.pm25AQIUS = pm25AQIUS;
- }
-
- @Override
- public float getPm01Ugm3() {
- return 0;
- }
-
- @Override
- public float getPm10Ugm3() {
- return 0;
- }
-
- public float getPm25Ugm3() {
- return pm25Ugm3;
- }
-
- public void setPm25Ugm3(float pm25Ugm3) {
- this.pm25Ugm3 = pm25Ugm3;
- }
-
- public float getTemperatureC() {
- return temperatureC;
- }
-
- public void setTemperatureC(float temperatureC) {
- this.temperatureC = temperatureC;
- }
-
- public float getTemperatureF() {
- return temperatureF;
- }
-
- public void setTemperatureF(float temperatureF) {
- this.temperatureF = temperatureF;
- }
-
- public int getVocPpb() {
- return vocPpb;
- }
-
- public void setVocPpb(int vocPpb) {
- this.vocPpb = vocPpb;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisual;
-
-import org.openhab.binding.airvisualnode.internal.json.DateAndTime;
-import org.openhab.binding.airvisualnode.internal.json.MeasurementsInterface;
-import org.openhab.binding.airvisualnode.internal.json.NodeDataInterface;
-
-/**
- * Top level object for AirVisual Node JSON data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class NodeData implements NodeDataInterface {
-
- private DateAndTime dateAndTime;
- private Measurements measurements;
- private String serialNumber;
- private Settings settings;
- private Status status;
-
- public NodeData(DateAndTime dateAndTime, Measurements measurements, String serialNumber, Settings settings,
- Status status) {
- this.dateAndTime = dateAndTime;
- this.measurements = measurements;
- this.serialNumber = serialNumber;
- this.settings = settings;
- this.status = status;
- }
-
- public DateAndTime getDateAndTime() {
- return dateAndTime;
- }
-
- public void setDateAndTime(DateAndTime dateAndTime) {
- this.dateAndTime = dateAndTime;
- }
-
- public MeasurementsInterface getMeasurements() {
- return measurements;
- }
-
- public void setMeasurements(Measurements measurements) {
- this.measurements = measurements;
- }
-
- public String getSerialNumber() {
- return serialNumber;
- }
-
- public void setSerialNumber(String serialNumber) {
- this.serialNumber = serialNumber;
- }
-
- public Settings getSettings() {
- return settings;
- }
-
- public void setSettings(Settings settings) {
- this.settings = settings;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisual;
-
-import java.util.List;
-
-import org.openhab.binding.airvisualnode.internal.json.PowerSavingTime;
-import org.openhab.binding.airvisualnode.internal.json.PowerSavingTimeSlot;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Power saving data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class PowerSaving {
-
- @SerializedName("2slots")
- private List<PowerSavingTimeSlot> timeSlots = null;
- private String mode;
- @SerializedName("yes")
- private List<PowerSavingTime> times = null;
-
- public PowerSaving(List<PowerSavingTimeSlot> timeSlots, String mode, List<PowerSavingTime> times) {
- this.mode = mode;
- this.times = times;
- this.timeSlots = timeSlots;
- }
-
- public List<PowerSavingTimeSlot> getTimeSlots() {
- return timeSlots;
- }
-
- public void setTimeSlots(List<PowerSavingTimeSlot> timeSlots) {
- this.timeSlots = timeSlots;
- }
-
- public List<PowerSavingTime> getTimes() {
- return times;
- }
-
- public void setTimes(List<PowerSavingTime> times) {
- this.times = times;
- }
-
- public String getMode() {
- return mode;
- }
-
- public void setMode(String mode) {
- this.mode = mode;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisual;
-
-/**
- * Settings data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class Settings {
-
- private String followedStation;
- private boolean isAqiUsa;
- private boolean isConcentrationShowed;
- private boolean isIndoor;
- private boolean isLcdOn;
- private boolean isNetworkTime;
- private boolean isTemperatureCelsius;
- private String language;
- private int lcdBrightness;
- private String nodeName;
- private PowerSaving powerSaving;
- private String speedUnit;
- private String timezone;
-
- public Settings(String followedStation, boolean isAqiUsa, boolean isConcentrationShowed, boolean isIndoor,
- boolean isLcdOn, boolean isNetworkTime, boolean isTemperatureCelsius, String language, int lcdBrightness,
- String nodeName, PowerSaving powerSaving, String speedUnit, String timezone) {
- this.followedStation = followedStation;
- this.isAqiUsa = isAqiUsa;
- this.isConcentrationShowed = isConcentrationShowed;
- this.isIndoor = isIndoor;
- this.isLcdOn = isLcdOn;
- this.isNetworkTime = isNetworkTime;
- this.isTemperatureCelsius = isTemperatureCelsius;
- this.language = language;
- this.lcdBrightness = lcdBrightness;
- this.nodeName = nodeName;
- this.powerSaving = powerSaving;
- this.speedUnit = speedUnit;
- this.timezone = timezone;
- }
-
- public String getFollowedStation() {
- return followedStation;
- }
-
- public void setFollowedStation(String followedStation) {
- this.followedStation = followedStation;
- }
-
- public boolean isIsAqiUsa() {
- return isAqiUsa;
- }
-
- public void setIsAqiUsa(boolean isAqiUsa) {
- this.isAqiUsa = isAqiUsa;
- }
-
- public boolean isIsConcentrationShowed() {
- return isConcentrationShowed;
- }
-
- public void setIsConcentrationShowed(boolean isConcentrationShowed) {
- this.isConcentrationShowed = isConcentrationShowed;
- }
-
- public boolean isIsIndoor() {
- return isIndoor;
- }
-
- public void setIsIndoor(boolean isIndoor) {
- this.isIndoor = isIndoor;
- }
-
- public boolean isIsLcdOn() {
- return isLcdOn;
- }
-
- public void setIsLcdOn(boolean isLcdOn) {
- this.isLcdOn = isLcdOn;
- }
-
- public boolean isIsNetworkTime() {
- return isNetworkTime;
- }
-
- public void setIsNetworkTime(boolean isNetworkTime) {
- this.isNetworkTime = isNetworkTime;
- }
-
- public boolean isIsTemperatureCelsius() {
- return isTemperatureCelsius;
- }
-
- public void setIsTemperatureCelsius(boolean isTemperatureCelsius) {
- this.isTemperatureCelsius = isTemperatureCelsius;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public int getLcdBrightness() {
- return lcdBrightness;
- }
-
- public void setLcdBrightness(int lcdBrightness) {
- this.lcdBrightness = lcdBrightness;
- }
-
- public String getNodeName() {
- return nodeName;
- }
-
- public void setNodeName(String nodeName) {
- this.nodeName = nodeName;
- }
-
- public PowerSaving getPowerSaving() {
- return powerSaving;
- }
-
- public void setPowerSaving(PowerSaving powerSaving) {
- this.powerSaving = powerSaving;
- }
-
- public String getSpeedUnit() {
- return speedUnit;
- }
-
- public void setSpeedUnit(String speedUnit) {
- this.speedUnit = speedUnit;
- }
-
- public String getTimezone() {
- return timezone;
- }
-
- public void setTimezone(String timezone) {
- this.timezone = timezone;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisual;
-
-/**
- * Status data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class Status {
-
- private String appVersion;
- private int battery;
- private long datetime;
- private String model;
- private String sensorPm25Serial;
- private int syncTime;
- private String systemVersion;
- private int usedMemory;
- private int wifiStrength;
-
- public Status(String appVersion, int battery, long datetime, String model, String sensorPm25Serial, int syncTime,
- String systemVersion, int usedMemory, int wifiStrength) {
- this.appVersion = appVersion;
- this.battery = battery;
- this.datetime = datetime;
- this.model = model;
- this.sensorPm25Serial = sensorPm25Serial;
- this.syncTime = syncTime;
- this.systemVersion = systemVersion;
- this.usedMemory = usedMemory;
- this.wifiStrength = wifiStrength;
- }
-
- public String getAppVersion() {
- return appVersion;
- }
-
- public void setAppVersion(String appVersion) {
- this.appVersion = appVersion;
- }
-
- public int getBattery() {
- return battery;
- }
-
- public void setBattery(int battery) {
- this.battery = battery;
- }
-
- public long getDatetime() {
- return datetime;
- }
-
- public void setDatetime(long datetime) {
- this.datetime = datetime;
- }
-
- public String getModel() {
- return model;
- }
-
- public void setModel(String model) {
- this.model = model;
- }
-
- public String getSensorPm25Serial() {
- return sensorPm25Serial;
- }
-
- public void setSensorPm25Serial(String sensorPm25Serial) {
- this.sensorPm25Serial = sensorPm25Serial;
- }
-
- public int getSyncTime() {
- return syncTime;
- }
-
- public void setSyncTime(int syncTime) {
- this.syncTime = syncTime;
- }
-
- public String getSystemVersion() {
- return systemVersion;
- }
-
- public void setSystemVersion(String systemVersion) {
- this.systemVersion = systemVersion;
- }
-
- public int getUsedMemory() {
- return usedMemory;
- }
-
- public void setUsedMemory(int usedMemory) {
- this.usedMemory = usedMemory;
- }
-
- public int getWifiStrength() {
- return wifiStrength;
- }
-
- public void setWifiStrength(int wifiStrength) {
- this.wifiStrength = wifiStrength;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisualpro;
-
-import org.openhab.binding.airvisualnode.internal.json.MeasurementsInterface;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Measurements data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class Measurements implements MeasurementsInterface {
-
- @SerializedName("co2_ppm")
- private int co2Ppm;
-
- @SerializedName("humidity_RH")
- private int humidityRH;
-
- @SerializedName("pm25_AQICN")
- private int pm25AQICN;
-
- @SerializedName("pm25_AQIUS")
- private int pm25AQIUS;
-
- @SerializedName("pm01_ugm3")
- private float pm01Ugm3;
-
- @SerializedName("pm25_ugm3")
- private float pm25Ugm3;
-
- @SerializedName("pm10_ugm3")
- private float pm10Ugm3;
-
- @SerializedName("temperature_C")
- private float temperatureC;
-
- @SerializedName("temperature_F")
- private float temperatureF;
-
- private int vocPpb;
-
- public Measurements(int co2Ppm, int humidityRH, int pm25AQICN, int pm25AQIUS, float pm01Ugm3, float pm10Ugm3,
- float pm25Ugm3, float temperatureC, float temperatureF, int vocPpb) {
-
- this.co2Ppm = co2Ppm;
- this.humidityRH = humidityRH;
- this.pm25AQICN = pm25AQICN;
- this.pm25AQIUS = pm25AQIUS;
- this.pm01Ugm3 = pm01Ugm3;
- this.pm10Ugm3 = pm10Ugm3;
- this.pm25Ugm3 = pm25Ugm3;
- this.temperatureC = temperatureC;
- this.temperatureF = temperatureF;
- this.vocPpb = vocPpb;
- }
-
- public int getCo2Ppm() {
- return co2Ppm;
- }
-
- public void setCo2Ppm(int co2Ppm) {
- this.co2Ppm = co2Ppm;
- }
-
- public int getHumidityRH() {
- return humidityRH;
- }
-
- public void setHumidityRH(int humidityRH) {
- this.humidityRH = humidityRH;
- }
-
- public int getPm25AQICN() {
- return pm25AQICN;
- }
-
- public void setPm25AQICN(int pm25AQICN) {
- this.pm25AQICN = pm25AQICN;
- }
-
- public int getPm25AQIUS() {
- return pm25AQIUS;
- }
-
- public void setPm25AQIUS(int pm25AQIUS) {
- this.pm25AQIUS = pm25AQIUS;
- }
-
- public float getPm01Ugm3() {
- return pm01Ugm3;
- }
-
- public void setPm01Ugm3(float pm01Ugm3) {
- this.pm01Ugm3 = pm01Ugm3;
- }
-
- public float getPm10Ugm3() {
- return pm10Ugm3;
- }
-
- public void setPm10Ugm3(float pm10Ugm3) {
- this.pm10Ugm3 = pm10Ugm3;
- }
-
- public float getPm25Ugm3() {
- return pm25Ugm3;
- }
-
- public void setPm25Ugm3(float pm25Ugm3) {
- this.pm25Ugm3 = pm25Ugm3;
- }
-
- public float getTemperatureC() {
- return temperatureC;
- }
-
- public void setTemperatureC(float temperatureC) {
- this.temperatureC = temperatureC;
- }
-
- public float getTemperatureF() {
- return temperatureF;
- }
-
- public void setTemperatureF(float temperatureF) {
- this.temperatureF = temperatureF;
- }
-
- public int getVocPpb() {
- return vocPpb;
- }
-
- public void setVocPpb(int vocPpb) {
- this.vocPpb = vocPpb;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisualpro;
-
-import java.util.List;
-
-import org.openhab.binding.airvisualnode.internal.json.PowerSavingTime;
-import org.openhab.binding.airvisualnode.internal.json.PowerSavingTimeSlot;
-
-import com.google.gson.annotations.SerializedName;
-
-/**
- * Power saving data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class PowerSaving {
-
- @SerializedName("2slots")
- private List<PowerSavingTimeSlot> timeSlots = null;
-
- private String mode;
-
- private long runningTime;
-
- @SerializedName("yes")
- private List<PowerSavingTime> times = null;
-
- public PowerSaving(List<PowerSavingTimeSlot> timeSlots, String mode, long runningTime,
- List<PowerSavingTime> times) {
- this.mode = mode;
- this.runningTime = runningTime;
- this.times = times;
- this.timeSlots = timeSlots;
- }
-
- public List<PowerSavingTimeSlot> getTimeSlots() {
- return timeSlots;
- }
-
- public void setTimeSlots(List<PowerSavingTimeSlot> timeSlots) {
- this.timeSlots = timeSlots;
- }
-
- public List<PowerSavingTime> getTimes() {
- return times;
- }
-
- public void setTimes(List<PowerSavingTime> times) {
- this.times = times;
- }
-
- public String getMode() {
- return mode;
- }
-
- public void setMode(String mode) {
- this.mode = mode;
- }
-
- public long getRunningTime() {
- return runningTime;
- }
-
- public void setRunningTime(long runningTime) {
- this.runningTime = runningTime;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisualpro;
-
-import java.util.List;
-
-import org.openhab.binding.airvisualnode.internal.json.DateAndTime;
-import org.openhab.binding.airvisualnode.internal.json.MeasurementsInterface;
-import org.openhab.binding.airvisualnode.internal.json.NodeDataInterface;
-import org.openhab.binding.airvisualnode.internal.json.airvisual.Settings;
-import org.openhab.binding.airvisualnode.internal.json.airvisual.Status;
-
-/**
- * Top level object for AirVisual Node JSON data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class ProNodeData implements NodeDataInterface {
-
- private DateAndTime dateAndTime;
- private List<Measurements> measurements;
- private String serialNumber;
- private Settings settings;
- private Status status;
-
- public ProNodeData(DateAndTime dateAndTime, List<Measurements> measurements, String serialNumber, Settings settings,
- Status status) {
- this.dateAndTime = dateAndTime;
- this.measurements = measurements;
- this.serialNumber = serialNumber;
- this.settings = settings;
- this.status = status;
- }
-
- public DateAndTime getDateAndTime() {
- return dateAndTime;
- }
-
- public void setDateAndTime(DateAndTime dateAndTime) {
- this.dateAndTime = dateAndTime;
- }
-
- public MeasurementsInterface getMeasurements() {
- return measurements.get(0);
- }
-
- public void setMeasurements(List<Measurements> measurements) {
- this.measurements = measurements;
- }
-
- public String getSerialNumber() {
- return serialNumber;
- }
-
- public void setSerialNumber(String serialNumber) {
- this.serialNumber = serialNumber;
- }
-
- public Settings getSettings() {
- return settings;
- }
-
- public void setSettings(Settings settings) {
- this.settings = settings;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisualpro;
-
-/**
- * Sensor Usage/Life data
- *
- * @author Oleg Davydyuk - Initial contribution
- */
-public class SensorLife {
-
- private long pm25;
-
- public SensorLife(long pm25) {
- this.pm25 = pm25;
- }
-
- public long getPm25() {
- return pm25;
- }
-
- public void setPm25(long pm25) {
- this.pm25 = pm25;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisualpro;
-
-/**
- * Sensor Operating Mode
- *
- * @author Oleg Davydyuk - Initial contribution
- */
-public class SensorMode {
-
- private long customModeInterval;
-
- private long mode;
-
- public SensorMode(long customModeInterval, long mode) {
- this.customModeInterval = customModeInterval;
- this.mode = mode;
- }
-
- public long getCustomModeInterval() {
- return customModeInterval;
- }
-
- public void setCustomModeInterval(long customModeInterval) {
- this.customModeInterval = customModeInterval;
- }
-
- public long getMode() {
- return mode;
- }
-
- public void setMode(long mode) {
- this.mode = mode;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisualpro;
-
-import org.openhab.binding.airvisualnode.internal.json.airvisual.PowerSaving;
-
-/**
- * Settings data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class Settings {
-
- private String followMode;
- private String followedStation;
- private boolean isAqiUsa;
- private boolean isConcentrationShowed;
- private boolean isIndoor;
- private boolean isLcdOn;
- private boolean isNetworkTime;
- private boolean isTemperatureCelsius;
- private String language;
- private int lcdBrightness;
- private String nodeName;
- private PowerSaving powerSaving;
- private SensorMode sensorMode;
- private String speedUnit;
- private String timezone;
-
- public Settings(String followMode, String followedStation, boolean isAqiUsa, boolean isConcentrationShowed,
- boolean isIndoor, boolean isLcdOn, boolean isNetworkTime, boolean isTemperatureCelsius, String language,
- int lcdBrightness, String nodeName, PowerSaving powerSaving, SensorMode sensorMode, String speedUnit,
- String timezone) {
-
- this.followMode = followMode;
- this.followedStation = followedStation;
- this.isAqiUsa = isAqiUsa;
- this.isConcentrationShowed = isConcentrationShowed;
- this.isIndoor = isIndoor;
- this.isLcdOn = isLcdOn;
- this.isNetworkTime = isNetworkTime;
- this.isTemperatureCelsius = isTemperatureCelsius;
- this.language = language;
- this.lcdBrightness = lcdBrightness;
- this.nodeName = nodeName;
- this.powerSaving = powerSaving;
- this.sensorMode = sensorMode;
- this.speedUnit = speedUnit;
- this.timezone = timezone;
- }
-
- public String getFollowMode() {
- return followMode;
- }
-
- public void setFollowMode(String followMode) {
- this.followMode = followMode;
- }
-
- public String getFollowedStation() {
- return followedStation;
- }
-
- public void setFollowedStation(String followedStation) {
- this.followedStation = followedStation;
- }
-
- public boolean isIsAqiUsa() {
- return isAqiUsa;
- }
-
- public void setIsAqiUsa(boolean isAqiUsa) {
- this.isAqiUsa = isAqiUsa;
- }
-
- public boolean isIsConcentrationShowed() {
- return isConcentrationShowed;
- }
-
- public void setIsConcentrationShowed(boolean isConcentrationShowed) {
- this.isConcentrationShowed = isConcentrationShowed;
- }
-
- public boolean isIsIndoor() {
- return isIndoor;
- }
-
- public void setIsIndoor(boolean isIndoor) {
- this.isIndoor = isIndoor;
- }
-
- public boolean isIsLcdOn() {
- return isLcdOn;
- }
-
- public void setIsLcdOn(boolean isLcdOn) {
- this.isLcdOn = isLcdOn;
- }
-
- public boolean isIsNetworkTime() {
- return isNetworkTime;
- }
-
- public void setIsNetworkTime(boolean isNetworkTime) {
- this.isNetworkTime = isNetworkTime;
- }
-
- public boolean isIsTemperatureCelsius() {
- return isTemperatureCelsius;
- }
-
- public void setIsTemperatureCelsius(boolean isTemperatureCelsius) {
- this.isTemperatureCelsius = isTemperatureCelsius;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public int getLcdBrightness() {
- return lcdBrightness;
- }
-
- public void setLcdBrightness(int lcdBrightness) {
- this.lcdBrightness = lcdBrightness;
- }
-
- public String getNodeName() {
- return nodeName;
- }
-
- public void setNodeName(String nodeName) {
- this.nodeName = nodeName;
- }
-
- public PowerSaving getPowerSaving() {
- return powerSaving;
- }
-
- public void setPowerSaving(PowerSaving powerSaving) {
- this.powerSaving = powerSaving;
- }
-
- public String getSpeedUnit() {
- return speedUnit;
- }
-
- public void setSpeedUnit(String speedUnit) {
- this.speedUnit = speedUnit;
- }
-
- public String getTimezone() {
- return timezone;
- }
-
- public void setTimezone(String timezone) {
- this.timezone = timezone;
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2010-2022 Contributors to the openHAB project
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0
- *
- * SPDX-License-Identifier: EPL-2.0
- */
-package org.openhab.binding.airvisualnode.internal.json.airvisualpro;
-
-/**
- * Status data.
- *
- * @author Victor Antonovich - Initial contribution
- */
-public class Status {
-
- private String appVersion;
- private int battery;
- private long datetime;
- private String deviceName;
- private String ipAddress;
- private String macAddress;
- private String model;
- private SensorLife sensorLife;
- private String sensorPm25Serial;
- private int syncTime;
- private String systemVersion;
- private int usedMemory;
- private int wifiStrength;
-
- public Status(String appVersion, int battery, long datetime, String deviceName, String ipAddress, String macAddress,
- String model, SensorLife sensorLife, String sensorPm25Serial, int syncTime, String systemVersion,
- int usedMemory, int wifiStrength) {
- this.appVersion = appVersion;
- this.battery = battery;
- this.datetime = datetime;
- this.deviceName = deviceName;
- this.ipAddress = ipAddress;
- this.macAddress = macAddress;
- this.model = model;
- this.sensorLife = sensorLife;
- this.sensorPm25Serial = sensorPm25Serial;
- this.syncTime = syncTime;
- this.systemVersion = systemVersion;
- this.usedMemory = usedMemory;
- this.wifiStrength = wifiStrength;
- }
-
- public String getAppVersion() {
- return appVersion;
- }
-
- public void setAppVersion(String appVersion) {
- this.appVersion = appVersion;
- }
-
- public int getBattery() {
- return battery;
- }
-
- public void setBattery(int battery) {
- this.battery = battery;
- }
-
- public long getDatetime() {
- return datetime;
- }
-
- public void setDatetime(long datetime) {
- this.datetime = datetime;
- }
-
- public String getDeviceName() {
- return deviceName;
- }
-
- public void setDeviceName(String deviceName) {
- this.deviceName = deviceName;
- }
-
- public String getIpAddress() {
- return ipAddress;
- }
-
- public void setIpAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- public String getMacAddress() {
- return macAddress;
- }
-
- public void setMacAddress(String macAddress) {
- this.macAddress = macAddress;
- }
-
- public String getModel() {
- return model;
- }
-
- public void setModel(String model) {
- this.model = model;
- }
-
- public SensorLife getSensorLife() {
- return sensorLife;
- }
-
- public void setSensorLife(SensorLife sensorLife) {
- this.sensorLife = sensorLife;
- }
-
- public String getSensorPm25Serial() {
- return sensorPm25Serial;
- }
-
- public void setSensorPm25Serial(String sensorPm25Serial) {
- this.sensorPm25Serial = sensorPm25Serial;
- }
-
- public int getSyncTime() {
- return syncTime;
- }
-
- public void setSyncTime(int syncTime) {
- this.syncTime = syncTime;
- }
-
- public String getSystemVersion() {
- return systemVersion;
- }
-
- public void setSystemVersion(String systemVersion) {
- this.systemVersion = systemVersion;
- }
-
- public int getUsedMemory() {
- return usedMemory;
- }
-
- public void setUsedMemory(int usedMemory) {
- this.usedMemory = usedMemory;
- }
-
- public int getWifiStrength() {
- return wifiStrength;
- }
-
- public void setWifiStrength(int wifiStrength) {
- this.wifiStrength = wifiStrength;
- }
-}