forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[venstarthermostat] Venstar thermostat away mode enhancement (openhab…
…#10736) * [VENSTAR THERMOSTAT BINDING] ADD AWAY MODE Signed-off-by: Matthew Davies matthew.davies@skynet.be Signed-off-by: raveydavies <84205523+raveydavies@users.noreply.github.com> * [VENSTAR THERMOSTAT] FIXED COMMAND AWAY MODE Signed-off-by: Matthew Davies matthew.davies@skynet.be Signed-off-by: raveydavies <84205523+raveydavies@users.noreply.github.com> * VENSTAR THERMOSTAT AWAY MODE AFTER INITIAL COMMIT FEEDBACK This code includes the Away mode of the Venstar thermostat. It is updated following initial feedback and suggestions on my first version from @digitaldan. Signed-off-by: Matthew Davies <matthew.davies@skynet.be> Signed-off-by: raveydavies <84205523+raveydavies@users.noreply.github.com> * VENSTAR THERMOSTAT BINDING - INCLUDE AWAY MODE Removed the updateThermostat function, now have updateSettings and updateControls corresponding to local API URLs. Signed-off-by: Matthew Davies <matthew.davies@skynet.be> Signed-off-by: raveydavies <84205523+raveydavies@users.noreply.github.com> * VENSTAR THERMOSTAT AWAY MODE - Modification updated as per feedback 1 June 2021 Signed-off-by: Matthew Davies <matthew.davies@skynet.be> Signed-off-by: raveydavies <84205523+raveydavies@users.noreply.github.com> * VENSTAR THERMOSTAT AWAY MODE INCLUSION - UPDATED README Signed-off-by: Matthew Davies <matthew.davies@skynet.be> Signed-off-by: raveydavies <84205523+raveydavies@users.noreply.github.com>
- Loading branch information
1 parent
89496c7
commit d1052be
Showing
8 changed files
with
207 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...t/src/main/java/org/openhab/binding/venstarthermostat/internal/model/VenstarAwayMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.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)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
.../java/org/openhab/binding/venstarthermostat/internal/model/VenstarAwayModeSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters