基于节点红色的温度灯或风扇

时间:2019-07-16 11:12:05

标签: javascript raspberry-pi iot node-red

我正在从传感器获取温度值到一个函数中。我如何通过拨动开关打开或关闭连接到树莓针的东西。尝试在函数中是否其他,但不会返回布尔值。

1 个答案:

答案 0 :(得分:0)

也许此流程可以帮助您... :)

node-red flow overview

[{"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"]]}]