# Trigger node: allow sending 1 and 0 to separate outputs

**URL:** <https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893>\
**Category:** Feature Requests\
**Created:** [30 March 2020 11:57 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893 "2020-03-30T11:57:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![javawizard](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/javawizard/32/19067_2.png) [@javawizard](https://discourse.nodered.org/u/javawizard)\
**Post date:** [30 March 2020 11:57 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893/1 "2020-03-30T11:57:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [30 March 2020 12:23 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893/2 "2020-03-30T12:23:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [30 March 2020 12:50 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893/3 "2020-03-30T12:50:44Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 March 2020 12:52 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893/4 "2020-03-30T12:52:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [30 March 2020 12:55 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893/5 "2020-03-30T12:55:23Z")

</div>

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](https://github.com/node-red/node-red/pull/2436)

This will be in 1.1.0 as and when that arrives.

---

<div class="post-metadata">

**Author:** ![javawizard](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/javawizard/32/19067_2.png) [@javawizard](https://discourse.nodered.org/u/javawizard)\
**Post date:** [31 March 2020 08:30 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893/6 "2020-03-31T08:30:54Z")

</div>

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!)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [31 March 2020 09:36 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893/7 "2020-03-31T09:36:47Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 May 2020 09:36 UTC](https://discourse.nodered.org/t/trigger-node-allow-sending-1-and-0-to-separate-outputs/23893/8 "2020-05-30T09:36:53Z")

</div>

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