Need help with State nodes. Trying to get the state of a Shelly 1 detached switch as trigger for a flow

HA/Node Red noob here. Been watching lots of videos about the flows and inject, debug nodes etc. Been spinning my wheels on the details of triggering on a Shelly device.

I've played with the various State nodes to read the on/off status of the Shelly 1 detached switch for a garage door open/closed status to trigger and email and a Sonos announcement. At one point I was getting 'on' and 'off' in the payload trying to run a Switch and Change Node to so I could just get a Garage door 1 open or closed email. I seem to be getting from/to state changes and two emails on each door status change.

Hoping someone can tell me what state node to use and what basic nodes I can use to send to the email node to report the status of the door.

After that I'm hoping to get ideas on the best way to send the announcements to Sonos.

Much appreciated.

Thanks.

Normally you use the Shellie’s with a MQTT-Broker like mosquitto and then you can use the mqtt-in and out nodes, to trigger a flow or sending commands.

1 Like

Thanks for this. Now i just need to figure out what that means. Still learning.

Last night i found in the HA integrations view that my garage door Shelly 1 had 8 more entities that were hidden. I enabled the input one and created a state node for it and it is passing an on or off to the debug node and to the body of the email. I used a change node to convert that to open/closed. Is this close to what you described?

Now I just need to figure out how to put Garage Door 1 Open or Closed in the subject of the email. Also need to figure out how to announce on Sonos with TTS or even a .wav file. Should I create separate threads for those?

Thanks again for the time you put into this.

I am not sure , if we mean the same. My problem is that I dont know HA and do not know, if HA has an integrated MQTT broker.

I am not sure if you need a separate thread. If you look to the description (help) of the email node, then you can use msg.topic as email subject and the msg.payload as mail body. For sure you will use change nodes to transform the message properties as desired.

As i do not use Sonos - I am not sure if I can give you an useful advice - but it seem that this node
node-red-contrib-tts-ultimate could be part of the solution.

1 Like

Thanks. I looked at the email node docs again and it clicked with me this time. Put the email title into msg.topic and it now works. So Garage doors trigger email alerts done. My first working flow.

Now I'm looking for an AND node. I want to have a red light show when all doors are closed. I see there are some I can download into my palette. Do you know if can I use the GUI to do the download or is it only possible in the CLI?
Thanks.

There are Nodes you can download - but I use Change Nodes as well for boolean logic. So use a change node to translate closed into true and a join node - to combine this into an object.

Here the flow for import:

