Let me start by saying that I am new to SmartThings and to Groovy, but certainly not to programming. That being said, I am attempting to write a SmartApp specific to my setup that makes use of dynamic preference pages as well as “dynamic” sections in those pages. For instance, my main preference page allows selection of contactSensor devices to perform an audio notification for when opened:
Then in a subsequent page, I ask for the audio to play for each of the selected contactSensor devices:
def page2() {
dynamicPage(name: "page2")
{
def pos = 1
notifyOnOpenSensors.each {
section("$it.displayName open notification:")
{
input "onOpenAudioDevice" + pos, "capability.audioNotification", title: "Audio player?", required: true
input "onOpenAudioTrack" + pos, "text", title: "Audio track?", required: true
}
pos++
}
}
}
This appears to “work” fine in the simulator, and it appears that definitions are created for onOpenAudioDevice1, onOpenAudioDevice2, etc. My question is this: if every contactSensor device calls the same handler for contact.open, and I can determine the index of the triggering device in notifyOnOpenSensors, how can I get the proper onOpenAudioDevice and onOpenAudioTrack values? From my searching, I haven’t found a way to get an object reference by name. Is it even possible? Thanks in advance.