-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[venstarthermostat] more functions issue enhancement 10823 (#11305)
* Adding several functions to binding to mimic local API Signed-off-by: raveydavies <[email protected]> * Adding functionality according to API Signed-off-by: raveydavies <[email protected]> * Updating Read me with new capability Signed-off-by: raveydavies <[email protected]> * Additional commit with requested changes to pull request Signed-off-by: raveydavies <[email protected]> * Updates to address all comments on previous commit. Signed-off-by: raveydavies <[email protected]> * Updates as requested in review. Signed-off-by: raveydavies <[email protected]> * Corrections for check style warnings Signed-off-by: raveydavies <[email protected]> * Updates to address feedback from lolodomo. Signed-off-by: raveydavies <[email protected]> * Changes to address feedback from lolodomo's review Signed-off-by: raveydavies <[email protected]> * FanState changed to Switch, Exception handling added as per review. Signed-off-by: raveydavies <[email protected]>
- Loading branch information
1 parent
82ac5ee
commit 6c6c93e
Showing
21 changed files
with
1,064 additions
and
78 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
59 changes: 59 additions & 0 deletions
59
...stat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarFanMode.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,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; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* The {@link VenstarFanMode} represents the value of the fan mode returned | ||
* from the REST API. | ||
* | ||
* @author Matthew Davies - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public enum VenstarFanMode { | ||
AUTO(0, "auto", "Auto"), | ||
ON(1, "on", "On"); | ||
|
||
private int mode; | ||
private String name; | ||
private String friendlyName; | ||
|
||
VenstarFanMode(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 VenstarFanMode fromInt(int mode) throws IllegalArgumentException { | ||
for (VenstarFanMode fm : values()) { | ||
if (fm.mode == mode) { | ||
return fm; | ||
} | ||
} | ||
|
||
throw (new IllegalArgumentException("Invalid fan mode " + mode)); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...ain/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarFanModeSerializer.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,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; | ||
|
||
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 VenstarFanModeSerializer} parses fan mode values | ||
* from the REST API JSON. | ||
* | ||
* @author Matthew Davies - Initial contribution | ||
*/ | ||
|
||
public class VenstarFanModeSerializer implements JsonDeserializer<VenstarFanMode> { | ||
@Override | ||
public VenstarFanMode deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2) | ||
throws JsonParseException { | ||
int key = element.getAsInt(); | ||
try { | ||
return VenstarFanMode.fromInt(key); | ||
} catch (IllegalArgumentException e) { | ||
throw new JsonParseException(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.