]> git.basschouten.com Git - openhab-addons.git/commitdiff
[venstarthermostat] Use doubles over Int or float types when processing temperatures...
authorDan Cunningham <dan@digitaldan.com>
Sun, 6 Jun 2021 17:34:35 +0000 (10:34 -0700)
committerGitHub <noreply@github.com>
Sun, 6 Jun 2021 17:34:35 +0000 (19:34 +0200)
* Use a single numeric type (double), remove ints and floats

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
* Rebases with master.  Fixes All Checkstyle warning, renames package 'model' -> 'dto'

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
25 files changed:
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/VenstarThermostatBindingConstants.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/VenstarThermostatConfiguration.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/VenstarThermostatHandlerFactory.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/discovery/VenstarThermostatDiscoveryService.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarAwayMode.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarAwayModeSerializer.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarInfoData.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarResponse.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSensor.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSensorData.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemMode.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemModeSerializer.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemState.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemStateSerializer.java [new file with mode: 0644]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler/VenstarThermostatHandler.java
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarAwayMode.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarAwayModeSerializer.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarInfoData.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarResponse.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSensor.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSensorData.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemMode.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemModeSerializer.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemState.java [deleted file]
bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemStateSerializer.java [deleted file]

index 0c15359419bbc8bff4df25e60a0de87b0c3470df..87378b210b99069a86f65ae3959eed7c6ae1afce 100644 (file)
@@ -31,30 +31,30 @@ public class VenstarThermostatBindingConstants {
     public static final String BINDING_ID = "venstarthermostat";
 
     // List of all Thing Type UIDs
-    public final static ThingTypeUID THING_TYPE_COLOR_TOUCH = new ThingTypeUID(BINDING_ID, "colorTouchThermostat");
+    public static final ThingTypeUID THING_TYPE_COLOR_TOUCH = new ThingTypeUID(BINDING_ID, "colorTouchThermostat");
 
-    public final static Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_COLOR_TOUCH);
+    public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Collections.singleton(THING_TYPE_COLOR_TOUCH);
     // List of all Channel ids
-    public final static String CHANNEL_TEMPERATURE = "temperature";
-    public final static String CHANNEL_HUMIDITY = "humidity";
-    public final static String CHANNEL_EXTERNAL_TEMPERATURE = "outdoorTemperature";
-
-    public final static String CHANNEL_HEATING_SETPOINT = "heatingSetpoint";
-    public final static String CHANNEL_COOLING_SETPOINT = "coolingSetpoint";
-    public final static String CHANNEL_SYSTEM_STATE = "systemState";
-    public final static String CHANNEL_SYSTEM_MODE = "systemMode";
-    public final static String CHANNEL_SYSTEM_STATE_RAW = "systemStateRaw";
-    public final static String CHANNEL_SYSTEM_MODE_RAW = "systemModeRaw";
-    public final static String CHANNEL_AWAY_MODE = "awayMode";
-    public final static String CHANNEL_AWAY_MODE_RAW = "awayModeRaw";
-
-    public final static String CONFIG_USERNAME = "username";
-    public final static String CONFIG_PASSWORD = "password";
-    public final static String CONFIG_REFRESH = "refresh";
-
-    public final static String PROPERTY_URL = "url";
-    public final static String PROPERTY_UUID = "uuid";
-
-    public final static String REFRESH_INVALID = "refresh-invalid";
-    public final static String EMPTY_INVALID = "empty-invalid";
+    public static final String CHANNEL_TEMPERATURE = "temperature";
+    public static final String CHANNEL_HUMIDITY = "humidity";
+    public static final String CHANNEL_EXTERNAL_TEMPERATURE = "outdoorTemperature";
+
+    public static final String CHANNEL_HEATING_SETPOINT = "heatingSetpoint";
+    public static final String CHANNEL_COOLING_SETPOINT = "coolingSetpoint";
+    public static final String CHANNEL_SYSTEM_STATE = "systemState";
+    public static final String CHANNEL_SYSTEM_MODE = "systemMode";
+    public static final String CHANNEL_SYSTEM_STATE_RAW = "systemStateRaw";
+    public static final String CHANNEL_SYSTEM_MODE_RAW = "systemModeRaw";
+    public static final String CHANNEL_AWAY_MODE = "awayMode";
+    public static final String CHANNEL_AWAY_MODE_RAW = "awayModeRaw";
+
+    public static final String CONFIG_USERNAME = "username";
+    public static final String CONFIG_PASSWORD = "password";
+    public static final String CONFIG_REFRESH = "refresh";
+
+    public static final String PROPERTY_URL = "url";
+    public static final String PROPERTY_UUID = "uuid";
+
+    public static final String REFRESH_INVALID = "refresh-invalid";
+    public static final String EMPTY_INVALID = "empty-invalid";
 }
