Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/smartthings-infrastructure
[smartthings-infrastructure.git] / main.groovy
index e282ed898bdaa5ef71e779d2b0902564e7705ad1..b28d935b47563728dc56e7bacdcecfde7c2759a7 100644 (file)
@@ -20,6 +20,20 @@ import Location.LocationVar
 import Location.Phrase
 import appTouch.Touched
 import NfcTouch.NfcTouch
+import AeonKeyFob.AeonKeyFob
+import AeonKeyFob.AeonKeyFobs
+import MusicPlayer.MusicPlayer
+import MusicPlayer.MusicPlayers
+import MotionSensor.MotionSensor
+import MotionSensor.MotionSensors
+import ImageCapture.ImageCapture
+import ImageCapture.ImageCaptures
+import SmokeDetector.SmokeDetector
+import SmokeDetector.SmokeDetectors
+import Alarm.Alarm
+import Alarm.Alarms
+import SpeechSynthesis.SpeechSynthesis
+import SpeechSynthesis.SpeechSynthesises
 import Event.Event
 import Timer.SimulatedTimer
 
@@ -59,7 +73,7 @@ def eventHandler(LinkedHashMap eventDataMap) {
                        eventHandler(eventDataMap)
                        }
 //Object for location
-@Field def locationObject = new LocationVar()
+@Field def locationObject = new LocationVar(sendEvent)
 //Object for touch to call function
 @Field def appObject = new Touched(sendEvent, 0)
 //Create a global list for events
