-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[venstarthermostat] Add more channels provided by the local API #11305
Merged
lolodomo
merged 10 commits into
openhab:main
from
raveydavies:venstar-binding-more-functions-issue-enhancement-10823
Dec 4, 2021
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
147646d
Adding several functions to binding to mimic local API
raveydavies 3bf1a74
Adding functionality according to API
raveydavies 415a47c
Updating Read me with new capability
raveydavies 2229467
Additional commit with requested changes to pull request
raveydavies d37477e
Updates to address all comments on previous commit.
raveydavies e2367d9
Updates as requested in review.
raveydavies 583fe4a
Corrections for check style warnings
raveydavies 04e0dee
Updates to address feedback from lolodomo.
raveydavies fef9759
Changes to address feedback from lolodomo's review
raveydavies f1c81d3
FanState changed to Switch, Exception handling added as per review.
raveydavies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
56 changes: 56 additions & 0 deletions
56
...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,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 | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* from the REST API. | ||
* | ||
* @author Matthew Davies - Initial contribution | ||
*/ | ||
public enum VenstarFanMode { | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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) { | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (VenstarFanMode fm : values()) { | ||
if (fm.mode == mode) { | ||
return fm; | ||
} | ||
} | ||
|
||
throw (new IllegalArgumentException("Invalid fan mode " + mode)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...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,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 | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* from the REST API JSON. | ||
* | ||
* @author Matthew Davies - Initial contribution | ||
*/ | ||
public class VenstarFanModeSerializer implements JsonDeserializer<VenstarFanMode> { | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@Override | ||
public VenstarFanMode deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2) | ||
throws JsonParseException { | ||
int key = element.getAsInt(); | ||
return VenstarFanMode.fromInt(key); | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...tat/src/main/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarFanState.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.dto; | ||
|
||
/** | ||
* The {@link VenstarSystemMode} represents the value of the system mode returned | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* from the REST API. | ||
* | ||
* @author Matthew Davies - Initial contribution | ||
*/ | ||
public enum VenstarFanState { | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
OFF(0, "off", "Off"), | ||
ON(1, "on", "On"); | ||
|
||
private int state; | ||
private String name; | ||
private String friendlyName; | ||
|
||
VenstarFanState(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 VenstarFanState fromInt(int state) { | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (VenstarFanState fs : values()) { | ||
if (fs.state == state) { | ||
return fs; | ||
} | ||
} | ||
|
||
throw (new IllegalArgumentException("Invalid fan state " + state)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...in/java/org/openhab/binding/venstarthermostat/internal/dto/VenstarFanStateSerializer.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.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 | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* from the REST API JSON. | ||
* | ||
* @author Matthew Davies - Initial contribution | ||
*/ | ||
public class VenstarFanStateSerializer implements JsonDeserializer<VenstarFanState> { | ||
lolodomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@Override | ||
public VenstarFanState deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2) | ||
throws JsonParseException { | ||
int key = element.getAsInt(); | ||
return VenstarFanState.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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit, i would replace all the
RT
abbreviations withRuntime
to make this more clear to usersThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I will update it. By the way, how does this formatting of a table in Markdown (in Eclipse) work? Is there a tutorial on it somewhere? I'm not familiar at all with this stuff, so I was kind of trying to fit RT into a column, probably not necessary :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So put everything you want into the table, don't worry about formatting too much, then before you push your changes, use http://markdowntable.com/ to have it format your table with the correct spacing and such. This is how i do it, others may have a different approach. Eclipse has a very poor markdown editor and previewer.