index bf82b5b4f3c1efd93f2b8ec353153575db85dabe..d17563bd8ba40b0bc3aea8c0067c114810af1f5d 100644 (file)
  */
 package org.openhab.binding.venstarthermostat.internal;
 
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
 /**
  * The {@link VenstarThermostatConfiguration} is responsible for holding configuration information.
  *
  * @author William Welliver - Initial contribution
  */
-
+@NonNullByDefault
 public class VenstarThermostatConfiguration {
-    public String username;
-    public String password;
-    public String url;
-    public Integer refresh;
+    public String username = "";
+    public String password = "";
+    public String url = "";
+    public Integer refresh = 30;
 }
index 23e7790ead370c511c9e385ecb80c688be7185de..092bb47a712582f2f46023a099a7b10b89b92e7e 100644 (file)
@@ -37,7 +37,7 @@ import org.osgi.service.component.annotations.Component;
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.venstarthermostat")
 public class VenstarThermostatHandlerFactory extends BaseThingHandlerFactory {
 
-    private final static Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_COLOR_TOUCH);
+    private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_COLOR_TOUCH);
 
     @Override
     public boolean supportsThingType(ThingTypeUID thingTypeUID) {
@@ -46,7 +46,6 @@ public class VenstarThermostatHandlerFactory extends BaseThingHandlerFactory {
 
     @Override
     protected @Nullable ThingHandler createHandler(Thing thing) {
-
         ThingTypeUID thingTypeUID = thing.getThingTypeUID();
 
         if (thingTypeUID.equals(THING_TYPE_COLOR_TOUCH)) {
index c2756fbb8749dc3789e495f4ac2c3f517e3d9ff9..60c66153b5cee91c446fe4ab625672f992a441eb 100644 (file)
@@ -29,6 +29,8 @@ import java.util.concurrent.TimeUnit;
 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.venstarthermostat.internal.VenstarThermostatBindingConstants;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
 import org.openhab.core.config.discovery.DiscoveryResult;
@@ -47,6 +49,7 @@ import org.slf4j.LoggerFactory;
  * @author Dan Cunningham - Refactoring and Improvements
  */
 
+@NonNullByDefault
 @Component(service = DiscoveryService.class, configurationPid = "discovery.venstarthermostat")
 public class VenstarThermostatDiscoveryService extends AbstractDiscoveryService {
     private final Logger logger = LoggerFactory.getLogger(VenstarThermostatDiscoveryService.class);
@@ -57,7 +60,7 @@ public class VenstarThermostatDiscoveryService extends AbstractDiscoveryService
     private static final String SSDP_MATCH = "colortouch:ecp";
     private static final int BACKGROUND_SCAN_INTERVAL_SECONDS = 300;
 
-    private ScheduledFuture<?> scheduledFuture = null;
+    private @Nullable ScheduledFuture<?> scheduledFuture = null;
 
     public VenstarThermostatDiscoveryService() {
         super(VenstarThermostatBindingConstants.SUPPORTED_THING_TYPES, 30, true);
@@ -67,14 +70,15 @@ public class VenstarThermostatDiscoveryService extends AbstractDiscoveryService
     protected void startBackgroundDiscovery() {
         logger.debug("Starting Background Scan");
         stopBackgroundDiscovery();
-        scheduledFuture = scheduler.scheduleAtFixedRate(this::doRunRun, 0, BACKGROUND_SCAN_INTERVAL_SECONDS,
+        scheduledFuture = scheduler.scheduleWithFixedDelay(this::doRunRun, 0, BACKGROUND_SCAN_INTERVAL_SECONDS,
                 TimeUnit.SECONDS);
     }
 
     @Override
     protected void stopBackgroundDiscovery() {
-        if (scheduledFuture != null && !scheduledFuture.isCancelled()) {
-            scheduledFuture.cancel(true);
+        ScheduledFuture<?> scheduledFutureLocal = scheduledFuture;
+        if (scheduledFutureLocal != null && !scheduledFutureLocal.isCancelled()) {
+            scheduledFutureLocal.cancel(true);
         }
     }
 
@@ -112,7 +116,7 @@ public class VenstarThermostatDiscoveryService extends AbstractDiscoveryService
      * @throws SocketException
      * @throws UnsupportedEncodingException
      */
-    private MulticastSocket sendDiscoveryBroacast(NetworkInterface ni)
+    private @Nullable MulticastSocket sendDiscoveryBroacast(NetworkInterface ni)
             throws UnknownHostException, SocketException, UnsupportedEncodingException {
         InetAddress m = InetAddress.getByName("239.255.255.250");
         final int port = 1900;
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarAwayMode.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarAwayMode.java
new file mode 100644 (file)
index 0000000..589929b
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+/**
+ * The {@link VenstarSystemMode} represents the value of the system mode returned
+ * from the REST API.
+ *
+ * @author Matthew Davies - Initial contribution
+ */
+public enum VenstarAwayMode {
+    HOME(0, "home", "Home"),
+    AWAY(1, "away", "Away");
+
+    private int mode;
+    private String name;
+    private String friendlyName;
+
+    VenstarAwayMode(int mode, String name, String friendlyName) {
+        this.mode = mode;
+        this.name = name;
+        this.friendlyName = friendlyName;
+    }
+
+    public int mode() {
+        return mode;
+    }
+
+    public String modeName() {
+        return name;
+    }
+
+    public String friendlyName() {
+        return friendlyName;
+    }
+
+    public static VenstarAwayMode fromInt(int mode) {
+        for (VenstarAwayMode am : values()) {
+            if (am.mode == mode) {
+                return am;
+            }
+        }
+
+        throw (new IllegalArgumentException("Invalid away mode " + mode));
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarAwayModeSerializer.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarAwayModeSerializer.java
new file mode 100644 (file)
index 0000000..8ae8188
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+import java.lang.reflect.Type;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+
+/**
+ * The {@link VenstarSystemModeSerializer} parses system mode values
+ * from the REST API JSON.
+ *
+ * @author Matthew Davies - Initial contribution
+ */
+public class VenstarAwayModeSerializer implements JsonDeserializer<VenstarAwayMode> {
+    @Override
+    public VenstarAwayMode deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2)
+            throws JsonParseException {
+        int key = element.getAsInt();
+        return VenstarAwayMode.fromInt(key);
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarInfoData.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarInfoData.java
new file mode 100644 (file)
index 0000000..b5a4aa9
--- /dev/null
@@ -0,0 +1,91 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+/**
+ * The {@link VenstarInfoData} represents a thermostat state from the REST API.
+ *
+ * @author William Welliver - Initial contribution
+ * @author Matthew Davies - added VenstarAwayMode to include away mode in binding
+ */
+public class VenstarInfoData {
+    double cooltemp;
+    double heattemp;
+
+    VenstarSystemState state;
+    VenstarSystemMode mode;
+    VenstarAwayMode away;
+    int tempunits;
+
+    public VenstarInfoData() {
+        super();
+    }
+
+    public VenstarInfoData(double cooltemp, double heattemp, VenstarSystemState state, VenstarSystemMode mode,
+            VenstarAwayMode away) {
+        super();
+        this.cooltemp = cooltemp;
+        this.heattemp = heattemp;
+        this.state = state;
+        this.mode = mode;
+        this.away = away;
+    }
+
+    public double getCooltemp() {
+        return cooltemp;
+    }
+
+    public void setCooltemp(double cooltemp) {
+        this.cooltemp = cooltemp;
+    }
+
+    public double getHeattemp() {
+        return heattemp;
+    }
+
+    public void setHeattemp(double heattemp) {
+        this.heattemp = heattemp;
+    }
+
+    public VenstarSystemState getState() {
+        return state;
+    }
+
+    public void setState(VenstarSystemState state) {
+        this.state = state;
+    }
+
+    public VenstarSystemMode getMode() {
+        return mode;
+    }
+
+    public void setMode(VenstarSystemMode mode) {
+        this.mode = mode;
+    }
+
+    public int getTempunits() {
+        return tempunits;
+    }
+
+    public void setTempunits(int tempunits) {
+        this.tempunits = tempunits;
+    }
+
+    public VenstarAwayMode getAway() {
+        return away;
+    }
+
+    public void setAwayMode(VenstarAwayMode away) {
+        this.away = away;
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarResponse.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarResponse.java
new file mode 100644 (file)
index 0000000..fe9045b
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+/**
+ * The {@link VenstarResponse} represents a response message from the REST API.
+ *
+ * @author William Welliver - Initial contribution
+ */
+public class VenstarResponse {
+
+    private boolean success;
+    private String reason;
+
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSensor.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSensor.java
new file mode 100644 (file)
index 0000000..77dc6e7
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+/**
+ * The {@link VenstarSensor} represents a sensor returned from the REST API.
+ *
+ * @author William Welliver - Initial contribution
+ */
+public class VenstarSensor {
+    String name;
+    double temp;
+    double hum;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public double getTemp() {
+        return temp;
+    }
+
+    public void setTemp(double temp) {
+        this.temp = temp;
+    }
+
+    public double getHum() {
+        return hum;
+    }
+
+    public void setHum(double hum) {
+        this.hum = hum;
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSensorData.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSensorData.java
new file mode 100644 (file)
index 0000000..dad79fd
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+import java.util.List;
+
+/**
+ * The {@link VenstarSensorData} represents sensor data returned from the REST API.
+ *
+ * @author William Welliver - Initial contribution
+ */
+public class VenstarSensorData {
+    List<VenstarSensor> sensors;
+
+    public List<VenstarSensor> getSensors() {
+        return sensors;
+    }
+
+    public void setSensors(List<VenstarSensor> sensors) {
+        this.sensors = sensors;
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemMode.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemMode.java
new file mode 100644 (file)
index 0000000..6803549
--- /dev/null
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+/**
+ * The {@link VenstarSystemMode} represents the value of the system mode returned
+ * from the REST API.
+ *
+ * @author William Welliver - Initial contribution
+ */
+public enum VenstarSystemMode {
+    OFF(0, "off", "Off"),
+    HEAT(1, "heat", "Heat"),
+    COOL(2, "cool", "Cool"),
+    AUTO(3, "auto", "Auto");
+
+    private int mode;
+    private String name;
+    private String friendlyName;
+
+    VenstarSystemMode(int mode, String name, String friendlyName) {
+        this.mode = mode;
+        this.name = name;
+        this.friendlyName = friendlyName;
+    }
+
+    public int mode() {
+        return mode;
+    }
+
+    public String modeName() {
+        return name;
+    }
+
+    public String friendlyName() {
+        return friendlyName;
+    }
+
+    public static VenstarSystemMode fromInt(int mode) {
+        for (VenstarSystemMode sm : values()) {
+            if (sm.mode == mode) {
+                return sm;
+            }
+        }
+
+        throw (new IllegalArgumentException("Invalid system mode " + mode));
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemModeSerializer.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemModeSerializer.java
new file mode 100644 (file)
index 0000000..cbb3a10
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+import java.lang.reflect.Type;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+
+/**
+ * The {@link VenstarSystemModeSerializer} parses system mode values
+ * from the REST API JSON.
+ *
+ * @author William Welliver - Initial contribution
+ */
+public class VenstarSystemModeSerializer implements JsonDeserializer<VenstarSystemMode> {
+    @Override
+    public VenstarSystemMode deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2)
+            throws JsonParseException {
+        int key = element.getAsInt();
+        return VenstarSystemMode.fromInt(key);
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemState.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemState.java
new file mode 100644 (file)
index 0000000..ec0e9e9
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+/**
+ * The {@link VenstarSystemState} represents the value of the system state
+ * returneda from the REST API.
+ *
+ * @author William Welliver - Initial contribution
+ */
+public enum VenstarSystemState {
+    IDLE(0, "idle", "Idle"),
+    HEATING(1, "heating", "Heating"),
+    COOLING(2, "cooling", "Cooling"),
+    LOCKOUT(3, "lockout", "Lockout"),
+    ERROR(4, "error", "Error");
+
+    private int state;
+    private String name;
+    private String friendlyName;
+
+    VenstarSystemState(int state, String name, String friendlyName) {
+        this.state = state;
+        this.name = name;
+        this.friendlyName = friendlyName;
+    }
+
+    public int state() {
+        return state;
+    }
+
+    public String stateName() {
+        return name;
+    }
+
+    public String friendlyName() {
+        return friendlyName;
+    }
+
+    public static VenstarSystemState fromInt(int state) {
+        for (VenstarSystemState ss : values()) {
+            if (ss.state == state) {
+                return ss;
+            }
+        }
+
+        throw (new IllegalArgumentException("Invalid system state " + state));
+    }
+}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemStateSerializer.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarSystemStateSerializer.java
new file mode 100644 (file)
index 0000000..f7e1798
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2010-2021 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.venstarthermostat.internal.dto;
+
+import java.lang.reflect.Type;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+
+/**
+ * The {@link VenstarSystemStateSerializer} parses system state values
+ * from the REST API JSON.
+ *
+ * @author William Welliver - Initial contribution
+ */
+public class VenstarSystemStateSerializer implements JsonDeserializer<VenstarSystemState> {
+    @Override
+    public VenstarSystemState deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2)
+            throws JsonParseException {
+        int key = element.getAsInt();
+        return VenstarSystemState.fromInt(key);
+    }
+}
index 3e21f20f64f93389ade51a2656a70f27538cdaa9..5041eaff9c06203ac02f831e2fe880c1a4f28d6e 100644 (file)
@@ -47,16 +47,16 @@ import org.eclipse.jetty.client.util.DigestAuthentication;
 import org.eclipse.jetty.http.HttpMethod;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.openhab.binding.venstarthermostat.internal.VenstarThermostatConfiguration;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarAwayMode;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarAwayModeSerializer;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarInfoData;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarResponse;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarSensor;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarSensorData;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarSystemMode;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarSystemModeSerializer;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarSystemState;
-import org.openhab.binding.venstarthermostat.internal.model.VenstarSystemStateSerializer;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarAwayMode;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarAwayModeSerializer;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarInfoData;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarResponse;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarSensor;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarSensorData;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarSystemMode;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarSystemModeSerializer;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarSystemState;
+import org.openhab.binding.venstarthermostat.internal.dto.VenstarSystemStateSerializer;
 import org.openhab.core.config.core.status.ConfigStatusMessage;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.QuantityType;
@@ -117,7 +117,6 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
         log.trace("VenstarThermostatHandler for thing {}", getThing().getUID());
     }
 
-    @SuppressWarnings("null") // compiler does not see conf.refresh == null check
     @Override
     public Collection<ConfigStatusMessage> getConfigStatus() {
         Collection<ConfigStatusMessage> status = new ArrayList<>();
@@ -134,7 +133,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
                     .withArguments(CONFIG_PASSWORD).build());
         }
 
-        if (config.refresh == null || config.refresh < 10) {
+        if (config.refresh < 10) {
             log.warn("refresh is too small: {}", config.refresh);
 
             status.add(ConfigStatusMessage.Builder.error(CONFIG_REFRESH).withMessageKeySuffix(REFRESH_INVALID)
@@ -145,7 +144,6 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
 
     @Override
     public void handleCommand(ChannelUID channelUID, Command command) {
-
         if (getThing().getStatus() != ThingStatus.ONLINE) {
             log.debug("Controller is NOT ONLINE and is not responding to commands");
             return;
@@ -160,12 +158,12 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
             stateMap.remove(channelUID.getAsString());
             if (channelUID.getId().equals(CHANNEL_HEATING_SETPOINT)) {
                 QuantityType<Temperature> quantity = commandToQuantityType(command, unitSystem);
-                int value = quantityToRoundedTemperature(quantity, unitSystem).intValue();
+                double value = quantityToRoundedTemperature(quantity, unitSystem).doubleValue();
                 log.debug("Setting heating setpoint to {}", value);
                 setHeatingSetpoint(value);
             } else if (channelUID.getId().equals(CHANNEL_COOLING_SETPOINT)) {
                 QuantityType<Temperature> quantity = commandToQuantityType(command, unitSystem);
-                int value = quantityToRoundedTemperature(quantity, unitSystem).intValue();
+                double value = quantityToRoundedTemperature(quantity, unitSystem).doubleValue();
                 log.debug("Setting cooling setpoint to {}", value);
                 setCoolingSetpoint(value);
             } else if (channelUID.getId().equals(CHANNEL_SYSTEM_MODE)) {
@@ -298,20 +296,20 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
         return UnDefType.UNDEF;
     }
 
-    private void setCoolingSetpoint(int cool) {
-        int heat = getHeatingSetpoint().intValue();
+    private void setCoolingSetpoint(double cool) {
+        double heat = getHeatingSetpoint().doubleValue();
         VenstarSystemMode mode = getSystemMode();
         updateControls(heat, cool, mode);
     }
 
     private void setSystemMode(VenstarSystemMode mode) {
-        int cool = getCoolingSetpoint().intValue();
-        int heat = getHeatingSetpoint().intValue();
+        double cool = getCoolingSetpoint().doubleValue();
+        double heat = getHeatingSetpoint().doubleValue();
         updateControls(heat, cool, mode);
     }
 
-    private void setHeatingSetpoint(int heat) {
-        int cool = getCoolingSetpoint().intValue();
+    private void setHeatingSetpoint(double heat) {
+        double cool = getCoolingSetpoint().doubleValue();
         VenstarSystemMode mode = getSystemMode();
         updateControls(heat, cool, mode);
     }
@@ -354,7 +352,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
         }
     }
 
-    private void updateControls(int heat, int cool, VenstarSystemMode mode) {
+    private void updateControls(double heat, double cool, VenstarSystemMode mode) {
         // this function corresponds to the thermostat local API POST /control instruction
         // the function can be expanded with other parameters which are changed via POST /control
         Map<String, String> params = new HashMap<>();
@@ -503,7 +501,6 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
             return content;
         } catch (InterruptedException | TimeoutException | ExecutionException e) {
             throw new VenstarCommunicationException(e);
-
         }
     }
 
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarAwayMode.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarAwayMode.java
deleted file mode 100644 (file)
index 8a2c496..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-/**
- * The {@link VenstarSystemMode} represents the value of the system mode returned
- * from the REST API.
- *
- * @author Matthew Davies - created new class to add away mode to binding
- */
-public enum VenstarAwayMode {
-    HOME(0, "home", "Home"),
-    AWAY(1, "away", "Away");
-
-    private int mode;
-    private String name;
-    private String friendlyName;
-
-    VenstarAwayMode(int mode, String name, String friendlyName) {
-        this.mode = mode;
-        this.name = name;
-        this.friendlyName = friendlyName;
-    }
-
-    public int mode() {
-        return mode;
-    }
-
-    public String modeName() {
-        return name;
-    }
-
-    public String friendlyName() {
-        return friendlyName;
-    }
-
-    public static VenstarAwayMode fromInt(int mode) {
-        for (VenstarAwayMode am : values()) {
-            if (am.mode == mode) {
-                return am;
-            }
-        }
-
-        throw (new IllegalArgumentException("Invalid away mode " + mode));
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarAwayModeSerializer.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarAwayModeSerializer.java
deleted file mode 100644 (file)
index 2130d4b..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-import java.lang.reflect.Type;
-
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-
-/**
- * The {@link VenstarSystemModeSerializer} parses system mode values
- * from the REST API JSON.
- *
- * @author Matthew Davies - created new class to include away mode in binding
- */
-public class VenstarAwayModeSerializer implements JsonDeserializer<VenstarAwayMode> {
-    @Override
-    public VenstarAwayMode deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2)
-            throws JsonParseException {
-        int key = element.getAsInt();
-        return VenstarAwayMode.fromInt(key);
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarInfoData.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarInfoData.java
deleted file mode 100644 (file)
index 6d9aeae..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-/**
- * The {@link VenstarInfoData} represents a thermostat state from the REST API.
- *
- * @author William Welliver - Initial contribution
- * @author Matthew Davies - added VenstarAwayMode to include away mode in binding
- */
-public class VenstarInfoData {
-    double cooltemp;
-    double heattemp;
-
-    VenstarSystemState state;
-    VenstarSystemMode mode;
-    VenstarAwayMode away;
-    int tempunits;
-
-    public VenstarInfoData() {
-        super();
-    }
-
-    public VenstarInfoData(double cooltemp, double heattemp, VenstarSystemState state, VenstarSystemMode mode,
-            VenstarAwayMode away) {
-        super();
-        this.cooltemp = cooltemp;
-        this.heattemp = heattemp;
-        this.state = state;
-        this.mode = mode;
-        this.away = away;
-    }
-
-    public double getCooltemp() {
-        return cooltemp;
-    }
-
-    public void setCooltemp(double cooltemp) {
-        this.cooltemp = cooltemp;
-    }
-
-    public double getHeattemp() {
-        return heattemp;
-    }
-
-    public void setHeattemp(double heattemp) {
-        this.heattemp = heattemp;
-    }
-
-    public VenstarSystemState getState() {
-        return state;
-    }
-
-    public void setState(VenstarSystemState state) {
-        this.state = state;
-    }
-
-    public VenstarSystemMode getMode() {
-        return mode;
-    }
-
-    public void setMode(VenstarSystemMode mode) {
-        this.mode = mode;
-    }
-
-    public int getTempunits() {
-        return tempunits;
-    }
-
-    public void setTempunits(int tempunits) {
-        this.tempunits = tempunits;
-    }
-
-    public VenstarAwayMode getAway() {
-        return away;
-    }
-
-    public void setAwayMode(VenstarAwayMode away) {
-        this.away = away;
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarResponse.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarResponse.java
deleted file mode 100644 (file)
index f3324ed..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-/**
- * The {@link VenstarResponse} represents a response message from the REST API.
- *
- * @author William Welliver - Initial contribution
- */
-public class VenstarResponse {
-
-    private boolean success;
-    private String reason;
-
-    public String getReason() {
-        return reason;
-    }
-
-    public void setReason(String reason) {
-        this.reason = reason;
-    }
-
-    public boolean isSuccess() {
-        return success;
-    }
-
-    public void setSuccess(boolean success) {
-        this.success = success;
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSensor.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSensor.java
deleted file mode 100644 (file)
index 6c4d75a..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-/**
- * The {@link VenstarSensor} represents a sensor returned from the REST API.
- *
- * @author William Welliver - Initial contribution
- */
-public class VenstarSensor {
-    String name;
-    float temp;
-    float hum;
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public float getTemp() {
-        return temp;
-    }
-
-    public void setTemp(float temp) {
-        this.temp = temp;
-    }
-
-    public float getHum() {
-        return hum;
-    }
-
-    public void setHum(float hum) {
-        this.hum = hum;
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSensorData.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSensorData.java
deleted file mode 100644 (file)
index 216d170..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-import java.util.List;
-
-/**
- * The {@link VenstarSensorData} represents sensor data returned from the REST API.
- *
- * @author William Welliver - Initial contribution
- */
-public class VenstarSensorData {
-    List<VenstarSensor> sensors;
-
-    public List<VenstarSensor> getSensors() {
-        return sensors;
-    }
-
-    public void setSensors(List<VenstarSensor> sensors) {
-        this.sensors = sensors;
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemMode.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemMode.java
deleted file mode 100644 (file)
index 5e93aaa..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-/**
- * The {@link VenstarSystemMode} represents the value of the system mode returned
- * from the REST API.
- *
- * @author William Welliver - Initial contribution
- */
-public enum VenstarSystemMode {
-    OFF(0, "off", "Off"),
-    HEAT(1, "heat", "Heat"),
-    COOL(2, "cool", "Cool"),
-    AUTO(3, "auto", "Auto");
-
-    private int mode;
-    private String name;
-    private String friendlyName;
-
-    VenstarSystemMode(int mode, String name, String friendlyName) {
-        this.mode = mode;
-        this.name = name;
-        this.friendlyName = friendlyName;
-    }
-
-    public int mode() {
-        return mode;
-    }
-
-    public String modeName() {
-        return name;
-    }
-
-    public String friendlyName() {
-        return friendlyName;
-    }
-
-    public static VenstarSystemMode fromInt(int mode) {
-        for (VenstarSystemMode sm : values()) {
-            if (sm.mode == mode) {
-                return sm;
-            }
-        }
-
-        throw (new IllegalArgumentException("Invalid system mode " + mode));
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemModeSerializer.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemModeSerializer.java
deleted file mode 100644 (file)
index dc75713..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-import java.lang.reflect.Type;
-
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-
-/**
- * The {@link VenstarSystemModeSerializer} parses system mode values
- * from the REST API JSON.
- *
- * @author William Welliver - Initial contribution
- */
-public class VenstarSystemModeSerializer implements JsonDeserializer<VenstarSystemMode> {
-    @Override
-    public VenstarSystemMode deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2)
-            throws JsonParseException {
-        int key = element.getAsInt();
-        return VenstarSystemMode.fromInt(key);
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemState.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemState.java
deleted file mode 100644 (file)
index 9f75e16..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-/**
- * The {@link VenstarSystemState} represents the value of the system state
- * returneda from the REST API.
- *
- * @author William Welliver - Initial contribution
- */
-public enum VenstarSystemState {
-    IDLE(0, "idle", "Idle"),
-    HEATING(1, "heating", "Heating"),
-    COOLING(2, "cooling", "Cooling"),
-    LOCKOUT(3, "lockout", "Lockout"),
-    ERROR(4, "error", "Error");
-
-    private int state;
-    private String name;
-    private String friendlyName;
-
-    VenstarSystemState(int state, String name, String friendlyName) {
-        this.state = state;
-        this.name = name;
-        this.friendlyName = friendlyName;
-    }
-
-    public int state() {
-        return state;
-    }
-
-    public String stateName() {
-        return name;
-    }
-
-    public String friendlyName() {
-        return friendlyName;
-    }
-
-    public static VenstarSystemState fromInt(int state) {
-        for (VenstarSystemState ss : values()) {
-            if (ss.state == state) {
-                return ss;
-            }
-        }
-
-        throw (new IllegalArgumentException("Invalid system state " + state));
-    }
-}
diff --git a/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemStateSerializer.java b/bundles/org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarSystemStateSerializer.java
deleted file mode 100644 (file)
index dbf2098..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (c) 2010-2021 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.venstarthermostat.internal.model;
-
-import java.lang.reflect.Type;
-
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-
-/**
- * The {@link VenstarSystemStateSerializer} parses system state values
- * from the REST API JSON.
- *
- * @author William Welliver - Initial contribution
- */
-public class VenstarSystemStateSerializer implements JsonDeserializer<VenstarSystemState> {
-    @Override
-    public VenstarSystemState deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2)
-            throws JsonParseException {
-        int key = element.getAsInt();
-        return VenstarSystemState.fromInt(key);
-    }
-}