# How to conditionally pass-through a numeric value

**URL:** <https://discourse.nodered.org/t/how-to-conditionally-pass-through-a-numeric-value/46981>\
**Category:** General\
**Created:** [10 June 2021 11:35 UTC](https://discourse.nodered.org/t/how-to-conditionally-pass-through-a-numeric-value/46981 "2021-06-10T11:35:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![steerage250](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steerage250/32/38999_2.png) [@steerage250](https://discourse.nodered.org/u/steerage250)\
**Post date:** [10 June 2021 11:35 UTC](https://discourse.nodered.org/t/how-to-conditionally-pass-through-a-numeric-value/46981/1 "2021-06-10T11:35:55Z")

</div>

I want logic that will pass-through a numeric value input if an input\_boolean is true.

I have a feeling the Switch node is an appropriate node, but am having trouble defining the condition correctly.

Should I be selecting the Property type as Global ? That is: "Global.input\_boolean.test\_mode"

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 June 2021 12:10 UTC](https://discourse.nodered.org/t/how-to-conditionally-pass-through-a-numeric-value/46981/2 "2021-06-10T12:10:31Z")

</div>

So you have a msg being passed thru the wires. Let’s say the msg has a msg.payload which is a number 55. And the msg has a msg.test property that is a Boolean and in this case it is `true`.

You could easily use a `switch node to test msg.test to see if it was a Boolean and in this case the msg would be passed on to the next node.

---

<div class="post-metadata">

**Author:** ![steerage250](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steerage250/32/38999_2.png) [@steerage250](https://discourse.nodered.org/u/steerage250)\
**Post date:** [11 June 2021 03:12 UTC](https://discourse.nodered.org/t/how-to-conditionally-pass-through-a-numeric-value/46981/3 "2021-06-11T03:12:47Z")

</div>

thanks for your response zenofmud.

So I would use a Change node (for example) to add the boolean property to the message, and then use a switch node to test that property? It seems like an extra step than should be needed, but if it works, I'm happy. However, I still have the same issue in the change node in referring to the input\_boolean value. JSON, Jsonata etc are all a bit of an unknown to me. However, if it I could work-out how to read the value of the input\_boolean in a Change node, I could probably use the same method to refer to the input\_boolean in the switch node? - and miss the extra step of the Change node ?

---

<div class="post-metadata">

**Author:** ![steerage250](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steerage250/32/38999_2.png) [@steerage250](https://discourse.nodered.org/u/steerage250)\
**Post date:** [11 June 2021 03:24 UTC](https://discourse.nodered.org/t/how-to-conditionally-pass-through-a-numeric-value/46981/4 "2021-06-11T03:24:24Z")

</div>

ah - I found it. You can refer to an input\_boolean in Jsonata with the following: $globalContext("homeassistant.homeAssistant.states[''].state")

I was able to use this in a Switch node so that the message value would only pass through if the input\_boolean is true.

Problem solved.

---

<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:** [25 June 2021 03:24 UTC](https://discourse.nodered.org/t/how-to-conditionally-pass-through-a-numeric-value/46981/5 "2021-06-25T03:24:24Z")

</div>

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