Skip to content
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

28 changes: 28 additions & 0 deletions bundles/org.openhab.binding.venstarthermostat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ After adding the Inbox item, enter the user name and password from the physical
| temperature | Number:Temperature | Current Temperature | |
| outdoorTemperature | Number:Temperature | Outdoor Temperature | |
| humidity | Number | Humidity | |
| fanMode | String | Fan Mode | |
| fanModeRaw | Number | Fan Mode Raw (Read Only) | 0 (Auto) 1 (On) |
| fanState | String | Fan State (Read Only) | |
| fanStateRaw | Number | Fan State Raw (Read Only) | 0 (Off) 1 (On) |
| scheduleMode | String | Current Schedule Mode | |
| scheduleModeRaw | Number | Current Schedule mode Raw (Read Only)| 0(Disabled) 1(Enabled) |
| schedulePart | String | Current Schedule Part | |
| schedulePartRaw | Number | Schedule Part Raw (Read Only)|0(Morning) 1(Day) 2(Evening) 3 (Night) 255 (Inactive) |
| timestampRuntime | DateTime | Time Stamp of last RT update |Binding only looks at the last day runtime |
Copy link
Contributor

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 with Runtime to make this more clear to users

Copy link
Contributor Author

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 :-).

Copy link
Contributor

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.

| heat1Runtime | Number:Dimensionless| RT in heat1 mode in minutes | |
| heat2Runtime | Number:Dimensionless| RT in heat2 mode in minutes | |
| cool1Runtime | Number:Dimensionless| RT in cool1 mode in minutes | |
| cool2Runtime | Number:Dimensionless| RT in cool2 mode in minutes | |
| aux1Runtime | Number:Dimensionless| RT in aux1 mode in minutes | |
| aux2Runtime | Number:Dimensionless| RT in aux2 mode in minutes | |
| freecoolRuntime | Number:Dimensionless| RT in Free Cool in minutes | |


## Example
Expand All @@ -75,6 +91,18 @@ Number Guest_HVAC_Mode "Mode [%s]" {channel="ve
Number Guest_HVAC_Humidity "Humidity [%d %%]" {channel="venstarthermostat:colorTouchThermostat:001122334455:humidity"}
Number Guest_HVAC_State "State [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:systemState"}
Number Guest_Away_Mode "Mode [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:awayMode"}
String Guest_Fan_Mode "Mode [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:fanMode"}
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
String Guest_Fan_State "Fan State [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:fanState"}
String Guest_Schedule_Mode "Schedule Mode [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:scheduleMode"}
String Guest_Schedule_Part "Schedule Part [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:schedulePart"}
DateTime Guest_timestampRuntime "Date/Time Last Update [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:timestampRuntime"}
Number Guest_heat1Runtime "Heat1 Run Time [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:heat1Runtime"}
Number Guest_heat2Runtime "Heat2 Run Time [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:heat2Runtime"}
Number Guest_cool1Runtime "Cool1 Run Time [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:cool1Runtime"}
Number Guest_cool2Runtime "Cool2 Run Time [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:cool2Runtime"}
Number Guest_aux1Runtime "Aux1 Run Time [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:aux1Runtime"}
Number Guest_aux2Runtime "Aux2 Run Time [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:aux2Runtime"}
Number Guest_freecoolRuntime "Free Cool Run Time [%s]" {channel="venstarthermostat:colorTouchThermostat:001122334455:freecoolRuntime"}
```

### thermostat.sitemap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*
* @author William Welliver - Initial contribution
* @author Matthew Davies - added awayMode and awayModeRaw to include thermostat away mode in binding
* @author Matthew Davies - added more binding functionality to get close to the API functionality
*/
@NonNullByDefault
public class VenstarThermostatBindingConstants {
Expand All @@ -47,6 +48,24 @@ public class VenstarThermostatBindingConstants {
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 CHANNEL_FAN_MODE = "fanMode";
public static final String CHANNEL_FAN_MODE_RAW = "fanModeRaw";
public static final String CHANNEL_FAN_STATE = "fanState";
public static final String CHANNEL_FAN_STATE_RAW = "fanStateRaw";
public static final String CHANNEL_SCHEDULE_MODE = "scheduleMode";
public static final String CHANNEL_SCHEDULE_MODE_RAW = "scheduleModeRaw";
public static final String CHANNEL_SCHEDULE_PART = "schedulePart";
public static final String CHANNEL_SCHEDULE_PART_RAW = "schedulePartRaw";
public static final String CHANNEL_TIMESTAMP_RUNTIME = "timestampRuntime";
public static final String CHANNEL_HEAT1_RUNTIME = "heat1Runtime";
public static final String CHANNEL_HEAT2_RUNTIME = "heat2Runtime";
public static final String CHANNEL_COOL1_RUNTIME = "cool1Runtime";
public static final String CHANNEL_COOL2_RUNTIME = "cool2Runtime";
public static final String CHANNEL_AUX1_RUNTIME = "aux1Runtime";
public static final String CHANNEL_AUX2_RUNTIME = "aux2Runtime";
public static final String CHANNEL_FC_RUNTIME = "freecoolRuntime";

// add query/runtimes and query/alerts - these will need an additional class similar to Venstar.infodata - more work

public static final String CONFIG_USERNAME = "username";
public static final String CONFIG_PASSWORD = "password";
Expand Down
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));
}
}
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
}
}
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));
}
}
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,29 @@ public class VenstarInfoData {
VenstarSystemState state;
VenstarSystemMode mode;
VenstarAwayMode away;
VenstarFanMode fan;
VenstarFanState fanstate;
VenstarScheduleMode schedule;
VenstarSchedulePart schedulepart;
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
int tempunits;

public VenstarInfoData() {
super();
}

public VenstarInfoData(double cooltemp, double heattemp, VenstarSystemState state, VenstarSystemMode mode,
VenstarAwayMode away) {
VenstarAwayMode away, VenstarFanMode fan, VenstarFanState fanstate, VenstarScheduleMode schedule,
VenstarSchedulePart schedulepart) {
super();
this.cooltemp = cooltemp;
this.heattemp = heattemp;
this.state = state;
this.mode = mode;
this.away = away;
this.fan = fan;
this.fanstate = fanstate;
this.schedule = schedule;
this.schedulepart = schedulepart;
}

public double getCooltemp() {
Expand Down Expand Up @@ -88,4 +97,36 @@ public VenstarAwayMode getAway() {
public void setAwayMode(VenstarAwayMode away) {
this.away = away;
}

public VenstarFanMode getFanMode() {
return fan;
}

public void setFanMode(VenstarFanMode fan) {
this.fan = fan;
}

public VenstarFanState getFanState() {
return fanstate;
}

public void setFanState(VenstarFanState fanstate) {
this.fanstate = fanstate;
}

public VenstarScheduleMode getScheduleMode() {
return schedule;
}

public void setScheduleMode(VenstarScheduleMode schedule) {
this.schedule = schedule;
}

public VenstarSchedulePart getSchedulePart() {
return schedulepart;
}

public void setSchedulePart(VenstarSchedulePart schedulepart) {
this.schedulepart = schedulepart;
}
}
Loading