forked from pstuart/smartthings-ps
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTest Temp Slider.groovy
More file actions
166 lines (142 loc) · 4.74 KB
/
Test Temp Slider.groovy
File metadata and controls
166 lines (142 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
* ps_TestTempSlider
*
* Copyright 2014 patrick@patrickstuart.com
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
metadata {
definition (name: "ps_TestTempSlider", namespace: "ps", author: "patrick@patrickstuart.com") {
capability "Polling"
capability "Thermostat"
capability "Temperature Measurement"
}
preferences {
input("SliderMin", "Double", title: "Slider Min Adjust", description: "Set Slider Min")
input("SliderMax", "Double", title: "Slider Max Adjust", description: "Set Slider Max")
}
simulator {
// TODO: define status and reply messages here
}
tiles {
// TODO: define your main and details tiles here
valueTile("temperature", "device.temperature", width: 2, height: 2) {
state("temperature", label:'${currentValue}°', unit:"F",
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
[value: 59, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 84, color: "#f1d801"],
[value: 95, color: "#d04e00"],
[value: 96, color: "#bc2323"]
]
)
}
valueTile("thermostatSetpoint", "device.thermostatSetpoint", width: 1, height: 1, decoration: "flat") {
state "thermostatSetpoint", label:'${currentValue}'
}
controlTile("coolSliderControl", "device.coolingSetpoint", "slider", height: 1, width: 2, inactiveLabel: false) {
state "setCoolingSetpoint", action:"thermostat.setCoolingSetpoint", backgroundColor: "#1e9cbb"
}
standardTile("refresh", "device.thermostatMode", inactiveLabel: false, decoration: "flat") {
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
}
main "temperature"
details(["temperature", "thermostatSetpoint","coolSliderControl", "refresh"])
}
}
// parse events into attributes
def parse(String description) {
log.debug "Parsing '${description}'"
// TODO: handle 'temperature' attribute
// TODO: handle 'heatingSetpoint' attribute
// TODO: handle 'coolingSetpoint' attribute
// TODO: handle 'thermostatSetpoint' attribute
// TODO: handle 'thermostatMode' attribute
// TODO: handle 'thermostatFanMode' attribute
// TODO: handle 'thermostatOperatingState' attribute
// TODO: handle 'temperature' attribute
}
// handle commands
def poll() {
log.debug "Executing 'poll'"
// TODO: handle 'poll' command
}
def setHeatingSetpoint() {
log.debug "Executing 'setHeatingSetpoint'"
// TODO: handle 'setHeatingSetpoint' command
}
def setCoolingSetpoint(tempF) {
log.debug "Executing 'setCoolingSetpoint'"
// TODO: handle 'setCoolingSetpoint' command
log.debug tempF
def privMin = 40
def privMax = 90
def PrefSet = false
if (is(SliderMin))
{
PrefSet = true
}
if (is(SliderMax))
{
PrefSet = true
}
// So range is 1-100 need to map to a new min and max formula is y = ((x - a1)/(a2 - a1)) * (b2 - b1) + b1
//OldRange = (OldMax - OldMin)
//NewRange = (NewMax - NewMin)
//NewValue = (((OldValue - OldMin) * NewRange) / OldRange) + NewMin
//def newtempF = ((tempF.toInteger() - 1)/(100 - 1) * (privMax.toInteger() - privMin.toInteger()) + privMax.toInteger())
def newtempF = (((tempF.toInteger() - 1) * (privMax.toInteger() - privMin.toInteger()) / (100/1) + privMin.toInteger()))
log.debug newtempF
//Set min and max for range
sendEvent("name":"thermostatSetpoint", "value":newtempF)
}
def off() {
log.debug "Executing 'off'"
// TODO: handle 'off' command
}
def heat() {
log.debug "Executing 'heat'"
// TODO: handle 'heat' command
}
def emergencyHeat() {
log.debug "Executing 'emergencyHeat'"
// TODO: handle 'emergencyHeat' command
}
def cool() {
log.debug "Executing 'cool'"
// TODO: handle 'cool' command
}
def setThermostatMode() {
log.debug "Executing 'setThermostatMode'"
// TODO: handle 'setThermostatMode' command
}
def fanOn() {
log.debug "Executing 'fanOn'"
// TODO: handle 'fanOn' command
}
def fanAuto() {
log.debug "Executing 'fanAuto'"
// TODO: handle 'fanAuto' command
}
def fanCirculate() {
log.debug "Executing 'fanCirculate'"
// TODO: handle 'fanCirculate' command
}
def setThermostatFanMode() {
log.debug "Executing 'setThermostatFanMode'"
// TODO: handle 'setThermostatFanMode' command
}
def auto() {
log.debug "Executing 'auto'"
// TODO: handle 'auto' command
}