@@ -78,6 +92,20 @@ def eventHandler(LinkedHashMap eventDataMap) {
 @Field def presenceSensorObject = new PresenceSensors(sendEvent, 1)
 //Global Object for class thermostat!
 @Field def thermostatObject = new Thermostats(sendEvent, 1)
+//Global Object for class aeon key fob!
+@Field def aeonKeyFobObject = new AeonKeyFobs(sendEvent, 1)
+//Global Object for class music player!
+@Field def musicPlayerObject = new MusicPlayers(sendEvent, 1)
+//Global Object for class motion sensor!
+@Field def motionSensorObject = new MotionSensors(sendEvent, 1)
+//Global Object for class image capture!
+@Field def imageCaptureObject = new ImageCaptures(sendEvent, 1)
+//Global Object for class smoke detector!
+@Field def smokeDetectorObject = new SmokeDetectors(sendEvent, 1)
+//Global Object for class alarm!
+@Field def alarmObject = new Alarms(sendEvent, 1)
+//Global Object for class speech synthesis!
+@Field def speechSynthesisObject = new SpeechSynthesises(sendEvent, 1)
 
 //Application #1
 class App1 {
@@ -86,47 +114,40 @@ class App1 {
        def app
 
        //Extracted objects for App1
-       //Object for class Touch Sensor!
-       def tag
        //Object for class switch!
-       def switch1
+       def switches
+       //Object for class thermostat!
+       def thermostats
        //Object for class lock!
-       def lock
-       //Object for class door control!
-       def garageDoor
-       //Global variable for enum!
-       def masterSwitch = "40"
-       //Global variable for enum!
-       def masterLock = "20"
-       //Global variable for enum!
-       def masterDoor = "40"
+       def locks
 
        //Extracted objects for functions for App1
        //Global Object for functions in subscribe method!
-       def pageTwo = this.&pageTwo
-       //Global Object for functions in subscribe method!
        def installed = this.&installed
        //Global Object for functions in subscribe method!
        def updated = this.&updated
        //Global Object for functions in subscribe method!
-       def initialize = this.&initialize
+       def appTouch = this.&appTouch
        //Global Object for functions in subscribe method!
-       def currentStatus = this.&currentStatus
+       def changedLocationMode = this.&changedLocationMode
        //Global Object for functions in subscribe method!
-       def touchHandler = this.&touchHandler
+       def restoreState = this.&restoreState
+       //Global Object for functions in subscribe method!
+       def saveState = this.&saveState
+       //Global Object for functions in subscribe method!
+       def getCurrentMode = this.&getCurrentMode
 
        App1(Object obj) {
                reference = obj
                location = obj.locationObject
                app = obj.appObject
-               tag = obj.touchSensorObject
-               switch1 = obj.switchObject
-               lock = obj.lockObject
-               garageDoor = obj.doorControlObject
+               switches = obj.switchObject
+               thermostats = obj.thermostatObject
+               locks = obj.lockObject
+               //Global variable for settings!
+               settings = [app:app, switches:switches, thermostats:thermostats, locks:locks]
        }
        //Global variables for each app
-       //Settings variable defined to settings on purpose
-       def settings = "Settings"
        //Global variable for state[mode]
        def state = [home:[],away:[],night:[]]
        //Create a global logger object for methods
@@ -141,6 +162,10 @@ class App1 {
        def timersFuncList = []
        //Create a global list for timer schedulers
        def timersList = []
+       //Create a global variable for settings
+       def settings
+       //Zip code
+       def zipCode = 92617
 
        //Methods
        /////////////////////////////////////////////////////////////////////
@@ -178,11 +203,27 @@ class App1 {
        def runIn(int seconds, Closure functionToCall) {
                if (timersFuncList.contains(functionToCall)) {
                        timersList[timersFuncList.indexOf(functionToCall)].cancel()
-                       def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds, functionToCall)
+                       def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
                } else {
                        timersFuncList.add(functionToCall)
                        timersList.add(new SimulatedTimer())
-                       def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds, functionToCall)
+                       def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
+               }
+       }
+       
+       def runIn(int seconds, Closure functionToCall, LinkedHashMap metaData) {
+               runIn(seconds, functionToCall)
+       }
+       
+       def runIn(int seconds, String nameOfFunction, LinkedHashMap metaData) {
+               runIn(seconds, nameOfFunction)
+       }
+       
+       def runIn(int seconds, String nameOfFunction) {
+               timersFuncList.add(nameOfFunction)
+               timersList.add(new SimulatedTimer())
+               def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(seconds*1000*0) {
+                       "$nameOfFunction"()
                }
        }
        /////////////////////////////////////////////////////////////////////
@@ -219,6 +260,10 @@ class App1 {
        def sendSms(long phoneNumber, String text) {
                println("Sending \""+text+"\" to "+phoneNumber.toString())
        }
+       
+       def sendSMS(long phoneNumber, String text) {
+               println("Sending \""+text+"\" to "+phoneNumber.toString())
+       }
        /////////////////////////////////////////////////////////////////////
        ////sendPush(text)
        def sendPush(String text) {
@@ -244,7 +289,7 @@ class App1 {
        
                timersFuncList.add(nameOfFunction)
                timersList.add(new SimulatedTimer())
-               def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*1000) {
+               def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*1000*0) {
                        "$nameOfFunction"()
                }
        }
@@ -267,114 +312,125 @@ class App1 {
        
                if (timersFuncList.contains(nameOfFunction)) {
                        timersList[timersFuncList.indexOf(nameOfFunction)].cancel()
-                       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*seconds, nameOfFunction)
+                       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*seconds*0, nameOfFunction)
                } else {
                        timersFuncList.add(nameOfFunction)
                        timersList.add(new SimulatedTimer())
-                       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*seconds, nameOfFunction)
+                       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*seconds*0, nameOfFunction)
                }
        }
