# Switch node help

**URL:** <https://discourse.nodered.org/t/switch-node-help/52775>\
**Category:** General\
**Created:** [26 October 2021 18:53 UTC](https://discourse.nodered.org/t/switch-node-help/52775 "2021-10-26T18:53:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mantellian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mantellian/32/50008_2.png) [@mantellian](https://discourse.nodered.org/u/mantellian)\
**Post date:** [26 October 2021 18:53 UTC](https://discourse.nodered.org/t/switch-node-help/52775/1 "2021-10-26T18:53:17Z")

</div>

I’m attempting to use the payload from a temperature sensor as the property for a switch node. I also have a slider in Home Assistant that controls an input number in node red. I’m trying to take the payload form the input number and use it as the values for the switch node that the property is being checked against.

This is what I currently have

 ![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/4/74c1bc131e196243fb75394ff385a6b41f835a1d.jpeg)

`[{"id":"32bc9d642fe3ac62","type":"tab","label":"","disabled":false,"info":""},{"id":"65c768c9f86812da","type":"debug","z":"32bc9d642fe3ac62","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1110,"y":340,"wires":[]},{"id":"85ec2bf98594b7c0","type":"inject","z":"32bc9d642fe3ac62","name":"Inject Temp 33","props":[{"p":"payload.DS18B20.Temperature","v":"33","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":240,"y":380,"wires":[["18a840f7c09cf4f5","f72a0de7638ae0ac"]]},{"id":"6b68fe813853e5f4","type":"debug","z":"32bc9d642fe3ac62","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1110,"y":240,"wires":[]},{"id":"faab44569ca98d3d","type":"debug","z":"32bc9d642fe3ac62","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":180,"wires":[]},{"id":"f259bb559d2c6102","type":"inject","z":"32bc9d642fe3ac62","name":"Inject Temp 25","props":[{"p":"payload.DS18B20.Temperature","v":"25","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":240,"y":200,"wires":[["faab44569ca98d3d","f72a0de7638ae0ac"]]},{"id":"18a840f7c09cf4f5","type":"debug","z":"32bc9d642fe3ac62","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":380,"wires":[]},{"id":"98667477bce0f152","type":"server-state-changed","z":"32bc9d642fe3ac62","name":"","server":"8cd93e38.ec024","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.ds18b20_hi_fault","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload.input_number.ds18b20_hi_fault.set_point","propertyType":"msg","value":"","valueType":"entityState"}],"x":330,"y":280,"wires":[["c36c3ac896dcaa54","f72a0de7638ae0ac"]]},{"id":"c36c3ac896dcaa54","type":"debug","z":"32bc9d642fe3ac62","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":360,"wires":[]},{"id":"f72a0de7638ae0ac","type":"switch","z":"32bc9d642fe3ac62","name":"","property":"payload.DS18B20.Temperature","propertyType":"msg","rules":[{"t":"lt","v":"payload.input_number.ds18b20_hi_fault.set_point","vt":"msg"},{"t":"gte","v":"payload.input_number.ds18b20_hi_fault.set_point","vt":"msg"}],"checkall":"true","repair":false,"outputs":2,"x":810,"y":280,"wires":[["6b68fe813853e5f4"],["65c768c9f86812da"]]},{"id":"8cd93e38.ec024","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]`

I am new to Node-Red and perhaps what I’m attempting to do isn’t possible.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 October 2021 20:13 UTC](https://discourse.nodered.org/t/switch-node-help/52775/2 "2021-10-26T20:13:47Z")

</div>

You need to read the post on how to post code here.

There is a button at the _top_ of the window when you are entering your post.  
It is the `</>` button.  
[https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/2](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/2)

---

<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:** [26 October 2021 21:18 UTC](https://discourse.nodered.org/t/switch-node-help/52775/3 "2021-10-26T21:18:37Z")

</div>

Node-red messages arrive at a node at different times so if you want to check the values of two different inputs (messages) then you need to 'join' them before comparing them.

You could use a `join` node

Or, if the slide is setting the temperature you wanted to get to, you could have three different flows.  
FLOW 1: an inject connected to a change node. The inject is set to run when ever you deploy. the change node sets a flow variable (lets call it flow.setting) to an initial value.  
FLOW 2: the slider sends a value to a change node which put it in flow variable (flow.setting).  
FLOW 3: The sensor gets a reading and ends it to a `switch` node that checks the value against the flow variable (flow.setting). You could have three test 'greater than', 'equal' or 'less than'. You then send each output to more nodes that do what you want for that condition

---

<div class="post-metadata">

**Author:** ![mantellian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mantellian/32/50008_2.png) [@mantellian](https://discourse.nodered.org/u/mantellian)\
**Post date:** [26 October 2021 22:19 UTC](https://discourse.nodered.org/t/switch-node-help/52775/4 "2021-10-26T22:19:43Z")

</div>

> There is a button at the _top_ of the window when you are entering your post.  
> It is the `</>` button.

Found it and edited post, thanks.

---

<div class="post-metadata">

**Author:** ![mantellian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mantellian/32/50008_2.png) [@mantellian](https://discourse.nodered.org/u/mantellian)\
**Post date:** [26 October 2021 22:21 UTC](https://discourse.nodered.org/t/switch-node-help/52775/5 "2021-10-26T22:21:44Z")

</div>

Thanks, I will take a look at the join node and search for examples.

I currently have the set point hard coded in a different flow and it works. I was just trying to see if I could do it a different way for a project I'm considering in the future. I like the idea of having a set point that I can change from a ui.

---

<div class="post-metadata">

**Author:** ![mantellian](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mantellian/32/50008_2.png) [@mantellian](https://discourse.nodered.org/u/mantellian)\
**Post date:** [30 October 2021 15:57 UTC](https://discourse.nodered.org/t/switch-node-help/52775/6 "2021-10-30T15:57:29Z")

</div>

Thanks zenofmud for point me in the right direction. I spent a day reading the documentation and playing around with the join node. It works perfectly for what I wanted to accomplish. I've actually improved some of my other flows using it.

---

<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:** [13 November 2021 15:57 UTC](https://discourse.nodered.org/t/switch-node-help/52775/7 "2021-11-13T15:57:38Z")

</div>

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