首页 > 解决方案 > 基于节点红色温度的灯或风扇

问题描述

我正在将传感器中的温度值检索到一个函数中。如何通过拨动开关打开或关闭连接到覆盆子引脚的东西。尝试 if else in function 但它不会返回布尔值。

标签: javascriptraspberry-piiotnode-red

解决方案


也许这个流程可以帮助你...... :)

节点红色流概述

[{"id":"b91e3004.20d918","type":"inject","z":"96584deb.e06cd8","name":"temperature = 5","topic":"","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":480,"wires":[["8ed1e022.82aef8","90a9aef0.51dda"]]},{"id":"8ed1e022.82aef8","type":"function","z":"96584deb.e06cd8","name":"temp >= 10","func":"\nmsg.payload = (msg.payload >= 10);\n\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":460,"wires":[["b639cd87.885478","e13b38f4.0af918"]]},{"id":"b639cd87.885478","type":"debug","z":"96584deb.e06cd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":440,"wires":[]},{"id":"c44cdc90.fc2388","type":"inject","z":"96584deb.e06cd8","name":"temperature = 20","topic":"","payload":"20","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":540,"wires":[["8ed1e022.82aef8","90a9aef0.51dda"]]},{"id":"e13b38f4.0af918","type":"rpi-gpio out","z":"96584deb.e06cd8","name":"","pin":"7","set":"","level":"0","freq":"","out":"out","x":650,"y":480,"wires":[]},{"id":"90a9aef0.51dda","type":"switch","z":"96584deb.e06cd8","name":"temp >= 10","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"10","vt":"str"},{"t":"lt","v":"10","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":560,"wires":[["72eff73c.7845b"],["268e12dd.9e100e"]]},{"id":"72eff73c.7845b","type":"template","z":"96584deb.e06cd8","name":"true","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"true","output":"str","x":650,"y":540,"wires":[["28a0b8f8.67062"]]},{"id":"28a0b8f8.67062","type":"rpi-gpio out","z":"96584deb.e06cd8","name":"","pin":"7","set":"","level":"0","freq":"","out":"out","x":790,"y":560,"wires":[]},{"id":"268e12dd.9e100e","type":"template","z":"96584deb.e06cd8","name":"false","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"false","output":"str","x":650,"y":580,"wires":[["28a0b8f8.67062"]]}]


推荐阅读