# Slide ui with auto trigger

**URL:** <https://discourse.nodered.org/t/slide-ui-with-auto-trigger/15738>\
**Category:** General\
**Created:** [21 September 2019 02:07 UTC](https://discourse.nodered.org/t/slide-ui-with-auto-trigger/15738 "2019-09-21T02:07:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yortz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yortz/32/9480_2.png) [@Yortz](https://discourse.nodered.org/u/Yortz)\
**Post date:** [21 September 2019 02:07 UTC](https://discourse.nodered.org/t/slide-ui-with-auto-trigger/15738/1 "2019-09-21T02:07:55Z")

</div>

I have fan attached with my Pi. I want to make a slide to set threshold for fan controlling. When temperature of Pi higher than slider value fan should turn on automatically. vice-versa turn-off automatically when temperature lower than slider value. Now I have a problem. My flow didn't detect when temperature lower or higher than slider and turn on or off fan automatically. They will detect when you change the slider value higher or lower than Pi temperature only.

```auto
[{"id":"c68ba3ff.2c1a48","type":"ui_slider","z":"d6feabc5.588d9","name":"Temperature Threshold input","label":"Fan Temperature Threshold","tooltip":"","group":"45faa55b.9f4024","order":2,"width":0,"height":0,"passthru":true,"outs":"end","topic":"","min":"30","max":"50","step":1,"x":1423,"y":249.80003356933594,"wires":[["9029177d.9bad88"]]},{"id":"9029177d.9bad88","type":"function","z":"d6feabc5.588d9","name":"Thresholding","func":"var pitemp = parseFloat(flow.get(\"temp\"))\nvar bar = msg.payload;\nif(pitemp <= bar){\n msg.payload = 0\n return [msg, null];\n}\nif(pitemp > bar){\n msg.payload = 1\n return [null, msg];\n}","outputs":2,"noerr":0,"x":1417.9999389648438,"y":334.5999755859375,"wires":[["f0ea95d4.74f0d8","8e94faad.51665"],["1508e18e.ccbcd6","8e94faad.51665"]]},{"id":"f0ea95d4.74f0d8","type":"rpi-gpio out","z":"d6feabc5.588d9","name":"Fan OFF","pin":"40","set":"","level":"0","freq":"","out":"out","x":1629.5,"y":308,"wires":[]},{"id":"1508e18e.ccbcd6","type":"rpi-gpio out","z":"d6feabc5.588d9","name":"Fan ON","pin":"40","set":"","level":"0","freq":"","out":"out","x":1626.5,"y":362,"wires":[]},{"id":"8e94faad.51665","type":"switch","z":"d6feabc5.588d9","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1507.5,"y":418,"wires":[["cf652313.0b11f8"],["2075997a.57a83e"]]},{"id":"cf652313.0b11f8","type":"change","z":"d6feabc5.588d9","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1703.5,"y":397,"wires":[["3418faa2.5de18e"]]},{"id":"2075997a.57a83e","type":"change","z":"d6feabc5.588d9","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1705.5,"y":438,"wires":[["3418faa2.5de18e"]]},{"id":"3418faa2.5de18e","type":"ui_led","z":"d6feabc5.588d9","group":"45faa55b.9f4024","order":3,"width":0,"height":0,"label":"Fan Status","labelPlacement":"left","labelAlignment":"center","colorForValue":[{"color":"red","value":"false","valueType":"bool"},{"color":"gray","value":"true","valueType":"bool"}],"name":"","x":1864.5,"y":414,"wires":[]},{"id":"45faa55b.9f4024","type":"ui_group","z":"","name":"Pi Temperature ","tab":"7dcd8cb2.1a1e5c","order":1,"disp":false,"width":"6","collapse":false},{"id":"7dcd8cb2.1a1e5c","type":"ui_tab","z":"","name":"Home-Pi Status","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [21 September 2019 07:33 UTC](https://discourse.nodered.org/t/slide-ui-with-auto-trigger/15738/2 "2019-09-21T07:33:18Z")

</div>

You don't have any debug nodes in your flow. The first thing to do if you are trying to debug a flow is to place debug nodes so you can see what messages are being passed between the node.

Where are you setting the context value flow "temp"?

You can also add some logging statements into your function to check that the values & logic are what you think they are  
[https://nodered.org/docs/user-guide/writing-functions#logging-events](https://nodered.org/docs/user-guide/writing-functions#logging-events)

Your switch is also configured strangely

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/452c54f6019dfcf28c59e0302b5a631e3aa8081b.png)  
You check to see if msg.payload is a number 0 or a string 1 ( note the AZ before the 1)
