OR function works AND funciton not

Hello,

I have this flow for presence detection of persons switching a input select.
Just arrived, home, Away, just left. Each person have a input select
This section works but I want to control the House with it for Home, away , holiday, also a input select
When 1 of 2 persons is home the OR function works and set the input select of the house on Home.

But I do exact the same with the AND function but I can’t manage that this only works when both of the 2 persons are Away it switches the input select to Away.


with true restriction on it does nothing and with of it switch already when 1 person is away and not both.
This is my first flow based on this site


And I only ad the last input select of Home/ Away/ Holiday.
[{"id":"d494c7be.e46618","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"8ef7eb6c.0b9008","type":"switch","z":"d494c7be.e46618","name":"Home?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"},{"t":"eq","v":"not_home","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":420,"y":200,"wires":[["edda9cc2.fce4","68b68e55.076ae","b8bed4fa.6628e8"],["9cc71a37.9115b8","f9bb6a53.6cf638"]]},{"id":"edda9cc2.fce4","type":"api-current-state","z":"d494c7be.e46618","name":"Status?","server":"85cb4144.a30f7","version":1,"outputs":2,"halt_if":"Just Left","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"input_select.{{topic}}","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":540,"y":60,"wires":[["87403e0e.b2958"],["cdf65d1a.198fb"]]},{"id":"6d86081d.e91628","type":"api-call-service","z":"d494c7be.e46618","name":"Just Left","server":"85cb4144.a30f7","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"","data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Just Left\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":720,"y":360,"wires":[["68b68e55.076ae"]]},{"id":"87403e0e.b2958","type":"api-call-service","z":"d494c7be.e46618","name":"Just Arrived","server":"85cb4144.a30f7","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"","data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Just Arrived\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":710,"y":20,"wires":[["f9bb6a53.6cf638"]]},{"id":"ef89f40a.afe4b8","type":"api-call-service","z":"d494c7be.e46618","name":"Away","server":"85cb4144.a30f7","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"","data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Away\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1010,"y":340,"wires":[["b8bed4fa.6628e8","b10a02cb.bee76","b7f31d74.7bd52"]]},{"id":"ad074b8b.f06458","type":"api-call-service","z":"d494c7be.e46618","name":"Extended Away","server":"85cb4144.a30f7","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"","data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Extended Away\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1300,"y":200,"wires":[[]]},{"id":"68b68e55.076ae","type":"trigger","z":"d494c7be.e46618","name":"10min","op1":"","op2":"{\"payload\":{\"data\":{\"option\":\"\"}}}","op1type":"nul","op2type":"json","duration":"1","extend":false,"overrideDelay":false,"units":"min","reset":"home","bytopic":"topic","topic":"topic","outputs":1,"x":810,"y":240,"wires":[["ef89f40a.afe4b8"]]},{"id":"b8bed4fa.6628e8","type":"trigger","z":"d494c7be.e46618","name":"24hr","op1":"","op2":"{\"payload\":{\"data\":{\"option\":\"\"}}}","op1type":"nul","op2type":"json","duration":"24","extend":false,"units":"hr","reset":"home","bytopic":"topic","outputs":1,"x":1070,"y":200,"wires":[["ad074b8b.f06458"]]},{"id":"f9bb6a53.6cf638","type":"trigger","z":"d494c7be.e46618","name":"10min","op1":"","op2":"{\"payload\":{\"data\":{\"option\":\"\"}}}","op1type":"nul","op2type":"json","duration":"1","extend":false,"overrideDelay":false,"units":"min","reset":"not_home","bytopic":"topic","topic":"topic","outputs":1,"x":890,"y":60,"wires":[["cdf65d1a.198fb"]]},{"id":"cdf65d1a.198fb","type":"api-call-service","z":"d494c7be.e46618","name":"Home","server":"85cb4144.a30f7","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"","data":"{\"entity_id\":\"input_select.{{topic}}\",\"option\":\"Home\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1010,"y":100,"wires":[["85fcf507.d63e08"]]},{"id":"4aa7eafe.8ae754","type":"trigger-state","z":"d494c7be.e46618","name":"Person","server":"85cb4144.a30f7","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"^person\\..*$","entityidfiltertype":"regex","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is_not","comparatorValueDatatype":"prevEntity","comparatorValue":"state","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":80,"y":200,"wires":[["cea6e631.be54e8"],[]]},{"id":"9cc71a37.9115b8","type":"api-current-state","z":"d494c7be.e46618","name":"Status?","server":"85cb4144.a30f7","version":1,"outputs":2,"halt_if":"Just Left,Away, Extended Away","halt_if_type":"str","halt_if_compare":"does_not_include","override_topic":false,"entity_id":"input_select.{{topic}}","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":540,"y":320,"wires":[["6d86081d.e91628"],[]]},{"id":"cea6e631.be54e8","type":"change","z":"d494c7be.e46618","name":"Change","rules":[{"t":"change","p":"topic","pt":"msg","from":"person.","fromt":"str","to":"","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload = \"home\" ? \"home\" : \"not_home\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":215,"y":200,"wires":[["cd69db3e.42b298"]],"l":false},{"id":"cd69db3e.42b298","type":"rbe","z":"d494c7be.e46618","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":295,"y":200,"wires":[["8ef7eb6c.0b9008"]],"l":false},{"id":"ac1e6ddc.f091d","type":"debug","z":"d494c7be.e46618","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1620,"y":120,"wires":[]},{"id":"f6adfa47.14da68","type":"api-current-state","z":"d494c7be.e46618","name":"input select status tom","server":"85cb4144.a30f7","version":1,"outputs":2,"halt_if":"Just Left,Away, Extended Away","halt_if_type":"str","halt_if_compare":"does_not_include","override_topic":false,"entity_id":"input_select.tom","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"","override_data":"none","blockInputOverrides":false,"x":360,"y":560,"wires":[[],[]]},{"id":"b10a02cb.bee76","type":"and-gate","z":"d494c7be.e46618","name":"AND","rules":[{"t":"regex","v":"Away","vt":"str","case":false,"propertyType":"msg","property":"payload","topic":"input_select.tom"},{"t":"regex","v":"Away","vt":"str","case":false,"propertyType":"msg","property":"payload","topic":"input_select.patricia"}],"outputTopic":"","gateType":"and","emitOnlyIfTrue":false,"x":1170,"y":440,"wires":[["6c4c672.4042798","ac1e6ddc.f091d"]]},{"id":"6c4c672.4042798","type":"api-call-service","z":"d494c7be.e46618","name":"input select presence stateAway","server":"85cb4144.a30f7","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"","data":"{\"entity_id\":\"input_select.present_state\",\"option\":\"Away\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1430,"y":440,"wires":[[]]},{"id":"4ef14fd6.1d2b6","type":"api-call-service","z":"d494c7be.e46618","name":"input select presence state Home","server":"85cb4144.a30f7","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"","data":"{\"entity_id\":\"input_select.present_state\",\"option\":\"Home\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1400,"y":40,"wires":[[]]},{"id":"85fcf507.d63e08","type":"or-gate","z":"d494c7be.e46618","name":"OR","rules":[{"t":"regex","v":"Home","vt":"str","case":false,"propertyType":"msg","property":"payload","topic":"input_select.tom"},{"t":"regex","v":"Home","vt":"str","case":false,"propertyType":"msg","property":"payload","topic":"input_select.patrica"}],"outputTopic":"","gateType":"or","emitOnlyIfTrue":false,"x":1150,"y":20,"wires":[["4ef14fd6.1d2b6"]]},{"id":"b7f31d74.7bd52","type":"debug","z":"d494c7be.e46618","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1580,"y":300,"wires":[]},{"id":"85cb4144.a30f7","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

I have never used and or or.
I use current state nodes in series or parallel.
That will do the same thing.

1 Like

Yes that will do the trick thanks.
But still it’s strange that the AND function does not do like I think it should work

Does anyone use it ??

I can’t make it work

You won’t need it. Just put the current state nodes in series and you have your and gate.
Both states has to be “correct” for the message to pass through the nodes.

Thats how AND works, it means “this one AND that one” so both have to be true for the input boolean to change. OR is one OR the other OR both so if any are true the boolean becomes TRUE.