- Platform information:OpenHABian on Raspberry Pi 3+
- openHAB version: 2.5.10
- Issue of the topic: I am trying to iterate through group members with forEach , check the state and if a state matches, return it as an argument to “sendTelegramQuery” as one of the buttons.
...
var String command_list = ""
gLight.members.forEach[ lamp |
if (lamp.state == ON) {
if (command_list != "") command_list += ", "
command_list += "\"" + lamp.name + "\""
}
]
telegramAction.sendTelegramQuery("what to turn off?", "lights_off", command_list)
...
and it shows me just one button with text ‘“light_1”, “light2”, “light3”’.
sendTelegramQuery accepts one argument for each button (
sendTelegramQuery("question text", "reply_id", "light_1, "light2", light3", "some other button")
Telegram - Bindings | openHAB
)
Specifically the question is: is there an equivalent to eval() function so that command_list is treated as a list of arguments and not just a string, or is there another way to do this?
Sorry for the noob question, but I am a newbie to openHAB and Java (and objects and variable types in Java and how to convert between them)