Multiple Lambdas instances

Hi!
I’ve been playing around with Lambdas, and I run into a problem.

I have a rule to controll my lightscene, and I have a fade lambda for fading. Sometimes I want to execute the lambda multiple times, simultaneous. The problem is, when I just put it on separate lines, it does the first one, and then the second one. Like this:

fade.apply(“H_Bed_Celling”, new HSBType(new DecimalType(0),new PercentType(100),new PercentType(0)), new HSBType(Color_H_Bed_Celling.state.toString), 15, receivedCommand, 10)
fade.apply(“H_All_NOBED”, new HSBType(new DecimalType(0),new PercentType(100),new PercentType(0)), new HSBType(Color_H_Living_Celling.state.toString), 120, receivedCommand, 0)

I have manage to get it to work, but then I use a timer around each line.

Is there a way to run a separte thread for the command, without using timer?

G

If I understand correctly you want the lambdas to run in parallel. I don’t know if you can do that directly. You might need to create Timers that fire in say 1 millisecond and put the code in there. Or you can configure your rules so that multiple rules fire at the same time with each rule doing one of the lambdas.

Thanks. It seems like the only working solution… So far…

Another thing:
Can you get state from an item, using a variable as the item name? Like this:
var String name = ItemName
if (name.string == ON) {
Do something
}

(To be used inside a foreach encosure)

Can you get state from an item, using a variable as the item name?

Sort of. If you put the items in a group you can filter the group’s members based on name.

var item = gMyGroup.members.filter[i|i.name =="name"].head
... 
item.state 
...