mrkd
3/14/2013 - 6:55 PM

gistfile1.groovy

/**
 *  Garage Door Open/Close notification
 *
 *  Author: mark@marknorgren.com
 *  Date: 2013-03-09
 */

def preferences()
{
  return [
		sections: [
			[
				title: "When the garage door opens or closes...",
				input: [
					[
						name: "multisensor",
						title: "Where?",
						type: "device.smartSenseMulti",
						description: "Tap to set",
						multiple: false
					]
				]
			]
		]
	]
}

def installed()
{
	subscribe(multisensor.contact)
}

def updated()
{
	unsubscribe()
	subscribe(multisensor.contact)
}

def contact(evt) {
	log.trace "$evt.value: $evt, $settings"
    def lastTemp = multisensor.currentTemperature
    def header1 = "X-Parse-Application-Id: WGaLWe62iQpacEQEVYu7H1vICVJIZjl5EBYFyW2B"
    def header2 = "X-Parse-REST-API-Key: uVP4WwSY18ElyX6yhxw9bfT4loWxj0BBVE8WFMS7"
    def header3 = "Content-Type: application/json"
    def data    = "{temp: " + lastTemp + "}"
	log.debug "lastTemp: " + lastTemp
	if (evt.value == "closed") {
		log.debug "$multisensor was closed, sending push message to user"
		sendPush("Your ${multisensor.label ?: contact1.name} was closed")
	}
    if (evt.value == "open") {
		log.debug "$multisensor was opened, sending push message to user"
		sendPush("Your ${multisensor.label ?: contact1.name} was opened")
	}
    
}