[{"id":"3d2c3440ea1391f9","type":"inject","z":"ad9d4d1fb27a1de2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door1","payload":"closed","payloadType":"str","x":410,"y":260,"wires":[["7ed9163a4ef421de"]]},{"id":"376ad1790cf341dd","type":"inject","z":"ad9d4d1fb27a1de2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door2","payload":"closed","payloadType":"str","x":410,"y":300,"wires":[["7ed9163a4ef421de"]]},{"id":"ac522128ae3972f8","type":"inject","z":"ad9d4d1fb27a1de2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door3","payload":"closed","payloadType":"str","x":410,"y":340,"wires":[["7ed9163a4ef421de"]]},{"id":"7ed9163a4ef421de","type":"change","z":"ad9d4d1fb27a1de2","name":"translate","rules":[{"t":"change","p":"payload","pt":"msg","from":"closed","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"opened","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":300,"wires":[["a216f8a8d6c608aa"]]},{"id":"125b2b0a6b53a8b6","type":"switch","z":"ad9d4d1fb27a1de2","name":"AND?","property":"$reduce(payload.*,function($i, $j){$i and $j})","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":300,"wires":[["61c95d670f57725b"]],"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":"5e43ed7dd2fe25fb","type":"change","z":"ad9d4d1fb27a1de2","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":450,"y":700,"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":"413e8364ce2c431f","type":"switch","z":"ad9d4d1fb27a1de2","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":610,"y":660,"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":"04fafcc3fa45573d","type":"change","z":"ad9d4d1fb27a1de2","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":610,"y":700,"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":"d20284e99d3d0216","type":"change","z":"ad9d4d1fb27a1de2","name":"NOT","rules":[{"t":"set","p":"payload","pt":"msg","to":"$not(payload)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":680,"wires":[[]]},{"id":"733bd608280baba3","type":"switch","z":"ad9d4d1fb27a1de2","name":"AND?","property":"$reduce(payload.*,function($i, $j){$i and $j})","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":660,"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":"7e40bd5c89985516","type":"debug","z":"ad9d4d1fb27a1de2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1250,"y":300,"wires":[]},{"id":"a216f8a8d6c608aa","type":"join","z":"ad9d4d1fb27a1de2","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":730,"y":300,"wires":[["125b2b0a6b53a8b6"]]},{"id":"c16b0fa6558226a5","type":"inject","z":"ad9d4d1fb27a1de2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door1","payload":"closed","payloadType":"str","x":410,"y":400,"wires":[["48d90b0a6212dd06"]]},{"id":"26c4e572d87d95c7","type":"inject","z":"ad9d4d1fb27a1de2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door2","payload":"closed","payloadType":"str","x":410,"y":440,"wires":[["48d90b0a6212dd06"]]},{"id":"cad4564a09688758","type":"inject","z":"ad9d4d1fb27a1de2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door3","payload":"opened","payloadType":"str","x":410,"y":480,"wires":[["48d90b0a6212dd06"]]},{"id":"48d90b0a6212dd06","type":"change","z":"ad9d4d1fb27a1de2","name":"translate","rules":[{"t":"change","p":"payload","pt":"msg","from":"closed","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"opened","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":440,"wires":[["f0d3988fddd2bab7"]]},{"id":"6f7c836a6f806e83","type":"switch","z":"ad9d4d1fb27a1de2","name":"AND?","property":"$reduce(payload.*,function($i, $j){$i and $j})","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":440,"wires":[["71204382a1e52443"]],"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":"898ea1f69338253e","type":"debug","z":"ad9d4d1fb27a1de2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1250,"y":440,"wires":[]},{"id":"f0d3988fddd2bab7","type":"join","z":"ad9d4d1fb27a1de2","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":730,"y":440,"wires":[["6f7c836a6f806e83"]]},{"id":"61c95d670f57725b","type":"change","z":"ad9d4d1fb27a1de2","name":"set red light on","rules":[{"t":"set","p":"topic","pt":"msg","to":"alarm","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"red light on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":300,"wires":[["7e40bd5c89985516"]]},{"id":"71204382a1e52443","type":"change","z":"ad9d4d1fb27a1de2","name":"set red light on","rules":[{"t":"set","p":"topic","pt":"msg","to":"alarm","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"red light on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":440,"wires":[["898ea1f69338253e"]]}]
1 Like

Thanks for this. I've pasted in the flow (2nd success now). I'm sure I'll have a questions. I'll digest it it tomorrow. Much appreciated

Are the bottom 3 Inject nodes correct? Did you mean for all 3 of them to be 'door x opened'?

No it should only demonstrate if one door is open, that no message pass the flow

1 Like

So I've tried it but can;t get it to do what I hoped. The goal is to have the red light come on when any or all doors are left open. All doors have to be closed for the red light to go out. I've modified it to recognise 4 doors. Now it still sends a right light on when I open any door which is fine but it sends a red light on when I close the last door.

Should I duplicate the AND flow to turn out the light. I guess what I need to do is an OR to turn the light on and an AND to turn the light off.

thanks
(I've yet to master sending a flow as a single line and how to attach an image)

[{"id":"7488976d271d4144","type":"server-state-changed","z":"668a17e2bbad24f9","name":"Garage Door 3 ","server":"ee1bb5a.f1bd648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly1_e89f6d867d60_input","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":440,"wires":[["97f236a9171eb921"]]},{"id":"fa205c0c030ec3c5","type":"e-mail","z":"668a17e2bbad24f9","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"xx@gmail.com","dname":"","credentials":{},"x":1080,"y":260,"wires":[]},{"id":"704ed674238bf2ea","type":"server-state-changed","z":"668a17e2bbad24f9","name":"Garage Door 1","server":"ee1bb5a.f1bd648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly1_58bf25d86793_input","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":240,"wires":[["44f0fa42e1df5554"]]},{"id":"f4dbd6ea65404d7c","type":"server-state-changed","z":"668a17e2bbad24f9","name":"Garage Door 2","server":"ee1bb5a.f1bd648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly1_e89f6d85c8b5_input","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":340,"wires":[["830fff4202fc76b0"]]},{"id":"d7b1d831720fe286","type":"server-state-changed","z":"668a17e2bbad24f9","name":"Garage Door 4","server":"ee1bb5a.f1bd648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly1_e89f6d85f316_input","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":540,"wires":[["7d028ed5047a48c6"]]},{"id":"609d8a7c5ac63479","type":"debug","z":"668a17e2bbad24f9","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":220,"wires":[]},{"id":"01e3c2146b7843fe","type":"change","z":"668a17e2bbad24f9","name":"Change payload from \"off\" to \"Open\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage Door 1 Open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage Door 1 Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":220,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af","80f5e00ec747cb11","20ed879a3da257d8"]]},{"id":"44f0fa42e1df5554","type":"switch","z":"668a17e2bbad24f9","name":"Is door 1 sensor on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":360,"y":240,"wires":[["01e3c2146b7843fe"],["ab048aa7ce35395c"]]},{"id":"ab048aa7ce35395c","type":"change","z":"668a17e2bbad24f9","name":"Change Payload from \"on\" to \"Closed\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage door 1 Closed","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage door 1 Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":260,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af","80f5e00ec747cb11"]]},{"id":"a7c6b18ef7501874","type":"change","z":"668a17e2bbad24f9","name":"Change payload from \"off\" to \"Open\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage Door 2 Open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage Door 2 Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":320,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af","80f5e00ec747cb11","20ed879a3da257d8"]]},{"id":"830fff4202fc76b0","type":"switch","z":"668a17e2bbad24f9","name":"Is door 2 sensor on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":340,"wires":[["a7c6b18ef7501874"],["06da9a360da85242"]]},{"id":"06da9a360da85242","type":"change","z":"668a17e2bbad24f9","name":"Change Payload from \"on\" to \"Closed\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage door 2 Closed","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage door 2 Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":360,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af","80f5e00ec747cb11"]]},{"id":"735ef0a8fcb58640","type":"change","z":"668a17e2bbad24f9","name":"Change payload from \"off\" to \"Open\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage Door 3 Open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage Door 3 Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":420,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af","80f5e00ec747cb11","20ed879a3da257d8"]]},{"id":"97f236a9171eb921","type":"switch","z":"668a17e2bbad24f9","name":"Is door 3 sensor on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":440,"wires":[["735ef0a8fcb58640"],["fde4fc671ff82d4d"]]},{"id":"fde4fc671ff82d4d","type":"change","z":"668a17e2bbad24f9","name":"Change Payload from \"on\" to \"Closed\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage door 3 Closed","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage door 3 Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":480,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af","80f5e00ec747cb11","20ed879a3da257d8"]]},{"id":"7a6012c047a8ad73","type":"change","z":"668a17e2bbad24f9","name":"Change payload from \"off\" to \"Open\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage Door 4 Open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage Door 4 Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":520,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af","80f5e00ec747cb11","20ed879a3da257d8"]]},{"id":"7d028ed5047a48c6","type":"switch","z":"668a17e2bbad24f9","name":"Is door 4 sensor on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":540,"wires":[["7a6012c047a8ad73"],["9855e95d1c1a6a8e"]]},{"id":"9855e95d1c1a6a8e","type":"change","z":"668a17e2bbad24f9","name":"Change Payload from \"on\" to \"Closed\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage door 4 Closed","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage door 4 Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":560,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af","80f5e00ec747cb11"]]},{"id":"b2e634922583d9c5","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door1","payload":"closed","payloadType":"str","x":110,"y":740,"wires":[["259f5c414b2511af"]]},{"id":"4144242088f7de52","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door2","payload":"closed","payloadType":"str","x":110,"y":780,"wires":[["259f5c414b2511af"]]},{"id":"83a66c4338a8fcc9","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door3","payload":"closed","payloadType":"str","x":110,"y":820,"wires":[["259f5c414b2511af"]]},{"id":"259f5c414b2511af","type":"change","z":"668a17e2bbad24f9","name":"translate","rules":[{"t":"change","p":"payload","pt":"msg","from":"closed","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"open","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":780,"wires":[["572cc408cdd98a73"]]},{"id":"caebd5c3a86638ce","type":"switch","z":"668a17e2bbad24f9","name":"AND?","property":"$reduce(payload.*,function($i, $j){$i and $j})","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":780,"wires":[["98cb03e971e255d2"]],"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":"2fc54673c462631e","type":"debug","z":"668a17e2bbad24f9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":780,"wires":[]},{"id":"572cc408cdd98a73","type":"join","z":"668a17e2bbad24f9","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":780,"wires":[["caebd5c3a86638ce"]]},{"id":"98cb03e971e255d2","type":"change","z":"668a17e2bbad24f9","name":"set red light off","rules":[{"t":"set","p":"topic","pt":"msg","to":"alarm","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"red light off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":780,"wires":[["2fc54673c462631e"]]},{"id":"139181a298d6e0a7","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door4","payload":"closed","payloadType":"str","x":110,"y":860,"wires":[["259f5c414b2511af"]]},{"id":"80f5e00ec747cb11","type":"ttsultimate","z":"668a17e2bbad24f9","name":"","voice":"en-GB","ssml":false,"sonosipaddress":"192.168.1.72","sonosvolume":"60","sonoshailing":"0","config":"e1a4e0a0aeec9faf","property":"payload","propertyType":{},"rules":[{"host":"192.168.1.77","hostVolumeAdjust":"0"},{"host":"192.168.1.75","hostVolumeAdjust":"0"},{"host":"192.168.1.71","hostVolumeAdjust":"0"},{"host":"192.168.1.228","hostVolumeAdjust":"0"},{"host":"192.168.1.76","hostVolumeAdjust":"0"},{"host":"192.168.1.73","hostVolumeAdjust":"0"}],"playertype":"sonos","speakingrate":"1","speakingpitch":"0","unmuteIfMuted":true,"x":1070,"y":300,"wires":[[],[]]},{"id":"2e1d95b15c69dbbe","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"testing","payload":"testing","payloadType":"str","x":110,"y":160,"wires":[[]]},{"id":"20ed879a3da257d8","type":"debug","z":"668a17e2bbad24f9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":740,"wires":[]},{"id":"3a05c1c954327a42","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door1","payload":"open","payloadType":"str","x":110,"y":920,"wires":[["259f5c414b2511af","2fc54673c462631e"]]},{"id":"c1da656073b75e05","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door2","payload":"open","payloadType":"str","x":110,"y":960,"wires":[["259f5c414b2511af","2fc54673c462631e"]]},{"id":"ae43961771c44b50","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door3","payload":"open","payloadType":"str","x":110,"y":1000,"wires":[["259f5c414b2511af","2fc54673c462631e"]]},{"id":"f9e0d1e0a4f76bad","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door4","payload":"open","payloadType":"str","x":110,"y":1040,"wires":[["259f5c414b2511af","2fc54673c462631e"]]},{"id":"ee1bb5a.f1bd648","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"e1a4e0a0aeec9faf","type":"ttsultimate-config","name":"Sonos TTS Service","noderedipaddress":"AUTODISCOVER","noderedport":"1980","purgediratrestart":"leave","ttsservice":"googletranslate","TTSRootFolderPath":""}]

Can you edit your post and put the code between the 3 backticks (on a windows English keyboard) the symbol below the ~ key at the top left

Put three of these on a single line

Then on a new line paste your code

Then on another new line at the end paste another 3 of the backticks - and your code will go into a nice neat box like this

[{"id":"7488976d271d4144","type":"server-state-changed","z":"668a17e2bbad24f9","name":"Garage Door 3 ","server":"ee1bb5a.f1bd648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly1_e89f6d867d60_input","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":440,"wires":[["97f236a9171eb921"]]},{"id":"fa205c0c030ec3c5","type":"e-mail","z":"668a17e2bbad24f9","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"??@gmail.com","dname":"","x":1080,"y":260,"wires":[]},{"id":"704ed674238bf2ea","type":"server-state-changed","z":"668a17e2bbad24f9","name":"Garage Door 1","server":"ee1bb5a.f1bd648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly1_58bf25d86793_input","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":240,"wires":[["44f0fa42e1df5554"]]},{"id":"f4dbd6ea65404d7c","type":"server-state-changed","z":"668a17e2bbad24f9","name":"Garage Door 2","server":"ee1bb5a.f1bd648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly1_e89f6d85c8b5_input","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":340,"wires":[["830fff4202fc76b0"]]},{"id":"d7b1d831720fe286","type":"server-state-changed","z":"668a17e2bbad24f9","name":"Garage Door 4","server":"ee1bb5a.f1bd648","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.shelly1_e89f6d85f316_input","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":100,"y":540,"wires":[["7d028ed5047a48c6"]]},{"id":"609d8a7c5ac63479","type":"debug","z":"668a17e2bbad24f9","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":220,"wires":[]},{"id":"01e3c2146b7843fe","type":"change","z":"668a17e2bbad24f9","name":"Change payload from \"off\" to \"Open\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage Door 1 Open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage Door 1 Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":220,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af"]]},{"id":"44f0fa42e1df5554","type":"switch","z":"668a17e2bbad24f9","name":"Is door 1 sensor on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":360,"y":240,"wires":[["01e3c2146b7843fe"],["ab048aa7ce35395c"]]},{"id":"ab048aa7ce35395c","type":"change","z":"668a17e2bbad24f9","name":"Change Payload from \"on\" to \"Closed\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage door 1 Closed","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage door 1 Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":260,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af"]]},{"id":"a7c6b18ef7501874","type":"change","z":"668a17e2bbad24f9","name":"Change payload from \"off\" to \"Open\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage Door 2 Open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage Door 2 Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":320,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af"]]},{"id":"830fff4202fc76b0","type":"switch","z":"668a17e2bbad24f9","name":"Is door 2 sensor on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":340,"wires":[["a7c6b18ef7501874"],["06da9a360da85242"]]},{"id":"06da9a360da85242","type":"change","z":"668a17e2bbad24f9","name":"Change Payload from \"on\" to \"Closed\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage door 2 Closed","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage door 2 Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":360,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af"]]},{"id":"735ef0a8fcb58640","type":"change","z":"668a17e2bbad24f9","name":"Change payload from \"off\" to \"Open\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage Door 3 Open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage Door 3 Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":420,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af"]]},{"id":"97f236a9171eb921","type":"switch","z":"668a17e2bbad24f9","name":"Is door 3 sensor on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":440,"wires":[["735ef0a8fcb58640"],["fde4fc671ff82d4d"]]},{"id":"fde4fc671ff82d4d","type":"change","z":"668a17e2bbad24f9","name":"Change Payload from \"on\" to \"Closed\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage door 3 Closed","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage door 3 Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":480,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af"]]},{"id":"7a6012c047a8ad73","type":"change","z":"668a17e2bbad24f9","name":"Change payload from \"off\" to \"Open\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage Door 4 Open","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage Door 4 Open","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":520,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af"]]},{"id":"7d028ed5047a48c6","type":"switch","z":"668a17e2bbad24f9","name":"Is door 4 sensor on or off?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":360,"y":540,"wires":[["7a6012c047a8ad73"],["9855e95d1c1a6a8e"]]},{"id":"9855e95d1c1a6a8e","type":"change","z":"668a17e2bbad24f9","name":"Change Payload from \"on\" to \"Closed\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Garage door 4 Closed","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Garage door 4 Closed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":560,"wires":[["609d8a7c5ac63479","fa205c0c030ec3c5","259f5c414b2511af"]]},{"id":"b2e634922583d9c5","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door1","payload":"closed","payloadType":"str","x":110,"y":740,"wires":[["259f5c414b2511af"]]},{"id":"4144242088f7de52","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door2","payload":"closed","payloadType":"str","x":110,"y":780,"wires":[["259f5c414b2511af"]]},{"id":"83a66c4338a8fcc9","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door3","payload":"closed","payloadType":"str","x":110,"y":820,"wires":[["259f5c414b2511af"]]},{"id":"259f5c414b2511af","type":"change","z":"668a17e2bbad24f9","name":"translate","rules":[{"t":"change","p":"payload","pt":"msg","from":"closed","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"open","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":780,"wires":[["572cc408cdd98a73"]]},{"id":"caebd5c3a86638ce","type":"switch","z":"668a17e2bbad24f9","name":"AND?","property":"$reduce(payload.*,function($i, $j){$i and $j})","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":780,"wires":[["98cb03e971e255d2"]],"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":"2fc54673c462631e","type":"debug","z":"668a17e2bbad24f9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":780,"wires":[]},{"id":"572cc408cdd98a73","type":"join","z":"668a17e2bbad24f9","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":780,"wires":[["caebd5c3a86638ce"]]},{"id":"98cb03e971e255d2","type":"change","z":"668a17e2bbad24f9","name":"set red light on","rules":[{"t":"set","p":"topic","pt":"msg","to":"alarm","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"red light on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":780,"wires":[["2fc54673c462631e"]]},{"id":"139181a298d6e0a7","type":"inject","z":"668a17e2bbad24f9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"door4","payload":"closed","payloadType":"str","x":110,"y":860,"wires":[["259f5c414b2511af"]]},{"id":"ee1bb5a.f1bd648","type":"server","name":"Home Assistant","addon":true}]

You also might like to look at this - it is home assistant aware and sets up pretty easily for what you are trying to achieve

Craig

1 Like

Sorry - just had a chance to read through the whole thread now

What you shoud do is use the Current state node in NR (from the Home Assistant pallete)

node-red-contrib-home-assistant-websocket : api-current-state

What this will allow you to do is to poll HA for the actual state of each of the doors (you could do this with an inject node running every 5 seconds (say) and then output the states to the Boolean node that i listed previously

This is different to what you are currently doing in that you are waiting for state information to change and be sent from HA - this can be fraught as it is a problem when (for instance) you restart Node Red and you miss some state changes

Not sure if you have seen this one on YT - but it is the best for leading you through

Craig

Done! See above. Thanks it worked like a charm! Different than the pop up instructions when it detects a reply with the JSON in it. Thanks!

on to your next reply...

Well done - One step at a time !!

To paste an image (again assuming you are on Windows) - use the Snip tool in Windows 10/11 and take a screenshot of what you are wanting to share - this then gets put into the clipboard buffer - then come into the forum here - compose a reply and just hit Ctrl C wherever you want to paste the screenshot and away you go !

Craig

Image pasted. Thanks! I'm using a mac btw but i'm pretty comfortable with mac or windows. I go back to the MS/DOS 286 days (I'm 65).

ok I got the flows to work by using OR for door for any doors open turns on the light.. AND all doors must be closed to turn off the light.

You mentioned polling... I'm assuming of Node Red was down while any of the doors changed status then the flow would be out of sync until all 4 doors were cycled?

How about just doing a single poll when Node Red Starts?

I'll update my post above with this new Jason for the flow image now...
ok done! See my revised flows in in the image and the json for it in the single line.

I am not quite 65 - but was working with PCs before the 286 days ! Olivetti M24 with 8086 processor was my first PC purchase

Anyway

What i meant with polling was exactly the issue you alude to - if one of the state changes is missed then the flow will be out of sync

What you are doing now is monitoring a node and waiting for it to tell you the door has changed state i.e. open or closed - instead a better way to do it is to continually ask the system - what state is each door in ?

You do this by running a routine which could say run every 5 seconds - and it could ask the HA system - tell me the state of each of the doors - are they open or closed.

By doing this - each of the nodes will return an answer on/off and you can then feed that into the Boolean node i gave you

So have a look at the picture i pasted above - it shows the Current State node

So if you have 4 of these you can check the Current state of each of the doors and then feed those 4 into the Boolean Ultimate Node

Craig

Here is what it would look like

Note if you go to the Boolean Ultimate site he has some good examples to explain and demonstrate how to use the nodes (there is also a good inject node there for testing stuff like this)

And a good Youtube Video

Craig

1 Like

Have watched this a few times. This guy moves too fast at times. Even pausing isn't often good enough. I have book marked this to come back to and rewatch again when it's less of a swirl.

Btw I have just installed the Boolean Ultimate Node. Brain needs a break and sunny weather is calling me to go outside.

Thanks

Which YT video have you watched ? The one on the Home Assistant integration or the one on the Boolean Ultimate set of nodes ?

When i am following something like the difficult ones on YT - i usually turn the volume off and put the speed down to 1/4 so i can see the screens and what they are doing and not be distracted by what they are saying - does not always work but is often a good help - especially after watching it all the way through once to get the overview of ideas etc

Craig

Here you go - a flow to understand the Boolean ultimate node and how it would work in your scenario with easy testing

[{"id":"13faaec9.cd80b9","type":"InjectUltimate","z":"295a96171a24b772","name":"True","topic":"Door1","x":160,"y":460,"wires":[["6557d19.c71abb","20205deaac81ae9b"],[],[]]},{"id":"6557d19.c71abb","type":"debug","z":"295a96171a24b772","name":"What did we just send ?","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":590,"y":540,"wires":[]},{"id":"569b3820.b056e8","type":"InjectUltimate","z":"295a96171a24b772","name":"True","topic":"Door2","x":160,"y":540,"wires":[["20205deaac81ae9b","6557d19.c71abb"],[],[]]},{"id":"189399f.c384f66","type":"InjectUltimate","z":"295a96171a24b772","name":"Toggle","topic":"Door3","x":170,"y":620,"wires":[[],[],["6557d19.c71abb","20205deaac81ae9b"]]},{"id":"56119644.8c4bf8","type":"comment","z":"295a96171a24b772","name":"Inject Ultimate. Simple and efficient.","info":"","x":250,"y":400,"wires":[]},{"id":"20205deaac81ae9b","type":"BooleanLogicUltimate","z":"295a96171a24b772","name":"","filtertrue":"both","persist":true,"sInitializeWith":"false","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"4","topic":"result","restrictinputevaluation":true,"delayEvaluation":0,"x":490,"y":640,"wires":[["44b1d4b121fd2ea0"],["0d6dfe54bb06c8a7"],["fda86660d3419b5e"]]},{"id":"44b1d4b121fd2ea0","type":"debug","z":"295a96171a24b772","name":"Test if all Doors are True (Open)","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":890,"y":600,"wires":[]},{"id":"0d6dfe54bb06c8a7","type":"debug","z":"295a96171a24b772","name":"Test if any of the Doors are Open (True)","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":680,"wires":[]},{"id":"fda86660d3419b5e","type":"debug","z":"295a96171a24b772","name":"Test if all Doors are the same (Open or Closed)","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":940,"y":760,"wires":[]},{"id":"aaef8991d03dc966","type":"InjectUltimate","z":"295a96171a24b772","name":"True","topic":"Door4","x":160,"y":700,"wires":[["20205deaac81ae9b","6557d19.c71abb"],[],[]]}]

Once you understand what this does and how it works - you can put the Current state node for each of the doors in parallel with the 4 inject nodes and then hookup a single inject node to all the door Current state nodes and you should be good

[{"id":"871ad48acfaef3e6","type":"api-current-state","z":"295a96171a24b772","name":"Door 1 State","server":"b57b98e6e8b218da","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"automation.automation_0","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"topic","propertyType":"msg","value":"Door1State","valueType":"str"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":470,"y":180,"wires":[["ad09e1b38d603d24","101c6baf2588d379"],["371b8a992ea7d6ac"]]},{"id":"a4012a36144edec6","type":"inject","z":"295a96171a24b772","name":"Inject every 5 seconds","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":240,"wires":[["871ad48acfaef3e6"]]},{"id":"ad09e1b38d603d24","type":"BooleanLogicUltimate","z":"295a96171a24b772","name":"","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"4","topic":"result","restrictinputevaluation":false,"delayEvaluation":0,"x":690,"y":80,"wires":[[],[],[]]},{"id":"101c6baf2588d379","type":"debug","z":"295a96171a24b772","name":"Did we get an on ?","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":730,"y":140,"wires":[]},{"id":"371b8a992ea7d6ac","type":"debug","z":"295a96171a24b772","name":"Did we get an off ?","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":730,"y":220,"wires":[]},{"id":"b57b98e6e8b218da","type":"server","name":"Home Assistant","version":2,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":true,"heartbeatInterval":"30"}]

Craig

1 Like