AND or switch with multiple inputs

Simple question. may be simple answer but since I am struggling with this for weeks and tried to search all over but not finding any solution…

What I want. Just “simple AND” statement. For example I want to only turn the light on when another switch is on. Or I only want a snapshot of a camera be sent when another switch is on.

I see something like a switch with a double input. Just like that is input 1 and input 2 are on/true then only the output is on/true.

I think I am thinking too complicated a can really use a push in the right direction.

Another use-case is to “only” follow a flow if another input/switch is true. Like for example “a holiday switch”. If this is ON then only send a picture if the door is opened.

thanks in advance!

ps. I do not want to use complex functions/progamming to achieve…

EDIT: Nevermind. I did this:

I used the “HACS sensor” as an example. You can test the setup by opening and closing “the gate” manually or send an “on” msg.payload to the close gate or open gate to close or open the gate. then the gate will/will not pass any other stuff you flow to it (or not :-)).

This is the config (import in node red):
[{"id":"7de02708.031e08","type":"server-state-changed","z":"9ec3c5fb.13b3f8","name":"Events: State","server":"c6b350c5.b8b3c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.hacs","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":1170,"y":1720,"wires":[["3dc95e1.33760a2"]]},{"id":"3dc95e1.33760a2","type":"gate","z":"9ec3c5fb.13b3f8","name":"Gate","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":true,"x":1810,"y":1720,"wires":[["c3debf3b.af8db"]]},{"id":"38d67019.f65f5","type":"inject","z":"9ec3c5fb.13b3f8","name":"","topic":"control","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1590,"y":1760,"wires":[["3dc95e1.33760a2","c3debf3b.af8db"]]},{"id":"c3debf3b.af8db","type":"debug","z":"9ec3c5fb.13b3f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":2150,"y":1720,"wires":[]},{"id":"7bf191a9.f694e8","type":"inject","z":"9ec3c5fb.13b3f8","name":"","topic":"control","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1590,"y":1620,"wires":[["3dc95e1.33760a2","c3debf3b.af8db"]]},{"id":"1ae9b450.eab7fc","type":"function","z":"9ec3c5fb.13b3f8","name":"Open Gate","func":"msg.topic = \"control\"\nmsg.payload = \"open\"\nreturn msg;","outputs":1,"noerr":0,"x":1590,"y":1800,"wires":[["3dc95e1.33760a2","c3debf3b.af8db"]]},{"id":"793e0e69.3a4e08","type":"inject","z":"9ec3c5fb.13b3f8","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1410,"y":1800,"wires":[["1ae9b450.eab7fc"]]},{"id":"262f5e75.746332","type":"function","z":"9ec3c5fb.13b3f8","name":"Close Gate","func":"msg.topic = \"control\"\nmsg.payload = \"close\"\nreturn msg;","outputs":1,"noerr":0,"x":1590,"y":1660,"wires":[["3dc95e1.33760a2"]]},{"id":"58fae6f5.f88d7","type":"inject","z":"9ec3c5fb.13b3f8","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1410,"y":1660,"wires":[["262f5e75.746332"]]},{"id":"c6b350c5.b8b3c","type":"server","z":"","name":"Home Assistant"}]

Goodluck :slight_smile:

This is what you are looking for:

Can you select the nodes and export the config and shre it here?

This might be what you are looking for… ‘node-red-contrib-bool-gate’ look for it in the Manage palette in NR.

Good luck!

Tried that… no luck for me

I think you are going about this the wrong way. I’m assuming the states you want to check are all in home assistant.

Here is an example I have used, The node red flow is triggered if the harmony remote (TV) is turned off, AND it then checks if the lights in the room are off, THEN set the thermostat to 10 degrees.

image

[{"id":"634617ef.dd1508","type":"server-state-changed","z":"5f64b721.e82e98","name":"Harmony Living Room OFF","server":"8ac442b3.df77c","version":1,"entityidfilter":"remote.living","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":1170,"y":2100,"wires":[["e41f2b9f.4c70e8"],[]]},{"id":"e41f2b9f.4c70e8","type":"api-current-state","z":"5f64b721.e82e98","name":"Lights Living Room Off?","server":"8ac442b3.df77c","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.living_dining","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1430,"y":2100,"wires":[["1516bf09.b20ff1"],[]]},{"id":"1516bf09.b20ff1","type":"api-call-service","z":"5f64b721.e82e98","name":"Set Thermostat 10C","server":"8ac442b3.df77c","version":1,"debugenabled":false,"service_domain":"climate","service":"set_temperature","entityId":"climate.hallway","data":"{\"temperature\":\"10\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1720,"y":2100,"wires":[[]]},
1 Like
[{"id":"1c4fac64.855c14","type":"bigtimer","z":"c9c0cbc.a485238","outtopic":"avondverlichting1","outpayload1":"","outpayload2":"","name":"Weekdagen","comment":"","lat":"51.2272","lon":"5.4317","starttime":"5004","endtime":"1395","starttime2":0,"endtime2":0,"startoff":0,"endoff":"30","startoff2":0,"endoff2":0,"offs":0,"outtext1":"true","outtext2":"false","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":false,"sat":false,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":"24","xmonth1":"12","xday2":"25","xmonth2":"12","xday3":"31","xmonth3":"12","xday4":"1","xmonth4":"1","xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":true,"repeat":true,"atstart":true,"odd":false,"even":false,"x":95,"y":425,"wires":[[],["21f7954d.af559a"],["33294458.740fec"]]},{"id":"abe4908c.4a18b","type":"bigtimer","z":"c9c0cbc.a485238","outtopic":"avondverlichting2","outpayload1":"","outpayload2":"","name":"Weekend","comment":"","lat":"51.2272","lon":"5.4317","starttime":"5004","endtime":"1425","starttime2":0,"endtime2":0,"startoff":0,"endoff":"45","startoff2":0,"endoff2":0,"offs":0,"outtext1":"true","outtext2":"false","timeout":1440,"sun":false,"mon":false,"tue":false,"wed":false,"thu":false,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":"24","xmonth1":"12","xday2":"25","xmonth2":"12","xday3":"31","xmonth3":"12","xday4":"1","xmonth4":"1","xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":true,"repeat":true,"atstart":true,"odd":false,"even":false,"x":85,"y":500,"wires":[[],["21f7954d.af559a"],["33294458.740fec"]]},{"id":"afbba990.267308","type":"bigtimer","z":"c9c0cbc.a485238","outtopic":"avondverlichting3","outpayload1":"","outpayload2":"","name":"Feestdagen","comment":"","lat":"51.2272","lon":"5.4317","starttime":"5004","endtime":"105","starttime2":0,"endtime2":0,"startoff":0,"endoff":"30","startoff2":0,"endoff2":0,"offs":0,"outtext1":"true","outtext2":"false","timeout":1440,"sun":false,"mon":false,"tue":false,"wed":false,"thu":false,"fri":false,"sat":false,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":"24","month1":"12","day2":"25","month2":"12","day3":"31","month3":"12","day4":"1","month4":"1","day5":"","month5":"","day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":"","xmonth1":"","xday2":"","xmonth2":"","xday3":"","xmonth3":"","xday4":"","xmonth4":"","xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":true,"repeat":true,"atstart":true,"odd":false,"even":false,"x":95,"y":575,"wires":[[],["21f7954d.af559a"],["33294458.740fec"]]},{"id":"33294458.740fec","type":"BooleanLogicUltimate","z":"c9c0cbc.a485238","name":"Avondverlichting","filtertrue":"both","persist":true,"sInitializeWith":"false","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"3","topic":"avondverlichting","x":365,"y":500,"wires":[[],["cc378627.3e9188"],[]]}]

So … what is this? :slightly_smiling_face:
These are 3 timers:

  • 1 for weekends
  • 1 for weekdays
  • 1 for public holidays

They are OR’ed (so when 1 is on, the state is on), and the result is fed into a statemachine that determine what lighting profile should be active:

Thanks! Will look into. At least it looks good :slight_smile: