Map get not working

Hey everyone,

I am trying to create my first app. I have a simple block of code that is not working.

def devices = getDevices()
log.debug "Devices: ${devices}"
devices.each {
    log.debug "${it.key} = ${it.value}"
    log.debug "${ssdpUSN}"
    if (it.key == ssdpUSN) {
        log.debug "Key Match!"
    }
}
def dev = devices.get(ssdpUSN)
log.debug "Device: ${dev}"

In the logs, the "Devices" entry shows me my devices map. In the devices.each{} block I see the expected key, and value. The key is a String, and the equality test works, such that I see "Key Match!" in the logs. So why is is the assignment of the dev variable is always null? I have tried different get techniques, and they all return null.

def dev = devices[ssdpUSN]
def dev = devices["${ssdpUSN}"]
def dev = devices."${ssdpUSN}"

They all return null, and I don't understand why. Something is not right with the map, or I am missing something critical about groovy that didn't plague me with device driver coding.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.