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

[ICP-13246] Stelpro Thermostats preferences changes #32881

Merged
merged 9 commits into from
Jul 22, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ metadata {

preferences {
section {
input("heatdetails", "enum", title: "Do you want a detailed operating state notification?", options: ["No", "Yes"], defaultValue: "No", required: true, displayDuringSetup: true)
input("heatdetails", "enum", title: "Do you want to see detailed operating state events in the activity history? There may be many.", options: ["No", "Yes"], defaultValue: "No", required: false, displayDuringSetup: true)
}
section {
input title: "Outdoor Temperature", description: "To get the current outdoor temperature to display on your thermostat enter your zip code or postal code below and make sure that your SmartThings location has a Geolocation configured (typically used for geofencing).", displayDuringSetup: false, type: "paragraph", element: "paragraph"
input("zipcode", "text", title: "ZipCode (Outdoor Temperature)", description: "[Do not use space](Blank = No Forecast)")
input(title: "Outdoor Temperature", description: "To get the current outdoor temperature to display on your thermostat enter your zip code or postal code below and make sure that your SmartThings location has a Geolocation configured (typically used for geofencing). Do not use space. If you don't want a forecast, leave it blank.",
displayDuringSetup: false, type: "paragraph", element: "paragraph")
input("zipcode", "text", title: "ZipCode (Outdoor Temperature)", description: "")
}
}

Expand Down Expand Up @@ -290,7 +291,7 @@ def zwaveEvent(thermostatsetpointv2.ThermostatSetpointReport cmd) {
def map = [:]

if (cmd.scaledValue >= 327 ||
cmd.setpointType != thermostatsetpointv2.ThermostatSetpointReport.SETPOINT_TYPE_HEATING_1) {
cmd.setpointType != thermostatsetpointv2.ThermostatSetpointReport.SETPOINT_TYPE_HEATING_1) {
return [:]
}
temp = convertTemperatureIfNeeded(cmd.scaledValue, cmdScale, cmd.precision)
Expand Down Expand Up @@ -366,7 +367,10 @@ def zwaveEvent(thermostatoperatingstatev1.ThermostatOperatingStateReport cmd) {
map.name = "thermostatOperatingState"
map.value = operatingState

if (settings.heatdetails == "No") {
// If the user does not want to see the Idle and Heating events in the event history,
// don't show them. Otherwise, don't show them more frequently than 5 minutes.
if (settings.heatdetails == "No" ||
!secondsPast(device.currentState("thermostatOperatingState")?.getLastUpdated(), 60 * 5)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think secondsPast is defined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it isn't in this DTH. It is in the Zigbee and Maestro ones down at the bottom of the file. @PKacprowiczS You'll need to copy secondsPast over.

map.displayed = false
}
} else {
Expand Down Expand Up @@ -556,3 +560,25 @@ def fanCirculate() {
def setThermostatFanMode() {
log.trace "${device.displayName} does not support fan mode"
}

/**
* Checks if the time elapsed from the provided timestamp is greater than the number of senconds provided
*
* @param timestamp: The timestamp
*
* @param seconds: The number of seconds
*
* @returns true if elapsed time is greater than number of seconds provided, else false
*/
private Boolean secondsPast(timestamp, seconds) {
if (!(timestamp instanceof Number)) {
if (timestamp instanceof Date) {
timestamp = timestamp.time
} else if ((timestamp instanceof String) && timestamp.isNumber()) {
timestamp = timestamp.toLong()
} else {
return true
}
}
return (now() - timestamp) > (seconds * 1000)
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ metadata {
preferences {
section {
input("lock", "enum", title: "Do you want to lock your thermostat's physical keypad?", options: ["No", "Yes"], defaultValue: "No", required: false, displayDuringSetup: false)
input("heatdetails", "enum", title: "Do you want a detailed operating state notification?", options: ["No", "Yes"], defaultValue: "No", required: false, displayDuringSetup: true)
input("heatdetails", "enum", title: "Do you want to see detailed operating state events in the activity history? There may be many.", options: ["No", "Yes"], defaultValue: "No", required: false, displayDuringSetup: true)
}
section {
input title: "Outdoor Temperature", description: "To get the current outdoor temperature to display on your thermostat enter your zip code or postal code below and make sure that your SmartThings location has a Geolocation configured (typically used for geofencing).", displayDuringSetup: false, type: "paragraph", element: "paragraph"
input("zipcode", "text", title: "ZipCode (Outdoor Temperature)", description: "[Do not use space](Blank = No Forecast)")
input(title: "Outdoor Temperature", description: "To get the current outdoor temperature to display on your thermostat enter your zip code or postal code below and make sure that your SmartThings location has a Geolocation configured (typically used for geofencing). Do not use space. If you don't want a forecast, leave it blank.",
displayDuringSetup: false, type: "paragraph", element: "paragraph")
input("zipcode", "text", title: "ZipCode (Outdoor Temperature)", description: "")
}
}

Expand Down Expand Up @@ -308,9 +309,9 @@ def parse(String description) {
}

// If the user does not want to see the Idle and Heating events in the event history,
// don't show them. Otherwise, don't show them more frequently than 30 seconds.
// don't show them. Otherwise, don't show them more frequently than 5 minutes.
if (settings.heatdetails == "No" ||
!secondsPast(device.currentState("thermostatOperatingState")?.getLastUpdated(), 30)) {
!secondsPast(device.currentState("thermostatOperatingState")?.getLastUpdated(), 60 * 5)) {
map.displayed = false
}
map = validateOperatingStateBugfix(map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ metadata {
preferences {
section {
input("lock", "enum", title: "Do you want to lock your thermostat's physical keypad?", options: ["No", "Yes"], defaultValue: "No", required: false, displayDuringSetup: false)
input("heatdetails", "enum", title: "Do you want a detailed operating state notification?", options: ["No", "Yes"], defaultValue: "No", required: false, displayDuringSetup: true)
input("heatdetails", "enum", title: "Do you want to see detailed operating state events in the activity history? There may be many.", options: ["No", "Yes"], defaultValue: "No", required: false, displayDuringSetup: true)
}
section {
input title: "Outdoor Temperature", description: "To get the current outdoor temperature to display on your thermostat enter your zip code or postal code below and make sure that your SmartThings location has a Geolocation configured (typically used for geofencing).", displayDuringSetup: false, type: "paragraph", element: "paragraph"
input("zipcode", "text", title: "ZipCode (Outdoor Temperature)", description: "[Do not use space](Blank = No Forecast)")
input(title: "Outdoor Temperature", description: "To get the current outdoor temperature to display on your thermostat enter your zip code or postal code below and make sure that your SmartThings location has a Geolocation configured (typically used for geofencing). Do not use space. If you don't want a forecast, leave it blank.",
displayDuringSetup: false, type: "paragraph", element: "paragraph")
input("zipcode", "text", title: "ZipCode (Outdoor Temperature)", description: "")
}
/*
input("away_setpoint", "enum", title: "Away setpoint", options: ["5", "5.5", "6", "6.5", "7", "7.5", "8", "8.5", "9", "9.5", "10", "10.5", "11", "11.5", "12", "12.5", "13", "13.5", "14", "14.5", "15", "5.5", "15.5", "16", "16.5", "17", "17.5", "18", "18.5", "19", "19.5", "20", "20.5", "21", "21.5", "22", "22.5", "23", "24", "24.5", "25", "25.5", "26", "26.5", "27", "27.5", "28", "28.5", "29", "29.5", "30"], defaultValue: "21", required: true)
Expand Down Expand Up @@ -279,9 +280,9 @@ def parse(String description) {
}

// If the user does not want to see the Idle and Heating events in the event history,
// don't show them. Otherwise, don't show them more frequently than 30 seconds.
// don't show them. Otherwise, don't show them more frequently than 5 minutes.
if (settings.heatdetails == "No" ||
!secondsPast(device.currentState("thermostatOperatingState")?.getLastUpdated(), 30)) {
!secondsPast(device.currentState("thermostatOperatingState")?.getLastUpdated(), 60 * 5)) {
map.displayed = false
}
}
Expand Down