1515 or Monoprice #11989 Z-Wave In-Wall On/Off module
1616
1717 Change Log
18+ 2016-07-02b. fixed mode bug not by changing technique, cleaned up code with shutdownEvap()
19+ a. modify dynamic feedback of inputs to be via paragraph technique
1820 2016-07-01 changed user select mode method, changed default delay-on to 1.5
1921 2016-06-30 added dynamic temperature display readout to Room Setpoint Temp input for ease of troubleshooting
2022 2016-06-28 x.1 version update
21- added submitOnChange for motion so to skip minutes input next if no motion selected
22- changed order of inputs for better logic flow
23- added separate input page for only advanced options
24- fixed bug in High Speed startup assuming fan/pump was already running
25- renamed fanHiSpeed to fanSpeed for more generic use, added 0.0 on timer selection
26- changed motion detector minutes input only if motion selected submitOnChange
23+ f. added submitOnChange for motion so to skip minutes input next if no motion selected
24+ e. changed order of inputs for better logic flow
25+ d. added separate input page for only advanced options
26+ c. fixed bug in High Speed startup assuming fan/pump was already running
27+ b. renamed fanHiSpeed to fanSpeed for more generic use, added 0.0 on timer selection
28+ a. changed motion detector minutes input only if motion selected submitOnChange
2729 2016-06-22e added single speed default
28- 2016-06-22d change user guide content
29- 2016-06-22c modified icon to fan style, breeze style for comparison
30- 2016-06-22b moved pump input to first position (required), made other selections not required for those with single speed motor
31- 2016-06-22 added icons
30+ d. change user guide content
31+ c. modified icon to fan style, breeze style for comparison
32+ b. moved pump input to first position (required), made other selections not required for those with single speed motor
33+ a. added icons
3234 2016-06-21 modify 3-speed-ceiling-fan-thermostat code for outlets
3335
3436
4547*/
4648
4749definition(
48- name : " Evap Cooler Thermostat" ,
50+ name : " Evap Cooler Thermostat TEST " ,
4951 namespace : " dcoffing" ,
5052 author : " Dale Coffing, SmartThings" ,
5153 description : " Automatic control for an Evaporative Cooler with a 2-speed motor, water pump and any temp sensor." ,
@@ -63,24 +65,35 @@ preferences {
6365
6466def mainPage () {
6567 dynamicPage(name : " mainPage" , title : " Select your devices and settings" , install : true , uninstall : true ){
66-
67- section(" Select a room temperature sensor to control the Evap Cooler..." ){
68- input " tempSensor" , " capability.temperatureMeasurement" , multiple :false , title : " Temperature Sensor" , required : true , submitOnChange : true
69- }
70- if (tempSensor) { // protects from a null error
71- section(" Enter the desired room temperature setpoint...\n " + " NOTE: ${ tempSensor.displayName} room temp is ${ tempSensor.currentTemperature} ° currently" ){
72- input " setpoint" , " decimal" , title : " Room Setpoint Temp" , defaultValue : tempSensor. currentTemperature, required : true
73- }
74- }
75- else
76- section(" Enter the desired room temperature setpoint..." ){
77- input " setpoint" , " decimal" , title : " Room Setpoint Temp" , required : true
78- }
7968
80- section(" Select the Evap Cooler fan motor switch hardware..." ){
69+ section(" Select the Evap Cooler fan motor switch hardware..." ){
8170 input " fanMotor" , " capability.switch" ,
82- multiple :false , title : " Fan Motor On-Off Control device" , required : true
71+ multiple :false , title : " Fan Motor On-Off Control device" , required : true , submitOnChange : true
72+ }
73+
74+ section(" Select a room temperature sensor to control the Evap Cooler..." ){
75+ input " tempSensor" , " capability.temperatureMeasurement" , multiple :false , title : " Temperature Sensor" , required : true , submitOnChange : true
8376 }
77+
78+ section(" Enter the desired room temperature setpoint..." ){
79+ input " setpoint" , " decimal" , title : " Room Setpoint Temp" , required : true
80+ }
81+
82+ section(" Current Conditions are" ){
83+ if (fanMotor) {
84+ paragraph (" ${ fanMotor.displayName} is ${ fanMotor.currentSwitch} " )
85+ }
86+ if (tempSensor) {
87+ paragraph (" ${ tempSensor.displayName} room temp is ${ tempSensor.currentTemperature} ° " )
88+ }
89+ if (fanPump) {
90+ paragraph (" ${ fanPump.displayName} is ${ fanPump.currentSwitch} " )
91+ }
92+ if (fanSpeed) {
93+ paragraph (" ${ fanSpeed.displayName} is ${ fanSpeed.currentSwitch} " )
94+ }
95+ }
96+
8497 section(" Optional Settings (Fan Speed, Timers, Motion, etc)" ) {
8598 href (name : " optionsPage" ,
8699 title : " Configure Optional settings" ,
@@ -93,8 +106,8 @@ def mainPage() {
93106// VERSION
94107 section(" Version Info, User's Guide" ) {
95108 href (name : " aboutPage" ,
96- title : " Evap Cooler Thermostat \n " + " Version: 1.0.160701 \n " + " Copyright © 2016 Dale Coffing" ,
97- description : " Tap to get user's guide." ,
109+ title : " Evap Cooler Thermostat \n " + " Version: 1.0.160702c \n " + " Copyright © 2016 Dale Coffing" ,
110+ description : " Tap to access user's guide." ,
98111 image : " https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/smartapps/dcoffing/evap-cooler-thermostat.src/ect250x250.png" ,
99112 required : false ,
100113 page : " aboutPage"
@@ -108,7 +121,7 @@ def optionsPage() {
108121
109122 section(" Select the Evap Cooler Fan Speed switch control hardware (optional, leave blank for single speed)...." ){
110123 input " fanSpeed" , " capability.switch" ,
111- multiple :false , title : " Fan Hi-Lo Speed Control device" , required : false
124+ multiple :false , title : " Fan Hi-Lo Speed Control device" , required : false , submitOnChange : true
112125 }
113126
114127 section(" Enter the desired differential temp between fan speeds (default=1.0)..." ){
@@ -117,7 +130,7 @@ def optionsPage() {
117130
118131 section(" Select the Evap Cooler pump switch hardware..." ){
119132 input " fanPump" , " capability.switch" ,
120- multiple :false , title : " Fan Pump On-Off Control device" , required : false
133+ multiple :false , title : " Fan Pump On-Off Control device" , required : false , submitOnChange : true
121134 }
122135 section(" Enter the desired minutes to delay start of fan to allow for wetting of pads. (default=1.5)..." ){
123136 input " fanDelayOnString" , " enum" , title : " Fan Delay On Timer" , options : [" 0.0" ," 0.5" ," 1.0" ," 1.5" ," 2.0" ," 2.5" ], required : false
@@ -136,13 +149,12 @@ def optionsPage() {
136149 input " autoMode" , " enum" , title : " Enable Evap Cooler Thermostat?" , options : [" NO-Manual" ," YES-Auto" ], required : false
137150 }
138151
139- section (" Change SmartApp name, Mode selector" ) {
152+ section (" Change SmartApp name, Mode selector" ) {
140153 label title : " Assign a name" , required : false
141- mode(title : " Set for specific mode(s)" )
142- // mode title: "Set for specific mode(s)", required: false
143- }
144-
145- }
154+ // mode(title: "Set for specific mode(s)"), required: false //this technique for User mode fails for this smartapp
155+ input " selectedModes" , " mode" , title : " Select specific mode(s) to run (default is ALL modes)" , multiple : true , required : false
156+ }
157+ }
146158 }
147159
148160def aboutPage () {
@@ -172,7 +184,14 @@ def initialize() {
172184 subscribe(motionSensor, " motion" , motionHandler) // call the motionHandler method when there is any reported change to the "motion" attribute
173185 }
174186}
175- // Event Handler Methods
187+
188+ def shutdownEvap () {
189+ fanMotor. off()
190+ fanPump. off()
191+ fanSpeed. off()
192+ }
193+
194+ // Event Handler Methods
176195def temperatureHandler (evt ) {
177196 log. debug " temperatureHandler called: $evt "
178197 handleTemperature(evt. doubleValue)
@@ -188,11 +207,9 @@ def handleTemperature(temp) { //
188207 log. debug " handleTemperature ISACTIVE($isActive )"
189208 }
190209 else {
191- fanMotor. off()
192- fanPump. off()
193- fanSpeed. off()
210+ shutdownEvap()
194211 }
195- }
212+ }
196213
197214def motionHandler (evt ) {
198215 if (evt. value == " active" ) {
@@ -213,15 +230,13 @@ def motionHandler(evt) {
213230 }
214231 }
215232 else {
216- fanMotor. off()
217- fanPump. off()
218- fanSpeed. off()
233+ shutdownEvap()
219234 }
220235 }
221236}
222237
223- private tempCheck (currentTemp , desiredTemp )
224- {
238+ private tempCheck (currentTemp , desiredTemp ) {
239+
225240 log. debug " TEMPCHECK#1(CT=$currentTemp , SP=$desiredTemp , FM=$fanMotor . currentSwitch , automode=$autoMode , FDTstring=$fanDiffTempString , FDTvalue=$fanDiffTempValue )"
226241
227242 // convert Fan Delay On input enum string to number value and if user doesn't select a Fan Delay On value, then default to 1.5
@@ -237,7 +252,12 @@ private tempCheck(currentTemp, desiredTemp)
237252 def HighDiff = fanDiffTempValue* 2
238253
239254 log. debug " TEMPCHECK#2(CT=$currentTemp , SP=$desiredTemp , FM=$fanMotor . currentSwitch , automode=$autoMode , FDTstring=$fanDiffTempString , FDTvalue=$fanDiffTempValue )"
240- if (autoModeValue == " YES-Auto" ) {
255+
256+
257+ if (currentModeAllowed(settings. selectedModes)) {
258+ // Executes if current ST mode matches one of the user selected modes.
259+
260+ if (autoModeValue == " YES-Auto" ) {
241261 switch (currentTemp - desiredTemp) {
242262 case { it >= HighDiff }:
243263 // turn on fan high speed
@@ -258,26 +278,32 @@ private tempCheck(currentTemp, desiredTemp)
258278 fanMotor. on([delay : (fanDelayOnValue* 60 * 1000 )]) // delay starting fan to allow pump to wet pads
259279
260280 log. debug " Fan Lo speed in fanDelayOn min (CT=$currentTemp , SP=$desiredTemp , LowDiff=$LowDiff )"
261- } else {
281+ }
282+ else {
262283 fanSpeed. off() // fan is already running, set Low speed immediately
263- }
284+ }
264285 log. debug " LO speed skip pump (CT=$currentTemp , SP=$desiredTemp , LowDiff=$LowDiff )"
265286 break
266287 default :
267288 // check to see if fan should be turned off
268289 if (desiredTemp - currentTemp >= 0 ) { // below or equal to setpoint, turn off fan,
269- fanMotor. off()
270- fanPump. off()
271- fanSpeed. off()
290+ shutdownEvap()
272291 log. debug " below SP+Diff=fan OFF (CT=$currentTemp , SP=$desiredTemp , FD=$fanMotor . currentSwitch , autoMode=$autoMode ,)"
273292 }
274293 log. debug " autoMode YES-MANUAL? else OFF(CT=$currentTemp , SP=$desiredTemp , FD=$fanMotor . currentSwitch , autoMode=$autoMode ,)"
275294 }
276- }
295+ }
296+
297+ }
298+ else {
299+ shutdownEvap()
300+ }
301+ }
302+ def currentModeAllowed (allowedModes ) {
303+ return (! allowedModes || allowedModes?. find{it == location. mode})
277304}
278305
279- private hasBeenRecentMotion ()
280- {
306+ private hasBeenRecentMotion () {
281307 def isActive = false
282308 if (motionSensor && minutesNoMotion) {
283309 def deltaMinutes = minutesNoMotion as Long
@@ -308,4 +334,4 @@ private def textHelp() {
308334 " pump and fan speed then Enerwave ZWN-RSM2 dual 10amp relays to control pump and the second relay" +
309335 " to control hi-lo speed via Omoron LY1F SPDT 15amp relay. For only pump control any single switch could" +
310336 " work like the Enerwave ZWN-RSM1S or Monoprice #11989 Z-Wave In-Wall On/Off module"
311- }
337+ }
0 commit comments