4 * Copyright 2014 Yves Racine
5 * LinkedIn profile: ca.linkedin.com/pub/yves-racine-m-sc-a/0/406/4b/
7 * Developer retains all right, title, copyright, and interest, including all copyright, patent rights, trade secret
8 * in the Background technology. May be subject to consulting fees under the Agreement between the Developer and the Customer.
9 * Developer grants a non exclusive perpetual license to use the Background technology in the Software developed for and delivered
10 * to Customer under this Agreement. However, the Customer shall make no commercial use of the Background technology without
11 * Developer's written consent.
13 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
14 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * Software Distribution is restricted and shall be done only with Developer's written approval.
18 * Change the mode manually (by pressing the app's play button) and automatically at the ecobee thermostat(s)
19 * If you need to set it for both Away and Home modes, you'd need to save them as 2 distinct apps
20 * Don't forget to set the app to run only for the target mode.
22 * N.B. Requires MyEcobee device available at
23 * http://www.ecomatiqhomes.com/#!store/tc3yr
26 name: "ecobeeChangeMode",
28 author: "Yves Racine",
30 "Change the mode manually (by pressing the app's play button) and automatically at the ecobee thermostat(s)",
32 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Partner/ecobee.png",
33 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Partner/ecobee@2x.png"
39 page(name: "selectThermostats", title: "Thermostats", install: false , uninstall: true, nextPage: "selectProgram") {
41 paragraph "ecobeeChangeMode, the smartapp that sets your ecobee thermostat to a given program/climate ['Away', 'Home', 'Night']" +
42 " based on ST hello mode."
43 paragraph "Version 1.9.9"
44 paragraph "If you like this smartapp, please support the developer via PayPal and click on the Paypal link below "
45 href url: "https://www.paypal.me/ecomatiqhomes",
46 title:"Paypal donation..."
47 paragraph "Copyright©2014 Yves Racine"
48 href url:"http://github.com/yracine/device-type.myecobee", style:"embedded", required:false, title:"More information..."
49 description: "http://github.com/yracine/device-type.myecobee/blob/master/README.md"
51 section("Change the following ecobee thermostat(s)...") {
52 input "thermostats", "device.myEcobeeDevice", title: "Which thermostat(s)", multiple: true
54 section("Do the mode change manually only (by pressing the arrow to execute the smartapp)") {
55 input "manualFlag", "bool", title: "Manual only [default=false]", description:"optional",required:false
59 page(name: "selectProgram", title: "Ecobee Programs", content: "selectProgram")
60 page(name: "Notifications", title: "Notifications Options", install: true, uninstall: true) {
61 section("Notifications") {
62 input "sendPushMessage", "enum", title: "Send a push notification?", metadata: [values: ["Yes", "No"]], required:
64 input "phone", "phone", title: "Send a Text Message?", required: false
66 section([mobileOnly:true]) {
67 label title: "Assign a name for this SmartApp", required: false
74 def ecobeePrograms = thermostats[0].currentClimateList.toString().minus('[').minus(']').tokenize(',')
75 log.debug "programs: $ecobeePrograms"
81 return dynamicPage(name: "selectProgram", title: "Select Ecobee Program", install: false, uninstall: true, nextPage:
83 section("Select Program") {
84 input "givenClimate", "enum", title: "Change to this program?", options: ecobeePrograms, required: true
86 section("When SmartThings' hello home mode changes to (ex. 'Away', 'Home')[optional]") {
87 input "newMode", "enum", options: enumModes, multiple:true, required: false
89 section("Enter a delay in minutes [optional, default=immediately after ST hello mode change] ") {
90 input "delay", "number", title: "Delay in minutes [default=immediate]", description:"no delay by default",required:false
107 private def initialize() {
110 subscribe(location, "mode", changeMode)
114 subscribe(app, appTouch)
118 log.debug ("changeMode>location.mode= $location.mode, givenClimate
\7f=${givenClimate}, about to takeAction")
124 def changeMode(evt) {
130 unschedule(takeAction)
132 log.debug ("ecobeeChangeMode>exception when trying to unschedule: $e")
136 Boolean foundMode=false
139 if (it==location.mode) {
143 log.debug ("changeMode>location.mode= $location.mode, newMode=${newMode}")
145 if ((newMode != null) && (!foundMode)) {
147 log.debug "changeMode>location.mode= $location.mode, newMode=${newMode},foundMode=${foundMode}, not doing anything"
151 if ((!delay) || (delay==null)) {
152 log.debug ("changeMode>about to call takeAction()")
155 runIn((delay*60), "takeAction")
159 private void takeAction() {
160 def message = "ecobeeChangeMode>setting ${thermostats} to ${givenClimate}.."
165 it?.setThisTstatClimate(givenClimate)
173 if (sendPushMessage != "No") {
174 log.debug("sending push message")
178 log.debug("sending text message")