Trigger node: allow sending 1 and 0 to separate outputs

So I'm just getting started with Node-RED within my Home Assistant installation and already I'm finding myself repeating a pattern on a fairly frequent basis: a trigger node followed immediately by a switch node to send the "start" and "stop" states to two different places.

It seems like a reasonably common use case, so I'm thinking about taking a stab at adding a "send 'start' and 'stop' states to separate outputs" checkbox to the trigger node's configuration that, when checked:

  • adds a second output to the trigger node, and
  • sends the "off" message to that output instead of the first output

and so that pattern can be done using one node instead of two.

Anyway. Any reason I shouldn't go ahead with that? Alternatively, is there an obvious way to do that with a different node that I've totally overlooked?

A few things come to mind

Start and stops can be lots of things 1,0 "1","0" "start" "stop" "Start" ,"Stop" true,false "true","false" etc etc

And IME - I send start/stop commands down the same route to the same device so I'm wondering how common a use case it would be?

It seems like a reasonably common use case

Perhaps from a home assistant perspective, but many folks don't use that. The trigger node triggers the stop/start ?
And if you are repeating your patterns, perhaps you can make use of topics to differentiate between sources.

Can you explain what you are doing that requires stop and start to go down different routes?

Hi @javawizard

as luck would have it, we already have a PR waiting to be merged to add an optional second output to the trigger node - https://github.com/node-red/node-red/pull/2436

This will be in 1.1.0 as and when that arrives.

1 Like

Perfect, that looks like exactly what I'm looking for. Thanks @knolleary!

To answer some of the other questions that came up:

Can you explain what you are doing that requires stop and start to go down different routes?

@Colin - in Home Assistant land it's common for two separate blocks to be required to turn a given device on and off. One example of this would be setting up a light to turn on when a button is pressed and then turn off some amount of time later - and to reset the timer if the button is pressed while the light is still on. That could be done with a trigger node whose outputs are split with the on output going to a node that turns the light on and the off output going to a node that turns the light off.

I haven't figured out if there's a way to create a node that turns a light on or off depending on the message payload - that would address some of the use cases for separate trigger outputs, but not all. Another common case in my setup is to have lights that dim a few minutes before they go off to alert occupants that they need to push the button to reset the timer if they're still there. That's an easy trigger -> split -> dim -> stoptimer -> off flow, with the other split output turning the light on when the button is pressed.

(Probably way more detail than you wanted!)

Start and stops can be lots of things 1,0 "1","0" "start" "stop" "Start" ,"Stop" true,false "true","false" etc etc

@cymplecy - I'm not sure how this is relevant. The two outputs would of course send appropriate messages whenever the trigger was triggered or timed out.

And IME - I send start/stop commands down the same route to the same device so I'm wondering how common a use case it would be?

Oh interesting. Is this with Home Assistant as well? If so, what's the best way to switch a device on or off depending on the payload of a message? As mentioned above that doesn't address all of my use cases, but it definitely would address some of them.

Perhaps from a home assistant perspective, but many folks don't use that.

@bakman2 - That's true, and I don't know what the standard of inclusion for a feature in Node-RED's core is. It seems like a generically useful thing, but I can't speak to what if any usage it would see outside use cases relating to Home Assistant.

And if you are repeating your patterns, perhaps you can make use of topics to differentiate between sources.

I'm not sure I understand how this would help me. Either way I'd have to switch on something, whether that's the topic or otherwise, right? Or does Node-RED have special handling built in when it comes to topics that I'm not familiar with? (I am totally new to this, so I could be missing something obvious!)

I thought you wanted to send specific start/stop not generic ones

I don't use Home Assistant so didn't know how it works

But nice to see the option being made available - it could come in handy one day :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.