Backets in SmartApps - Smart Lights Code

Hi Friends,

I would like to avoid brackets “[ ]” when use $something or ${something}.

Example:

“Delay Turn On $ActionSwitchesOn”

Will return:

Delay Turn On [switch1, switch2, switch3]

Would like to see:

Delay Turn On switch1, switch2, switch3

I simply want to avoid showing brackets… like in the SmartApp: Smart Lights

Thank you in advance!

“Delay Turn On $ActionSwitchesOn”.replaceAll("[", “”).replaceAll("]", “”)

I think that should work.

Thank you very much for your fast answer, unfortunately, the option proposed did not work…

Any other idea?

Try:

log.debug "Delay Turn On ${ActionSwitchesOn?.join(', ')}"

Edit: more info here.

1 Like

Fantastic, thank you guys! This works!

Actually even easier the following works:

$ActionSwitchesOn.join()

That’s it…

Now to make it a bit more fun; what about if i wanted to display the different element separated by AND, like this:

$ActionSwitchesOn.SOMTHING

Returns:

switch1 AND switch2 AND switch3 AND switch4

or

switch1, switch2, switch3 AND switch4

Let me know…

Just use a different character in the join call :smile: