How to use array loop?

Hi,

I'm pretty much a noob it seems.
I can't get the array loop from contrib-loop-processing to work.

My goal is to go over an array with 18 datapoints (as a string).
Defined in a function node:
image
I want to go over that array, and for each value use the iobroker get node to get the value of that datapoint.
But I have no clue how to use the array loop node properly.
Can anybody give me a hint?

The output should basically be an array of the values.
So 18x "true" or "false"

You would use a split node to send a payload for each element, Then your iobrokernode to get data then a join node to reassemble.
here is a simple example

[{"id":"4dbe6f25.a00d08","type":"inject","z":"368e5e5ea9463c23","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5]","payloadType":"json","x":130,"y":840,"wires":[["7672d787.f724a"]]},{"id":"7672d787.f724a","type":"split","z":"368e5e5ea9463c23","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":300,"y":840,"wires":[["db36ae5f.03f818"]]},{"id":"db36ae5f.03f818","type":"change","z":"368e5e5ea9463c23","name":"simulate iobroker result","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload % 2 = 0","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":860,"wires":[["9d2fcacc.6a106"]]},{"id":"9d2fcacc.6a106","type":"join","z":"368e5e5ea9463c23","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":690,"y":840,"wires":[["9d92c570.6966a"]]},{"id":"9d92c570.6966a","type":"debug","z":"368e5e5ea9463c23","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":560,"y":720,"wires":[]}]
1 Like

how about:

for (i = 0; i < array.length; i++)
{
   // doSomething();
}
1 Like

Wow!
So I actually don't need the loop node?

Not sure what I was doing wrong all the time, but I always had the imagination that when doing it like that, it's not doing it "one by one", but throwing the whole array at the iobroker node at once.

Thank you so very much!

I wouldn't know how to use the iobroker node inside a function node (or more specifially: inside the doSomething() part) :smiley:

Are you sure you just want an array of values? Are you sure you don't want an array of objects like {device: "0015999003850", available: true} or a single object with a set of keys/values like {"0015999003850": true, "0015999003851": false}?

1 Like

That would indeed be the next challenge!

Let's say my function doing the array looks like this:

var array = [
    "zigbee.0.00158d000410e87b.available",
    ]

(with more values of course).
Can I just change this to:

var array = [
    "Kitchen":"zigbee.0.00158d000410e87b.available",
    ]

and then use [0] and [1] to work with the key/values?

Can't you use friendly zigbee device names in that setup? I use zigbee2mqtt and you can give each device a name to save all those silly numbers.

I use the Zigbee Adapter in IoBroker, and the devices are stored like this:


But I have no idea how I would use that name as a datapoint.
When using the iobroker list node to get everything, it contains all datapoints, but not the "Name" :frowning:

OK, so what exactly do you want out of this, after polling the iobroker?

My final goal is to check the availability of my 18 multisensors, check if one of them is "false" and if it is, send me a telegram message.

The telegram part is clear, and so far I get a list of the 18 "true"s.
Like you said, I don't need just the "true", but also the room name.
So when I message myself in case of a sensor not being available, I also send the name.

So I basically need to link the value of each sensor with the corresponding name.

With my knowledge I would probably achieve this by using 18 change nodes, where I set the topic (zigbee ID) and room name and then feed a subflow.
But I want to avoid using 18 change nodes and create the json/array via one function node

I would start with an array of the form

[
  {name: "kitchen", device: "0015999003850"},
  {name: "bedroom", device: ...}
]

then proceed more or less as @E1cid suggested, but make sure you don't lose the name along the way. If you move the name into something like msg.name then it should still be there after the iobroker node.

1 Like

That got the array working - thank you!

Now I'm stuck here:

I'm using the join node to join the value with the room name.
Would work fine: after the 20ms delay I get the value, and in the change node I changed the payload to the room name. So I join the payload from the iobroker node (true/false) with the payload from the change node (room name)
But joining them get's me wrong stuff:


From what I can tell, the join node get's a list of all room names and then all the iobroker values.

I always assumed this was due to the input coming in at the same time and the join node just joins whatever comes in first.
That's why I tried to use the array loop node: to put a "delay" between each run to make sure the correct outputs are joined together

You can not have the link from the change to the join that will short the loop.

If you want a delay i would put it after the split node and set it to rate limit 50 per second.
eg

