Return label of device that trigger evt

Essentially, tell me which one of the two presence sensors left.

I’ve been looking at the Greeting Earthlings app which allows for the selection of multiple presenceSensors.

When I run the code below in Sim it still outputs the name of both cars instead of the one that triggered the event.

preferences {
	
	section("Available Sensors") {
		input "auto", "capability.presenceSensor", title: "Select sensor to configure...", multiple: true
	}

	section("Available iPhones") {
		input "phone", "capability.presenceSensor", title: "Select phone to ping...", multiple: true
	}

}

def installed() {
	log.debug "Cars = ${auto.collect{it.label + ': ' + it.currentPresence}}"
	subscribe(auto, "presence", pingHandler)
}

def update() {
	log.debug "Cars = ${auto.collect{it.label + ': ' + it.currentPresence}}"
	unsubscribe()
	subscribe(auto, "presence", pingHandler)
}

def pingHandler(evt) {

	def car = getCar(evt)
	
	if(evt.value == "present") {
		def phoneState = phone.currentState("presenceSensor")
		sendPush("${auto.displayName} is here, I will update iPhone locations.")
	} else if (evt.value == "not present") {
		def phoneState = phone.currentState("presenceSensor")
		sendPush("${auto.displayName} has left, I will update iPhone locations.")
	}
}

private getCar(evt) {
	auto.find{evt.deviceId == it.id}
}

You can use ${evt.displayName} instead of ${auto.displayName}.

See https://graph.api.smartthings.com/ide/doc/event

displayName of an event is “User-oriented name of the source of this event. Typically the user-assigned device label”

Thanks @stepchen,

I appreciate the link. I kept getting a HANDLER error in console. I refreshed and it worked.