Checking input_boolean and state change in node-red

Hi there,

I am making my way to node-red at the moment and the simple flows are pretty straight forward.
Now I want to make a flow for the mailbox.
I have a sensor when the mailbox is opened and closed and I have a input_boolean in home-assistant “mail” true/false.
Now I want a workflow that is pretty much like:
When Mailbox is opened (I figure this is state change) then check if input_boolean “mail” is false. If false then send notification and set input_boolean to true.
If input_boolean is true when mailbox is opened then set it to false and don’t send a notification.
I guess I have to do that with switch-nodes but I have no idea what I am doing there.
Any hint or help is appreciated.

Thank you.
Acid

Use current state nodes after the state change to check your mail input. Then the output of the state node you can have whatever you want depending on the mail input.

image

[{"id":"83a5f98b.7ad328","type":"trigger-state","z":"fac037bf.a42d78","name":"","entityid":"sensor.mailbox","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"nt1z9cpfia","targetType":"entity_id","targetValue":"input_boolean.mail","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":184,"y":544,"wires":[["91dcbfe.c8c194","1f456c2f.5f4514"],["1f456c2f.5f4514"]]},{"id":"1f456c2f.5f4514","type":"api-call-service","z":"fac037bf.a42d78","name":"","version":1,"service_domain":"input_boolean","service":"toggle","entityId":"input_boolean.mail","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":462,"y":544,"wires":[[]]},{"id":"91dcbfe.c8c194","type":"debug","z":"fac037bf.a42d78","name":"Send Notifaction","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":432,"y":496,"wires":[]}]

Oh nice - I did not know about the “toggle” - that’s neat.
Thank you.