[{"id":"9d92c570.6966a","type":"debug","z":"368e5e5ea9463c23","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":540,"y":740,"wires":[]},{"id":"173652ec.341aa5","type":"change","z":"368e5e5ea9463c23","name":"create message","rules":[{"t":"set","p":"payload","pt":"msg","to":"$join([payload[available =false].room], \",\") & \" off line\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":860,"wires":[["9d92c570.6966a"]]},{"id":"9d2fcacc.6a106","type":"join","z":"368e5e5ea9463c23","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":730,"y":860,"wires":[["173652ec.341aa5"]]},{"id":"92c6d458.d8f84","type":"change","z":"368e5e5ea9463c23","name":"move results back to payload with room and device","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.available","tot":"msg"},{"t":"move","p":"hold.device","pt":"msg","to":"payload.device","tot":"msg"},{"t":"move","p":"hold.room","pt":"msg","to":"payload.room","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":920,"wires":[["9d2fcacc.6a106"]]},{"id":"db36ae5f.03f818","type":"change","z":"368e5e5ea9463c23","name":"simulate iobroker result returns true or false (guess)","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.device % 2 = 0","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":1000,"wires":[["92c6d458.d8f84"]]},{"id":"2739ec7d.bfd2b4","type":"change","z":"368e5e5ea9463c23","name":"move payload so iobroker will not overwrite","rules":[{"t":"set","p":"hold","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":920,"wires":[["db36ae5f.03f818"]]},{"id":"99b156a7.45dfb","type":"delay","z":"368e5e5ea9463c23","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"50","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":370,"y":860,"wires":[["2739ec7d.bfd2b4"]]},{"id":"7672d787.f724a","type":"split","z":"368e5e5ea9463c23","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":190,"y":860,"wires":[["99b156a7.45dfb"]]},{"id":"4dbe6f25.a00d08","type":"inject","z":"368e5e5ea9463c23","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"room\":\"kitchen\",\"device\":11111},{\"room\":\"bedroom\",\"device\":22222}]","payloadType":"json","x":70,"y":860,"wires":[["7672d787.f724a"]]}]

you can change the proprty names to suit yourself, hope the example helps

1 Like

I changed it a little bit so my little brain can comprehend what it's doing :smiley:

[
    {
        "id": "4c07223a.0f98ec",
        "type": "debug",
        "z": "f24596d3.51bf08",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1310,
        "y": 360,
        "wires": []
    },
    {
        "id": "9d2fcacc.6a106",
        "type": "join",
        "z": "f24596d3.51bf08",
        "name": "",
        "mode": "auto",
        "build": "string",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 490,
        "y": 520,
        "wires": [
            [
                "cbd3a2d2.3aba2"
            ]
        ]
    },
    {
        "id": "92c6d458.d8f84",
        "type": "change",
        "z": "f24596d3.51bf08",
        "name": "move results back to payload with room and device",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "payload.available",
                "tot": "msg"
            },
            {
                "t": "move",
                "p": "hold.room",
                "pt": "msg",
                "to": "payload.room",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 230,
        "y": 520,
        "wires": [
            [
                "9d2fcacc.6a106"
            ]
        ]
    },
    {
        "id": "2739ec7d.bfd2b4",
        "type": "change",
        "z": "f24596d3.51bf08",
        "name": "move payload so iobroker will not overwrite",
        "rules": [
            {
                "t": "set",
                "p": "hold",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "payload.zigbee",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 210,
        "y": 480,
        "wires": [
            [
                "6ee130a6.16a46"
            ]
        ]
    },
    {
        "id": "99b156a7.45dfb",
        "type": "delay",
        "z": "f24596d3.51bf08",
        "name": "",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "50",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 520,
        "y": 360,
        "wires": [
            [
                "2739ec7d.bfd2b4"
            ]
        ]
    },
    {
        "id": "d5417dd4.b4564",
        "type": "split",
        "z": "f24596d3.51bf08",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 350,
        "y": 360,
        "wires": [
            [
                "99b156a7.45dfb"
            ]
        ]
    },
    {
        "id": "7cc939cb.a18c28",
        "type": "inject",
        "z": "f24596d3.51bf08",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[{\"room\":\"kitchen\",\"device\":11111},{\"room\":\"bedroom\",\"device\":22222}]",
        "payloadType": "json",
        "x": 90,
        "y": 360,
        "wires": [
            [
                "60a78611.947278"
            ]
        ]
    },
    {
        "id": "60a78611.947278",
        "type": "function",
        "z": "f24596d3.51bf08",
        "name": "",
        "func": "var array = [\n    {room: \"Büro\", zigbee: \"zigbee.0.00158d000410e87b.available\"},\n    {room: \"Büro Heizung\", zigbee: \"zigbee.0.00158d000774f35a.available\"},\n    {room: \"Eingang\", zigbee: \"zigbee.0.00158d00073c0c65.available\"},\n    {room: \"Esszimmer\", zigbee: \"zigbee.0.00158d000411103a.available\"},\n    {room: \"Esszimmer Heizung\", zigbee: \"zigbee.0.00158d00077dce53.available\"},\n    {room: \"Flur 1\", zigbee: \"zigbee.0.00158d00041d8697.available\"},\n    {room: \"Flur 2\", zigbee: \"zigbee.0.00158d000774f2cb.available\"},\n    {room: \"Gästezimmer\", zigbee: \"zigbee.0.00158d000282eec7.available\"},\n    {room: \"Großes Bad\", zigbee: \"zigbee.0.00158d000283e64e.available\"},\n    {room: \"Kleines Bad\", zigbee: \"zigbee.0.00158d000283e67b.available\"},\n    {room: \"Küche\", zigbee: \"zigbee.0.00158d000163f2bc.available\"},\n    {room: \"Loggia\", zigbee: \"zigbee.0.00158d000412fc1e.available\"},\n    {room: \"Schlafzimmer\", zigbee: \"zigbee.0.00158d000309a45a.available\"},\n    {room: \"Schlafzimmer Heizung\", zigbee: \"zigbee.0.00158d000774f34a.available\"},\n    {room: \"Waschküche\", zigbee: \"zigbee.0.00158d00075f6607.available\"},\n    {room: \"Waschküche Heizung\", zigbee: \"zigbee.0.00158d000774f2c9.available\"},\n    {room: \"Wohnzimmer\", zigbee: \"zigbee.0.00158d000410e8ca.available\"},\n    {room: \"Wohnzimmer Heizung\", zigbee: \"zigbee.0.00158d00076565a1.available\"}\n]\nmsg.payload = array;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 220,
        "y": 360,
        "wires": [
            [
                "d5417dd4.b4564"
            ]
        ]
    },
    {
        "id": "6ee130a6.16a46",
        "type": "ioBroker get",
        "z": "f24596d3.51bf08",
        "name": "",
        "topic": "",
        "attrname": "payload",
        "payloadType": "value",
        "x": 480,
        "y": 480,
        "wires": [
            [
                "92c6d458.d8f84"
            ]
        ]
    },
    {
        "id": "cbd3a2d2.3aba2",
        "type": "split",
        "z": "f24596d3.51bf08",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 610,
        "y": 520,
        "wires": [
            [
                "9d900d8a.59341"
            ]
        ]
    },
    {
        "id": "9d900d8a.59341",
        "type": "switch",
        "z": "f24596d3.51bf08",
        "name": "",
        "property": "payload.available",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "false",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 760,
        "y": 520,
        "wires": [
            [
                "19d6e5c6.599b9a"
            ],
            [
                "1b8a5223.d67ace"
            ]
        ]
    },
    {
        "id": "19d6e5c6.599b9a",
        "type": "function",
        "z": "f24596d3.51bf08",
        "name": "",
        "func": "msg.payload = msg.payload.room + \": online\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 920,
        "y": 500,
        "wires": [
            [
                "4c07223a.0f98ec"
            ]
        ]
    },
    {
        "id": "1b8a5223.d67ace",
        "type": "function",
        "z": "f24596d3.51bf08",
        "name": "",
        "func": "msg.payload = msg.payload.room + \": offline\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 920,
        "y": 540,
        "wires": [
            [
                "4c07223a.0f98ec"
            ]
        ]
    }
]

How exactly is the limit to 50 msg per second delaying it? With 18 values in the array, it would be only 18 messages anyways, right?

The delay node takes 1 second and divides it by 50 to get 20ms, it then send one messsage every 20 ms

1 Like

oooooh, yea. Math. :smiley:
50msg/second doesn't mean it throws 50 msg, waits one second and throws another 50, but it literally sends one message each 20ms.
Nice!

Thank you guys so very much!

With this I can clean up so many of my flows, even the thought of it brings me joy!

PS:
I literally started hiding my mess in sublows all over the place :smiley:
Example:

I expained that how to check - here in detail: [gelöst] Überwachung eingeschaltete Verbraucher

Checking that state of an property within an object - I do with the following change or switch nodes:

[
    {
        "id": "9367f9f7.8f5708",
        "type": "switch",
        "z": "f05041e5.046a7",
        "name": "AND?",
        "property": "$reduce(payload.*,function($i, $j){$i and $j})",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 230,
        "y": 4780,
        "wires": [
            [],
            []
        ],
        "info": "# All properties of an object must be true.\n\nAll properties of an object must be true.\n\n`{\n    \"Office\": true,\n    \"Bedroom\": true,\n    \"Living Room Balcony\": true,\n    \"Living Room Right Window\": true,\n    \"Living Room Left Window\": true\n}`\n\nis true,\n\n`{\n    \"Office\": true,\n    \"Bedroom\": false,\n    \"Living Room Balcony\": true,\n    \"Living Room Right Window\": true,\n    \"Living Room Left Window\": true\n}`\n\nis false.\n\n# Alle Eigenschaften eines Objektes müssen wahr sein\n\nAlle Eigenschaften eines Objektes müssen wahr sein.\n\n`{\n    \"Büro Balkon\": true,\n    \"Schlafzimmer Balkon\": true,\n    \"Wohnzimmer Balkon\": true,\n    \"Wohnzimmer rechtes Fenster\": true,\n    \"Wohnzimmer linkes Fenster\": true\n}`\n\nergibt true,\n\n`{\n    \"Büro Balkon\": true,\n    \"Schlafzimmer Balkon\": true,\n    \"Wohnzimmer Balkon\": true,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": true\n}`\n\nergibt false."
    },
    {
        "id": "e3464ff4.b6dca",
        "type": "change",
        "z": "f05041e5.046a7",
        "name": "AND ?",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$reduce(payload.*,function($i, $j){$i and $j})",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 230,
        "y": 4820,
        "wires": [
            []
        ],
        "info": "# All Property of an object must be true.\n\nAll properties of an object must be true.\n\n`{\n    \"Office\": true,\n    \"Bedroom\": true,\n    \"Living Room Balcony\": true,\n    \"Living Room Right Window\": true,\n    \"Living Room Left Window\": true\n}`\n\nis true,\n\n`{\n    \"Office\": true,\n    \"Bedroom\": false,\n    \"Living Room Balcony\": true,\n    \"Living Room Right Window\": true,\n    \"Living Room Left Window\": true\n}`\n\nis false.\n\n# Alle Eigenschaften eines Objektes müssen wahr sein\n\nAlle Eigenschaften eines Objektes müssen wahr sein.\n\n`{\n    \"Büro Balkon\": true,\n    \"Schlafzimmer Balkon\": true,\n    \"Wohnzimmer Balkon\": true,\n    \"Wohnzimmer rechtes Fenster\": true,\n    \"Wohnzimmer linkes Fenster\": true\n}`\n\nergibt true,\n\n`{\n    \"Büro Balkon\": true,\n    \"Schlafzimmer Balkon\": true,\n    \"Wohnzimmer Balkon\": true,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": true\n}`\n\nergibt false."
    },
    {
        "id": "d2d1dca3.51175",
        "type": "switch",
        "z": "f05041e5.046a7",
        "name": "OR?",
        "property": "$reduce(payload.*,function($i, $j){$i or $j})",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 390,
        "y": 4780,
        "wires": [
            [],
            []
        ],
        "info": "# Only one or more properties of an object need to be true.\n\n Only one or more properties of an object need to be true.\n\n`{\n    \"Office\": false,\n    \"Bedroom\": false,\n    \"Living Room Balcony\": false,\n    \"Liviueng Room Right Window\": false,\n    \"Living Room Left Window\": false\n}`\n\nis false,\n\n`{\n    \"Office\": false,\n    \"Bedroom\": true,\n    \"Living Room Balcony\": false,\n    \"Living Room Right Window\": false,\n    \"Living Room Left Window\": false\n}`\n\nis true.\n\n# Mindestens eine Eigenschaft des Objektes muss wahr sein.\n\nMindestens eine Eigenschaft des Objektes muss wahr sein.\n\n`{\n    \"Büro Balkon\": false,\n    \"Schlafzimmer Balkon\": false,\n    \"Wohnzimmer Balkon\": false,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": false\n}`\n\nergibt false,\n\n`{\n    \"Büro Balkon\": false,\n    \"Schlafzimmer Balkon\": true,\n    \"Wohnzimmer Balkon\": false,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": false\n}`\n\nergibt true (wahr)."
    },
    {
        "id": "36f12990.e70ea6",
        "type": "change",
        "z": "f05041e5.046a7",
        "name": "OR ?",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$reduce(payload.*,function($i, $j){$i or $j})",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 390,
        "y": 4820,
        "wires": [
            []
        ],
        "info": "# Only one or more properties of an object need to be true.\n\n Only one or more properties of an object need to be true.\n\n`{\n    \"Office\": false,\n    \"Bedroom\": false,\n    \"Living Room Balcony\": false,\n    \"Liviueng Room Right Window\": false,\n    \"Living Room Left Window\": false\n}`\n\nis false,\n\n`{\n    \"Office\": false,\n    \"Bedroom\": true,\n    \"Living Room Balcony\": false,\n    \"Living Room Right Window\": false,\n    \"Living Room Left Window\": false\n}`\n\nis true.\n\n# Mindestens eine Eigenschaft des Objektes muss wahr sein.\n\nMindestens eine Eigenschaft des Objektes muss wahr sein.\n\n`{\n    \"Büro Balkon\": false,\n    \"Schlafzimmer Balkon\": false,\n    \"Wohnzimmer Balkon\": false,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": false\n}`\n\nergibt false,\n\n`{\n    \"Büro Balkon\": false,\n    \"Schlafzimmer Balkon\": true,\n    \"Wohnzimmer Balkon\": false,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": false\n}`\n\nergibt true (wahr)."
    },
    {
        "id": "a20d818b.7397c",
        "type": "change",
        "z": "f05041e5.046a7",
        "name": "NOT",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$not(payload)\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 4800,
        "wires": [
            []
        ]
    }
]

Checking if a device is still alive I use always the trigger node - which sends a message if a device is not sending a msg.

1 Like

That would indeed be an option.
I'm using the iobroker list node for a few things here and there, but somehow I don't fully trust it.
Before using node red I used the scripts in iobroker directly, where you can subscribe to a datapoint and trigger stuff if that datapoint changes.
Here you have the list node, which seems to do the same thing, but my first experience with that node was kinda dumb :smiley:
Example: I have 6 door sensors, each one is "monitored" with such a list node.
If the door opens/closes, I send myself a telegram message.
Works perfectly fine.
But: if I restart node red (or crash it while testing stuff.... happens a lot), all flows are restarted of course.
And the result is that in the next 2 hours after node red restarts, I get a message for each of the 6 sensors with the current state.
E.g. all doors are closed -> node red restarts -> after 5 minutes I get the message that door1 is closed, after 26 minutes the message for door 2, after 41 minutes for door3 and so on.
In short: I have no control over when they send the first message (I assume the sensors are updating the "closed" state every now and then and that is when it triggers.

Is there a way to use the list node and send the current status right away? It has the option to send messages at start, but as mentioned above... it only sends me a message as soon as the datapoint was updated once (even if the value doesn't change)

You can use the list node to read all values once triggered at start of node-red. Later you use in addition iobroker-in nodes. As they support wildcards as well this working properly now.

Zusammenfassung
[
    {
        "id": "a504250b.1486b8",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 370,
        "y": 1060,
        "wires": [
            [
                "88218261.6d77a"
            ]
        ]
    },
    {
        "id": "88218261.6d77a",
        "type": "ioBroker list",
        "z": "54b226bc.0793e8",
        "name": "",
        "topic": "alias.0.*.on",
        "objType": "state",
        "regex": "",
        "asArray": "false",
        "onlyIDs": "false",
        "withValues": "true",
        "x": 570,
        "y": 1060,
        "wires": [
            [
                "45bd3ed1.eb60d"
            ]
        ]
    },
    {
        "id": "45bd3ed1.eb60d",
        "type": "change",
        "z": "54b226bc.0793e8",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.val",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 770,
        "y": 1060,
        "wires": [
            [
                "bd1a1595.df8cc8"
            ]
        ]
    },
    {
        "id": "bd1a1595.df8cc8",
        "type": "debug",
        "z": "54b226bc.0793e8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 990,
        "y": 1060,
        "wires": []
    }
]

So if the topic is the same - the join node will updated regardless if the data are coming from the list node or the iobroker in Node.

I would only extract the topic for a following join node - I use normally a change node before to extract the topic from the iobroker path.
The inject Node triggers the iobroker list node just once after start of node-red