I have a routine I took from SmartThings that I can not seem to get to work in Hubitat. Here is the stripped down version
preferences {
section ("Select the switch") {
input "switches", "capability.switch", title: "Real Switch", required: true, multiple: true
}
}
def installed(){
initialize()
}
def updated(){
initialize()
}
def initialize() {
subscribe(switches, "switch", theSwitch)
}
def theSwitch(evt) {
// Both log.info display the same id. In the case of multtipleswitches switches.id returns the array and the evt.deviceId is contained within this array
log.info evt.deviceId
log.info switches.id
// Never appear to find the switch
def device = switches.find { it.id == evt.deviceId }
// device is always null
log.info "Device = $device"
}
There are no error but the find always returns a null. What have I got wrong??