# Trigger an action when payload equals a 0

**URL:** <https://discourse.nodered.org/t/trigger-an-action-when-payload-equals-a-0/44876>\
**Category:** General\
**Created:** [28 April 2021 15:20 UTC](https://discourse.nodered.org/t/trigger-an-action-when-payload-equals-a-0/44876 "2021-04-28T15:20:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcaccount](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@dcaccount](https://discourse.nodered.org/u/dcaccount)\
**Post date:** [28 April 2021 15:20 UTC](https://discourse.nodered.org/t/trigger-an-action-when-payload-equals-a-0/44876/1 "2021-04-28T15:20:29Z")

</div>

Hello,  
I would need a Node Red flow able to monitor a MQTT payload and to perform an action (for instance send a mail) **just once** when the payload is detected equal to 0.

I have tried with the switch node but it keeps on triggering the action even if I have set "stopping after the first match".

How can I achieve this?  
Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 April 2021 15:24 UTC](https://discourse.nodered.org/t/trigger-an-action-when-payload-equals-a-0/44876/2 "2021-04-28T15:24:56Z")

</div>

A switch node is the one to use. Show us what value goes into the switch (attach a debug node) and how you have setup the switch node.

---

<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:** [28 April 2021 15:35 UTC](https://discourse.nodered.org/t/trigger-an-action-when-payload-equals-a-0/44876/3 "2021-04-28T15:35:04Z")

</div>

When you say you want it to happen just once do you mean once in the rest of the future of the universe, or once and then don't send again until it leaves zero and then goes back again?  
If the latter then before the switch feed it through an RBE node, so it will only pass on a value when the value changes. Then when it goes to zero your switch node will detect it, but then following zeros will not get passed until a non-zero one appears.

---

<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:** [12 May 2021 15:35 UTC](https://discourse.nodered.org/t/trigger-an-action-when-payload-equals-a-0/44876/4 "2021-05-12T15:35:18Z")

</div>

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