Return displayName(s) as string, not array

How do I return input.device.displayNames (for a sendPush) without the Array brackets?

def switchHandler(evt) {
def lightsOnLabels = houseLightsOn.displayName
def lightsOffLabels = houseLightsOff.displayName
houseLightsOn.on()
log.debug "${lightsOnLabels}"
houseLightsOff.off()
log.debug "${lightsOffLabels}"
def message = "Sleep Tight! The house is secure. I have turned on the ${lightsOnLabels} and turned off the ${lightsOffLabels}."
sendPush("$message")

}

The above notification still includes an array of displayNames. I want a string.

ANSWER:

houseLightsOn.displayName.join() - I didn’t that that was supported in groovy but it is.

1 Like