Block anything from happening during certain automations?

Hi,

i recently stumbled across a rare case when two automation “crossed” each other.

On the one hand I have a motion sensor near my bed that turns the off lights when im in bed either to trigger a sleep routine or a naptime routine.
On the other hand I have an automation that turns the lights on when the sun sets.

Now i had this special case where the naptime routine was in effect and the lights where turned off, and then the sun set and the lights turned on.

So how would I go about preventing the lights from turning on during the naptime routine?
I could of course use an input bool to set a naptime-variable and have it checked by all other light automations. Thats probably simple for 2-3 automations but if you have a many that would mean a lot of configuration just to prevent this on rare condition.

Is there maybe a way to tell the whole light-domain in the room to only listen to the one flow and ignore all other triggers?

Cheers F.

You need to configure it some how. There is no “easy” way as I see it.
You could use flow or global variables in Node red but that is essentially the same as boolean.
You could disable the other sequence but not sure that is easier or better.

I think a global/flow/boolean is the easiest way to do it.

the best way to avoid such problems is by merging all the flows in a single one if possible or setting the right conditions in each one… In other words, you should only have 1 call service for turning on the light and just another one to turn it off in your whole NR instance.

Also what @Hellis81 said. You should create some variable/entity to know the state of your napping routine.

This is one great virtue NR has over yaml. This can be achieved way easier.

for the particular cross you mentioned something like this would do it, but if you have more flows with different triggers and conditions you should add all those triggers whithin the trigger node and branch the conditions accordingly in order to have everything merged

[{"id":"ce88f047.1ef03","type":"server-state-changed","z":"937ef78.ec6b408","name":"Motion sensor to detect sleep","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.your_sensor","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":220,"y":540,"wires":[["45fe7090.2bd11"],[]]},{"id":"45fe7090.2bd11","type":"api-call-service","z":"937ef78.ec6b408","name":"Input boolean on","server":"9405c3fe.d0a6c","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"input_boolean.nap","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":460,"y":540,"wires":[[]]},{"id":"a090cbb9.22de78","type":"server-state-changed","z":"937ef78.ec6b408","name":"Triggers","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sun.sun, input_boolean.nap","entityidfiltertype":"substring","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":[],"x":160,"y":640,"wires":[["a85385bf.3fc478"]]},{"id":"a85385bf.3fc478","type":"api-current-state","z":"937ef78.ec6b408","name":"nap off?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.nap","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":320,"y":640,"wires":[["68a32252.034cbc"],["b202b335.afbe3"]]},{"id":"68a32252.034cbc","type":"api-current-state","z":"937ef78.ec6b408","name":"below horizon?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"below_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":500,"y":620,"wires":[["d9cf5e4e.1da1"],[]]},{"id":"d9cf5e4e.1da1","type":"api-call-service","z":"937ef78.ec6b408","name":"light on","server":"9405c3fe.d0a6c","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":680,"y":600,"wires":[[]]},{"id":"b202b335.afbe3","type":"api-call-service","z":"937ef78.ec6b408","name":"light off","server":"9405c3fe.d0a6c","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":480,"y":660,"wires":[[]]},{"id":"9405c3fe.d0a6c","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}]

I see. your answers make sense.

Putting everything in single big flows makes sense Although for starters its probably easier to seperate everything out, but checking the input bools in individual flows is also easy enough.

But these are exactly the right tips to learn the “design philosophy” of HA and NR. Thanks!

I don’t think it’s about beginners or whatever and I don’t really think it’s easier to separate everything. It just probably is a matter of how one approaches the problem.

For this particular scenario, where you have multiple triggers/conditions and two actions (light on and off), this will be helpful

Suppose you have 3 triggers (a,b,c) that at the same time are conditions. To begin with, if you have never done that, you could do this:

Draw the whole tree and go one by one setting the right service at the end of each branch, like this:

Now it’s time to clean it. In the uppermost end, the uppermost c on? node, it doesn’t matter if the condition is true or false, both lead to a light on service. Same goes with the second c on? node, both ends lead to a light off service, so those conditions can be deleted

The other two c on? nodes have equal results, so the condition that’s irrelevant here is the b on? node. In other words, both ends of the lowermost b on? node have the same result, so b on? condition is irrelevant.

In the long run you’ll learn stronger conditions need to go first, near the triggers node, and weaker ones far apart. In this particular case, the nap condition should be first because, 100% of the times you’re taking the nap, you want the light to go off regardless of the other conditions.

It’s not that hard I believe. Just set a comma separated string of entities in your first node in substring without any particular state and work the tree.