First of all I hope I did not overlook something, in case I did please point me to the right documentation or post here.
I just migrated my OH 2.5 system to OH 3.3 → it went very smooth and I should have done it much earlier. I was always afraid I have to redo a lot of things, but most things actually still work, which is great. Thanks to all who are contributing to this amazing software.
I now wanted to get started and migrate my Rules (from the classic DSL) to Blockly. The tutorial on YouTube showed how much easier it can be to maintain those rules.
Now I wonder how I can migrate the following code to a Blockly function:
I have assigned a few (KNX) motion detectors in my home which have a red blinking LED, that can be turned on and off, into a (classic) group. I learned that in the “old DSL” I should use this following code block to efficiently turn on all the red lights:
(The 200 ms delay is to make it work. The binding or something “behind” it seemed to have had an issue to send out all telegrams in case there was no delay.)
Bewegung_LED_Rot.allMembers.forEach[item | logInfo("Red LED Switch", "item: " + item.label.toString() + " switch red LED ON" ) sendCommand(item, ON) Thread::sleep(200) ]
FYI - this is the definition of
Group Bewegung_LED_Rot "Bewegung LED Rot" <present>
and then the individual Red LEDs are normal switch items.
I could not find any Group Block in my Blockly list and also did not see something like a “forEach” in the “Loops” section.
Thanks for any advice on this.
FYI - for completeness this is the full classic rule I have:
rule "Abwesenheitsschaltung an" when Item Abwesend received update ON then say("Die Alarmanlage wird aktiviert. .. Es bleiben 30 Sekunden um das Haus zu verlassen. ") if (TimerAlarm!==null) TimerAlarm.cancel() TimerAlarm = createTimer(now.plusSeconds(30)) [| sendCommand(Alarm_Aktiv, ON) ] Bewegung_LED_Rot.allMembers.forEach[item | logInfo("Red LED Switch", "item: " + item.label.toString() + " switch red LED ON" ) sendCommand(item, ON) Thread::sleep(200) ] end