# Compare 2 attributes from same message and trigger 2 actions based on it

**URL:** https://discourse.nodered.org/t/compare-2-attributes-from-same-message-and-trigger-2-actions-based-on-it/34747
**Category:** General
**Created:** [24 October 2020 13:59 UTC](https://discourse.nodered.org/t/compare-2-attributes-from-same-message-and-trigger-2-actions-based-on-it/34747 "2020-10-24T13:59:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![slaz](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@slaz](https://discourse.nodered.org/u/slaz)
#### Post date: [24 October 2020 13:59 UTC](https://discourse.nodered.org/t/compare-2-attributes-from-same-message-and-trigger-2-actions-based-on-it/34747/1 "2020-10-24T13:59:55Z")

</div>

Hello,

Sorry for the dumb question in here but I try to set up nodered with home assistant and take care of some automation. The problem that I face is that I need to compare some temperature as it follows: if desired temperature (called temperature) is higher then actual temperature (called current\_temperature) I want to trigger a switch action and if the desired temperature is equal or lower then the actual temperature I want to trigger another switch action. The problem is that I don't see how I can compare 2 attributes from the current state message. My message is this:

 ![Capture2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/fe4b5e9560694c6ecffff2946f64d83e7747fb5a.jpeg)

Thanks lots in advance for the help. Much appreciated

---

<div class="post-metadata">

### Author: ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)
#### Post date: [24 October 2020 14:04 UTC](https://discourse.nodered.org/t/compare-2-attributes-from-same-message-and-trigger-2-actions-based-on-it/34747/2 "2020-10-24T14:04:29Z")

</div>

You have written the answer yourself, use a switch node 😃 , in the debug tab you can copy the path to the value and use it for compering in switch node.

In properties you can declare what will be outputed on output one (\<\>= etc...)  
Use one output for higher and one for lower.  
I am on my phone and can't build up the flow but will be happy to help you if you have any problems setting it up...

---

<div class="post-metadata">

### Author: ![slaz](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@slaz](https://discourse.nodered.org/u/slaz)
#### Post date: [24 October 2020 14:13 UTC](https://discourse.nodered.org/t/compare-2-attributes-from-same-message-and-trigger-2-actions-based-on-it/34747/3 "2020-10-24T14:13:38Z")

</div>

Thanks for the reply. I am trying with the switch but I would need some more guidance if you would be kind. Thanks lots in advance

---

<div class="post-metadata">

### Author: ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)
#### Post date: [24 October 2020 14:34 UTC](https://discourse.nodered.org/t/compare-2-attributes-from-same-message-and-trigger-2-actions-based-on-it/34747/5 "2020-10-24T14:34:57Z")

</div>

Try it like this , output one is for if temperature \> current\_temperature and output 2 is temperature \<= current\_temperature

```auto
[{"id":"6b8c44a4.697824","type":"switch","z":"4cb4f60b.341b2","name":"","property":"0.new_state.current_temperature","propertyType":"msg","rules":[{"t":"lt","v":"0.new_state.temperature","vt":"msg"},{"t":"gte","v":"0.new_state.temperature","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":340,"wires":[[],[]]}]

```

---

<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: [23 December 2020 14:35 UTC](https://discourse.nodered.org/t/compare-2-attributes-from-same-message-and-trigger-2-actions-based-on-it/34747/6 "2020-12-23T14:35:02Z")

</div>

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