-
-       def pageTwo() {
-               dynamicPage(name: "pageTwo") {
-               section("If set, the state of these devices will be toggled each time the tag is touched, " + 
-                       "e.g. a light that's on will be turned off and one that's off will be turned on, " +
-                       "other devices of the same type will be set to the same state as their master device. " +
-                       "If no master is designated then the majority of devices of the same type will be used " +
-                       "to determine whether to turn on or off the devices.") {
-                   
-                   if (switch1 || masterSwitch) {
-                       input "masterSwitch", "enum", title: "Master switch", options: switch1.collect{[(it.id): it.displayName]}, required: false
-                   }
-                   if (lock || masterLock) {
-                       input "masterLock", "enum", title: "Master lock", options: lock.collect{[(it.id): it.displayName]}, required: false
-                   }
-                   if (garageDoor || masterDoor) {
-                       input "masterDoor", "enum", title: "Master door", options: garageDoor.collect{[(it.id): it.displayName]}, required: false
-                   }            
-                       }
-                       section([mobileOnly:true]) {
-                               label title: "Assign a name", required: false
-                               mode title: "Set for specific mode(s)", required: false
-                       }        
-           }
+       /////////////////////////////////////////////////////////////////////
+       def now() {
+               return System.currentTimeMillis()
+       }
+       /////////////////////////////////////////////////////////////////////
+       def getTemperatureScale() {
+               return 'C' //Celsius for now
        }
        
+       /////////////////////////////////////////////////////////////////////
+       def getSunriseAndSunset(LinkedHashMap metaData) {
+               def sunRiseSetInfo = [sunrise:[time:1563800160000],sunset:[time:1563850740000]]
+               return sunRiseSetInfo
+       }
+
        def installed() {
-               log.debug "Installed with settings: ${settings}"
-       
-               initialize()
+               subscribe(location, changedLocationMode)
+               subscribe(app, appTouch)
+               saveState()
        }
        
        def updated() {
-               log.debug "Updated with settings: ${settings}"
-       
                unsubscribe()
-               initialize()
+               subscribe(location, changedLocationMode)
+               subscribe(app, appTouch)
+               saveState()
        }
        
-       def initialize() {
-               subscribe tag, "nfcTouch", touchHandler
-           subscribe app, touchHandler
+       def appTouch(evt)
+       {
+               restoreState(currentMode)
        }
        
-       private currentStatus(devices, master, attribute) {
-               log.trace "currentStatus($devices, $master, $attribute)"
-               def result = null
-               if (master) {
-               result = devices.find{it.id == master}?.currentValue(attribute)
-           }
-           else {
-               def map = [:]
-               devices.each {
-                       def value = it.currentValue(attribute)
-                   map[value] = (map[value] ?: 0) + 1
-                   log.trace "$it.displayName: $value"
-               }
-               log.trace map
-               result = map.collect{it}.sort{it.value}[-1].key
-           }
-           log.debug "$attribute = $result"
-           result
+       def changedLocationMode(evt)
+       {
+               restoreState(evt.value)
        }
        
-       def touchHandler(evt) {
-               log.trace "touchHandler($evt.descriptionText)"
-           if (switch1) {
-               def status = currentStatus(switch1, masterSwitch, "switch")
-               switch1.each {
-                   if (status == "on") {
-                       it.off()
-                   }
-                   else {
-                       it.on()
-                   }
-               }
-           }
-           
-           if (lock) {
-               def status = currentStatus(lock, masterLock, "lock")
-               lock.each {
-                   if (status == "locked") {
-                       lock.unlock()
-                   }
-                   else {
-                       lock.lock()
-                   }
-               }
-           }
-           
-           if (garageDoor) {
-               def status = currentStatus(garageDoor, masterDoor, "status")
-               garageDoor.each {
-                       if (status == "open") {
-                       it.close()
-                   }
-                   else {
-                       it.open()
-                   }
-               }
-           }
+       private restoreState(mode)
+       {
+               log.info "restoring state for mode '$mode'"
+               def map = state[mode] ?: [:]
+               switches?.each {
+                       def value = map[it.id]
+                       if (value?.switch == "on") {
+                               def level = value.level
+                               if (level) {
+                                       log.debug "setting $it.label level to $level"
+                                       it.setLevel(level)
+                               }
+                               else {
+                                       log.debug "turning $it.label on"
+                                       it.on()
+                               }
+                       }
+                       else if (value?.switch == "off") {
+                               log.debug "turning $it.label off"
+                               it.off()
+                       }
+               }
+       
+               thermostats?.each {
+                       def value = map[it.id]
+                       if (value?.coolingSetpoint) {
+                               log.debug "coolingSetpoint = $value.coolingSetpoint"
+                               it.setCoolingSetpoint(value.coolingSetpoint)
+                       }
+                       if (value?.heatingSetpoint) {
+                               log.debug "heatingSetpoint = $value.heatingSetpoint"
+                               it.setHeatingSetpoint(value.heatingSetpoint)
+                       }
+               }
+       
+               locks?.each {
+                       def value = map[it.id]
+                       if (value) {
+                               if (value?.locked) {
+                                       it.lock()
+                               }
+                               else {
+                                       it.unlock()
+                               }
+                       }
+               }
+       }
+       
+       
+       private saveState()
+       {
+               def mode = currentMode
+               def map = state[mode] ?: [:]
+       
+               switches?.each {
+                       map[it.id] = [switch: it.currentSwitch, level: it.currentLevel]
+               }
+       
+               thermostats?.each {
+                       map[it.id] = [coolingSetpoint: it.currentCoolingSetpoint, heatingSetpoint: it.currentHeatingSetpoint]
+               }
+       
+               locks?.each {
+                       map[it.id] = [locked: it.currentLock == "locked"]
+               }
+       
+               state[mode] = map
+               log.debug "saved state for mode ${mode}: ${state[mode]}"
+               log.debug "state: $state"
+       }
+       
+       private getCurrentMode()
+       {
+               location.mode ?: "_none_"
        }
 }
 
@@ -386,36 +442,45 @@ class App2 {
        def app
 
        //Extracted objects for App2
+       //Object for class Touch Sensor!
+       def tag
        //Object for class switch!
-       def switchesoff
-       //Object for class switch!
-       def switcheson
+       def switch1
        //Object for class lock!
-       def lock1
-       //Global variable for mode!
-       def newMode = "home"
-       //Global variable for number!
-       def waitfor = 10
+       def lock
+       //Object for class door control!
+       def garageDoor
+       //Global variable for enum!
+       def masterSwitch = "Yes"
+       //Global variable for enum!
+       def masterLock = "Yes"
+       //Global variable for enum!
+       def masterDoor = "No"
 
        //Extracted objects for functions for App2
        //Global Object for functions in subscribe method!
+       def pageTwo = this.&pageTwo
+       //Global Object for functions in subscribe method!
        def installed = this.&installed
        //Global Object for functions in subscribe method!
        def updated = this.&updated
        //Global Object for functions in subscribe method!
-       def appTouch = this.&appTouch
+       def initialize = this.&initialize
+       //Global Object for functions in subscribe method!
+       def touchHandler = this.&touchHandler
 
        App2(Object obj) {
                reference = obj
                location = obj.locationObject
                app = obj.appObject
-               switchesoff = obj.switchObject
-               switcheson = obj.switchObject
-               lock1 = obj.lockObject
+               tag = obj.touchSensorObject
+               switch1 = obj.switchObject
+               lock = obj.lockObject
+               garageDoor = obj.doorControlObject
+               //Global variable for settings!
+               settings = [app:app, tag:tag, switch1:switch1, lock:lock, garageDoor:garageDoor, masterSwitch:masterSwitch, masterLock:masterLock, masterDoor:masterDoor]
        }
        //Global variables for each app
-       //Settings variable defined to settings on purpose
-       def settings = "Settings"
        //Global variable for state[mode]
        def state = [home:[],away:[],night:[]]
        //Create a global logger object for methods
@@ -430,6 +495,10 @@ class App2 {
        def timersFuncList = []
        //Create a global list for timer schedulers
        def timersList = []
+       //Create a global variable for settings
+       def settings
+       //Zip code
+       def zipCode = 92617
 
        //Methods
        /////////////////////////////////////////////////////////////////////
@@ -467,11 +536,27 @@ class App2 {
        def runIn(int seconds, Closure functionToCall) {
                if (timersFuncList.contains(functionToCall)) {
                        timersList[timersFuncList.indexOf(functionToCall)].cancel()
-                       def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds, functionToCall)
+                       def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
                } else {
                        timersFuncList.add(functionToCall)
                        timersList.add(new SimulatedTimer())
-                       def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds, functionToCall)
+                       def task = timersList[timersFuncList.indexOf(functionToCall)].runAfter(1000*seconds*0, functionToCall)
+               }
+       }
+       
+       def runIn(int seconds, Closure functionToCall, LinkedHashMap metaData) {
+               runIn(seconds, functionToCall)
+       }
+       
+       def runIn(int seconds, String nameOfFunction, LinkedHashMap metaData) {
+               runIn(seconds, nameOfFunction)
+       }
+       
+       def runIn(int seconds, String nameOfFunction) {
+               timersFuncList.add(nameOfFunction)
+               timersList.add(new SimulatedTimer())
+               def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(seconds*1000*0) {
+                       "$nameOfFunction"()
                }
        }
        /////////////////////////////////////////////////////////////////////
@@ -508,6 +593,10 @@ class App2 {
        def sendSms(long phoneNumber, String text) {
                println("Sending \""+text+"\" to "+phoneNumber.toString())
        }
+       
+       def sendSMS(long phoneNumber, String text) {
+               println("Sending \""+text+"\" to "+phoneNumber.toString())
+       }
        /////////////////////////////////////////////////////////////////////
        ////schedule(time, nameOfFunction as String)
        def schedule(String time, String nameOfFunction) {
@@ -528,7 +617,7 @@ class App2 {
        
                timersFuncList.add(nameOfFunction)
                timersList.add(new SimulatedTimer())
-               def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*1000) {
+               def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*1000*0) {
                        "$nameOfFunction"()
                }
        }
@@ -551,43 +640,128 @@ class App2 {
        
                if (timersFuncList.contains(nameOfFunction)) {
                        timersList[timersFuncList.indexOf(nameOfFunction)].cancel()
-                       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*seconds, nameOfFunction)
+                       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*seconds*0, nameOfFunction)
                } else {
                        timersFuncList.add(nameOfFunction)
                        timersList.add(new SimulatedTimer())
-                       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*seconds, nameOfFunction)
+                       def task = timersList[timersFuncList.indexOf(nameOfFunction)].runAfter(delay*seconds*0, nameOfFunction)
                }
        }
+       /////////////////////////////////////////////////////////////////////
+       def now() {
+               return System.currentTimeMillis()
+       }
+       /////////////////////////////////////////////////////////////////////
+       def getTemperatureScale() {
+               return 'C' //Celsius for now
+       }
+       
+       /////////////////////////////////////////////////////////////////////
+       def getSunriseAndSunset(LinkedHashMap metaData) {
+               def sunRiseSetInfo = [sunrise:[time:1563800160000],sunset:[time:1563850740000]]
+               return sunRiseSetInfo
+       }
 
-       def installed()
-       {
-               log.debug "Installed with settings: ${settings}"
-               log.debug "Current mode = ${location.mode}"
-               subscribe(app, appTouch)
+       def pageTwo() {
+               dynamicPage(name: "pageTwo") {
+               section("If set, the state of these devices will be toggled each time the tag is touched, " + 
+                       "e.g. a light that's on will be turned off and one that's off will be turned on, " +
+                       "other devices of the same type will be set to the same state as their master device. " +
+                       "If no master is designated then the majority of devices of the same type will be used " +
+                       "to determine whether to turn on or off the devices.") {
+                   
+                   if (switch1 || masterSwitch) {
+                       input "masterSwitch", "enum", title: "Master switch", options: switch1.collect{[(it.id): it.displayName]}, required: false
+                   }
+                   if (lock || masterLock) {
+                       input "masterLock", "enum", title: "Master lock", options: lock.collect{[(it.id): it.displayName]}, required: false
+                   }
+                   if (garageDoor || masterDoor) {
+                       input "masterDoor", "enum", title: "Master door", options: garageDoor.collect{[(it.id): it.displayName]}, required: false
+                   }            
+                       }
+                       section([mobileOnly:true]) {
+                               label title: "Assign a name", required: false
+                               mode title: "Set for specific mode(s)", required: false
+                       }        
+           }
        }
        
+       def installed() {
+               log.debug "Installed with settings: ${settings}"
        
-       def updated()
-       {
+               initialize()
+       }
+       
+       def updated() {
                log.debug "Updated with settings: ${settings}"
-               log.debug "Current mode = ${location.mode}"
+       
                unsubscribe()
-               subscribe(app, appTouch)
+               initialize()
        }
        
-       def appTouch(evt) {
-               log.debug "changeMode, location.mode = $location.mode, newMode = $newMode, location.modes = $location.modes"
-           if (location.mode != newMode) {
-                               setLocationMode(newMode)
-                               log.debug "Changed the mode to '${newMode}'"
-           }   else {
-               log.debug "New mode is the same as the old mode, leaving it be"
-               }
-           log.debug "appTouch: $evt"
-           lock1.lock()
-           switcheson.on()
-           def delay = (waitfor != null && waitfor != "") ? waitfor * 1000 : 120000
-               switchesoff.off(delay: delay)
+       def initialize() {
+               subscribe tag, "nfcTouch", touchHandler
+           subscribe app, touchHandler
+       }
+       
+       private currentStatus(devices, master, attribute) {
+               log.trace "currentStatus($devices, $master, $attribute)"
+               def result = null
+               if (master) {
+               result = devices.find{it.id == master}?.currentValue(attribute)
+           }
+           else {
+               def map = [:]
+               devices.each {
+                       def value = it.currentValue(attribute)
+                   map[value] = (map[value] ?: 0) + 1
+                   log.trace "$it.displayName: $value"
+               }
+               log.trace map
+               result = map.collect{it}.sort{it.value}[-1].key
+           }
+           log.debug "$attribute = $result"
+           result
+       }
+       
+       def touchHandler(evt) {
+               log.trace "touchHandler($evt.descriptionText)"
+           if (switch1) {
+               def status = currentStatus(switch1, masterSwitch, "switch")
+               switch1.each {
+                   if (status == "on") {
+                       it.off()
+                   }
+                   else {
+                       it.on()
+                   }
+               }
+           }
+           
+           if (lock) {
+               def status = currentStatus(lock, masterLock, "lock")
+               lock.each {
+                   if (status == "locked") {
+                       lock.unlock()
+                   }
+                   else {
+                       lock.lock()
+                   }
+               }
+           }
+           
+           if (garageDoor) {
+               def status = currentStatus(garageDoor, masterDoor, "status")
+               garageDoor.each {
+                       if (status == "open") {
+                       it.close()
+                   }
+                   else {
+                       it.open()
+                   }
+               }
+           }
        }
 }
 
@@ -596,48 +770,13 @@ class App2 {
 app1.installed()
 app2.installed()
 
-def events = [1,2,3,4,5,6,7]
-def list = events.permutations()
-int count = Verify.getInt(0,list.size()-1)
-println "COUNT: " + count
-
-list[count].each {
-  switch(it) {
-    case 1:
-      appObject.setValue([name: "Touched", value: "Touched", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "1"
-      break
-    case 2:
-      lockObject.setValue([name: "lock0", value: "locked", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "   2"
-                       break
-    case 3:
-      lockObject.setValue([name: "lock0", value: "unlocked", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "      3"
-      break
-    case 4:
-      contactObject.setValue([name: "contact0", value: "open", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "         4"
-      break
-    case 5:
-      contactObject.setValue([name: "contact0", value: "closed", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "            5"
-      break
-    case 6:
-      switchObject.setValue([name: "switch0", value: "on", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "               6"
-      break
-    case 7:
-      switchObject.setValue([name: "switch0", value: "off", deviceId: 0, descriptionText: "",
-                                          displayed: true, linkText: "", isStateChange: false, unit: "", data: []])
-      println "                   7"
-    default:
-      break
-  }
-}
+appObject.setValue([name: "nfcTouch", value: "touched", deviceId: "nfcSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: [info: "info"]])
+appObject.setValue([name: "Touched", value: "touched", deviceId: "touchedSensorID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: [info: "info"]])
+locationObject.setValue([name: "Location", value: "away", deviceId: "locationID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: [info: "info"]])
+locationObject.setValue([name: "Location", value: "home", deviceId: "locationID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: [info: "info"]])
+locationObject.setValue([name: "Location", value: "night", deviceId: "locationID0", descriptionText: "",
+displayed: true, linkText: "", isStateChange: false, unit: "", data: [info: "info"]])