Loops
Loops can be used to iterate over a collection of topics that match a pattern. Click on the Loops
section to drag a loop block into the workspace. The loop has two fields: a field for a Variable
name and a field to specify a pattern for a Topic
. In this example we first define a variable somebodyPresent
and set this to false
. Then we are looping over all topics defined by the pattern office.htc.presense.*.present
which define which people are currently connected to the WIFI router. If there is anybody present the variable somebodyPresent
is set to true
. A second loop is used to iterate over all all topics that have an on
field, such as switches or lights. These are all turned off if there is nobody present and if it is after 18:00.