# Temp sensor - Trigger activity only when mowing from -1 to 0 , not on any other temp changes

**URL:** https://discourse.nodered.org/t/temp-sensor-trigger-activity-only-when-mowing-from-1-to-0-not-on-any-other-temp-changes/18572
**Category:** General
**Created:** [28 November 2019 19:13 UTC](https://discourse.nodered.org/t/temp-sensor-trigger-activity-only-when-mowing-from-1-to-0-not-on-any-other-temp-changes/18572 "2019-11-28T19:13:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Soiski](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/soiski/32/88848_2.png) [@Soiski](https://discourse.nodered.org/u/Soiski)
#### Post date: [28 November 2019 19:13 UTC](https://discourse.nodered.org/t/temp-sensor-trigger-activity-only-when-mowing-from-1-to-0-not-on-any-other-temp-changes/18572/1 "2019-11-28T19:13:48Z")

</div>

I am really hitting the wall now. I have tried several different methods to figure this out (RBE, Changing values to different ; like zero to 100 to help on calculations) but have failed to find error proof method of triggering a certain event when moving from negative temp (i.e. -1) to zero. No other changes inside negative or positive range should do anything.

I guess there is a simple way to do it but I can not see the forest any more from the trees...or vice versa 🙂

Thank you for your help!

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [28 November 2019 19:22 UTC](https://discourse.nodered.org/t/temp-sensor-trigger-activity-only-when-mowing-from-1-to-0-not-on-any-other-temp-changes/18572/2 "2019-11-28T19:22:49Z")

</div>

With function node seems to be simplest

```auto
[{"id":"a21b81f1.c7666","type":"function","z":"6d08d5ab.a8aa3c","name":"trigger ","func":"var last = context.get(\"last\")||0\nif(last < 0 && msg.payload >= 0){\n var trigger = {payload:\"what ever is needed to be sent\"}\n node.send(trigger)\n}\ncontext.set(\"last\",msg.payload)\n","outputs":1,"noerr":0,"x":340,"y":270,"wires":[["166a2580.07a90b"]]},{"id":"cdcf5c96.53b0c","type":"inject","z":"6d08d5ab.a8aa3c","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":190,"wires":[["a21b81f1.c7666"]]},{"id":"6e35e3fb.a5d75c","type":"inject","z":"6d08d5ab.a8aa3c","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":260,"wires":[["a21b81f1.c7666"]]},{"id":"fb4976b1.6be6f8","type":"inject","z":"6d08d5ab.a8aa3c","name":"","topic":"","payload":"-1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":320,"wires":[["a21b81f1.c7666"]]},{"id":"166a2580.07a90b","type":"debug","z":"6d08d5ab.a8aa3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":500,"y":270,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![Soiski](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/soiski/32/88848_2.png) [@Soiski](https://discourse.nodered.org/u/Soiski)
#### Post date: [28 November 2019 19:26 UTC](https://discourse.nodered.org/t/temp-sensor-trigger-activity-only-when-mowing-from-1-to-0-not-on-any-other-temp-changes/18572/3 "2019-11-28T19:26:46Z")

</div>

Thank you @hotNipi.

Works great !
