Blocking input_boolean is True

Seems like there should be a node that would “block” if a external value is TRUE and allow flow to continue when false.

Occasionally, I need a way to stop automations form running.
I set up an input_boolean as stop_automations.

I want STOP a flow that is being activated I want to check the value of a stop_automations is true and continue only if the value is false.

Any ideas?

There should be an “expose to home assistant” option that will give you an entity you can disable in HA (or another flow). I have used this in the past, but no longer use node red as the built in automations have gotten better.

Thanks and appreciate the input.

While that is interesting.
But with so many flows that would require Hundreds of Node Red Nodes being exposed, each with a seperate Lovelace Button to turn them on or off.
And although the level of control is enticing maintenance of such would be daunting.

Maybe I’m not understanding your request, but it seems like the current state and switch node would accomplish what you are looking for. Assuming the input boolean you mentioned is your on/off switch for the automation, place a current state node for your input boolean in the flow. Connect that to a switch node with one output for when the msg.payload is “on” and another for when it is “off”. Connect the rest of the flow to whichever state of the input boolean (on / off) you want to allow the automation to execute.

Really appreciate the input.

The idea would be to stop a flow based on the value of a input_boolean that is NOT part of the current flow.

As one example, we had a contractor working on a stairwell and as most people would never be in the stairwell for more than a minute or two, they were there for hours. I had to disable a node in the flow to stop the automation from working until they were finished.

My ides was to implement a input_boolean that could be used within the flow, without impacting the flow to stop it.

So far everything I tried interferes with the flow but does not stop it.

Check state node and set the value to equal to true, which should give you two outputs one for true and one for other states.
Just use the one you need and the other will then work as a dead end for the flow.

I must not be clear.

Here is a typical flow.

[{"id":"8122b560.3b09e8","type":"api-call-service","z":"de182df6.e92bc","name":"office_stairs ON","server":"f0c57d9.41a8f8","version":5,"debugenabled":false,"domain":"light","service":"turn_{{payload}}","areaId":[],"deviceId":[],"entityId":["light.office_stairs_2"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":780,"y":700,"wires":[[]]},{"id":"c84673a8.ac0b5","type":"server-state-changed","z":"de182df6.e92bc","name":" STAIRS Door","server":"f0c57d9.41a8f8","version":4,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Trigger Stairs DOOR "},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.office_stairs_door_contact","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":130,"y":600,"wires":[["d7c7ef1b.6531a","850488081528c228"]]},{"id":"d7c7ef1b.6531a","type":"debug","z":"de182df6.e92bc","name":"STAIRS: mc-ON","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":340,"y":600,"wires":[]},{"id":"f9917606.7612f8","type":"debug","z":"de182df6.e92bc","name":"STAIRS: ON","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":620,"wires":[]},{"id":"850488081528c228","type":"switch","z":"de182df6.e92bc","name":"Stairs on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":660,"wires":[["f9917606.7612f8","9840dd23c59d9aad"],[]]},{"id":"9840dd23c59d9aad","type":"trigger","z":"de182df6.e92bc","name":"","op1":"on","op2":"off","op1type":"str","op2type":"str","duration":"59","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":570,"y":700,"wires":[["8122b560.3b09e8"]]},{"id":"a9d5d1fa053edf48","type":"server-state-changed","z":"de182df6.e92bc","name":" STAIRS Motion","server":"f0c57d9.41a8f8","version":4,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Trigger Stairs Motion"},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.ms_office_stairs_occupancy","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":680,"wires":[["850488081528c228"]]},{"id":"f0c57d9.41a8f8","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":true,"heartbeatInterval":"30"}]

And this is one example of many.
If I insert a “state node” then the flow becomes the “state node” flow and not the original.

Or am I missing something?

There is a node that you can put into your flow that checks the state of a sensor.
It is not a trigger node.

As far as I know, that take over the flow and so it can not be forwarded.

So i might look like:

Where the state input is not related to the flow but the could “switch” the flow to one of the outputs.

You can just put a “current state” node after the motion and hook it up to “STAIRS Door” and tell it to only continue if the state is “on”.

However, a while ago as sort of a proof-of-concept I wanted to see if subflows could be triggered from something other than the input to achieve the same sort of result. It probably looks more trouble than it’s worth, but really I’m just dropping the subflow onto a flow and setting a new id. Then something else enables/disables it. I’m now using it a lot (and haven’t noticed any performance issues since each instance tests each message).

I did this with a subflow that takes an “id” and blocks/allows the flow based on an MQTT message. This is what the subflow looks like:

I used node-red-contrib-simple-gate here because I’m using it elsewhere but it could probably be done differently.

Then I use it like this:

I guess if you want you could set it up with two outputs so you can do something with blocked, but I don’t need that.

The properties for this instance of the subflow look like this:

In this case the id is “visitors” and the status shows it is not currently blocking (otherwise it would say “blocked”). So to block, I would publish an MQTT message to “mb/filter/whatever/retained” containing the following:

{ "id": "visitors", "value": true }

I publish this with retain so that when Node Red (or HA) deploys/restarts it picks up the correct value. For some of them I have created corresponding MQTT switches in HA so I can turn them on/off through the UI, like below, but for others it’s Node Red deciding to enable/block.

  - unique_id: filter_visitors
    name: "Filter Visitors"
    command_topic: "mb/filter/visitors/retained"
    payload_on: '{ "id": "visitors", "value": true }'
    payload_off: '{ "id": "visitors", "value": false }'
    state_topic: "mb/filter/visitors/retained"
    value_template: "{{ 'ON' if value_json['value'] == true else 'OFF' }}"
    state_on: "ON"
    state_off: "OFF"
    qos: 0
    retain: true
    optimistic: true

May be of some use to you.

It was the “current state” node I meant.
I have no access to NR from here, so it was by memory.

I was able to get what I wanted working with the “Gate” node.


Yes, the state node does this, you have to set a if value and then it transforms into two outputs.