Unipi 1.1 Lite - read from 1W-Sensor in NODERED
-
Hallo,
how can I read temperature, huminity, etc. from 1W-Sensor in NODERED. The standard input-node does not support 1 W-Sensors? -
Hello @Jeff,
the input node does support reading 1-Wire temperature sensors:
-
this flow gets data from unipi 1.1. unipi lite does not have ai ao. Just skip it. temp input is one wire sensor data. the json all node initializes all variables and then websocket delivers actual data.
[{"id":"cad50249.94c0e","type":"tab","label":"unipi1.1 to MQTT","disabled":false,"info":""},{"id":"9d58b57c.1dc5c8","type":"websocket in","z":"cad50249.94c0e","name":"","server":"","client":"84e45387.411c2","x":150,"y":340,"wires":[["f1646973.6f0b08"]]},{"id":"f1646973.6f0b08","type":"json","z":"cad50249.94c0e","name":"","property":"payload","action":"","pretty":false,"x":330,"y":340,"wires":[["317506aa.3aa32a","fa0726fd.a44fb8"]]},{"id":"cdd4d544.02a9f8","type":"mqtt out","z":"cad50249.94c0e","name":"home/ug/Buero/unipi/1","topic":"","qos":"","retain":"","broker":"e78c6663.280d38","x":1180,"y":400,"wires":[]},{"id":"bc4f4c59.0d206","type":"trigger","z":"cad50249.94c0e","op1":"","op2":"1 Stunde keine Meldung von One-Wire Sensoren!","op1type":"nul","op2type":"str","duration":"1","extend":true,"units":"hr","reset":"","bytopic":"all","name":"","x":290,"y":180,"wires":[["1e8f1bff.5ff404"]]},{"id":"7b4c23b3.9cfebc","type":"function","z":"cad50249.94c0e","name":"","func":"msg.payload = msg.topic + \" ---> \" + msg.payload;\nmsg.topic = \"Zeitüberschreitung One-Wire Sensoren\";\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":180,"wires":[["c4704b1c.ce25d8","8e60f8f7.3d3ee8"]]},{"id":"317506aa.3aa32a","type":"switch","z":"cad50249.94c0e","name":"","property":"payload.dev","propertyType":"msg","rules":[{"t":"eq","v":"temp","vt":"str"},{"t":"eq","v":"input","vt":"str"},{"t":"eq","v":"relay","vt":"str"},{"t":"eq","v":"ao","vt":"str"},{"t":"eq","v":"ai","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":490,"y":340,"wires":[["bc4f4c59.0d206","c0a56553.2502e8"],["6168748d.9395fc"],["ec9fec9a.b8bb8"],["bf29c465.fd0b98"],["6ec28c7b.7a5854"]]},{"id":"c4704b1c.ce25d8","type":"debug","z":"cad50249.94c0e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":220,"wires":[]},{"id":"e7b77d5b.681fb","type":"inject","z":"cad50249.94c0e","name":"","topic":"test","payload":"Testmail unipi-big","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":620,"y":140,"wires":[["8e60f8f7.3d3ee8"]]},{"id":"c0a56553.2502e8","type":"function","z":"cad50249.94c0e","name":"temp","func":"var t_loc = \"home/ug/Buero/unipi/1/\";\nmsg.topic = t_loc + msg.payload.dev + \"/\" + msg.payload.circuit;\nmsg.payload = parseFloat(msg.payload.value).toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":910,"y":280,"wires":[["cdd4d544.02a9f8"]]},{"id":"6168748d.9395fc","type":"function","z":"cad50249.94c0e","name":"input","func":"var t_loc = \"home/ug/Buero/unipi/1/\";\nmsg.topic = t_loc + msg.payload.dev + \"/\" + msg.payload.circuit;\nmsg.payload = msg.payload.value;\nreturn msg;","outputs":1,"noerr":0,"x":910,"y":320,"wires":[["cdd4d544.02a9f8"]]},{"id":"ec9fec9a.b8bb8","type":"function","z":"cad50249.94c0e","name":"relay","func":"var t_loc = \"home/ug/Buero/unipi/1/\";\nmsg.topic = t_loc + msg.payload.dev + \"/\" + msg.payload.circuit;\nmsg.payload = msg.payload.value;\nreturn msg;","outputs":1,"noerr":0,"x":910,"y":360,"wires":[["cdd4d544.02a9f8"]]},{"id":"bf29c465.fd0b98","type":"function","z":"cad50249.94c0e","name":"ao","func":"var t_loc = \"home/ug/Buero/unipi/1/\";\nmsg.topic = t_loc + msg.payload.dev + \"/\" + msg.payload.circuit;\nmsg.payload = parseFloat(msg.payload.value).toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":910,"y":400,"wires":[["cdd4d544.02a9f8"]]},{"id":"6ec28c7b.7a5854","type":"switch","z":"cad50249.94c0e","name":"","property":"payload.circuit","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":460,"wires":[["a14e1ae1.a92608"],["dad4982a.d5fe18"]]},{"id":"a14e1ae1.a92608","type":"function","z":"cad50249.94c0e","name":"ai 1","func":"var t_loc = \"home/ug/Buero/unipi/1/\";\nmsg.topic = t_loc + msg.payload.dev + \"/\" + msg.payload.circuit; \nmsg.payload = parseFloat(msg.payload.value).toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":440,"wires":[["7095cd82.073ff4"]]},{"id":"dad4982a.d5fe18","type":"function","z":"cad50249.94c0e","name":"ai 2","func":"var t_loc = \"home/ug/Buero/unipi/1/\";\nmsg.topic = t_loc + msg.payload.dev + \"/\" + msg.payload.circuit; \nmsg.payload = (10.0 - parseFloat(msg.payload.value)).toFixed(2);\n//msg.payload = msg.payload.toFixed(2);\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":480,"wires":[["6749874e.7eb638"]]},{"id":"8e60f8f7.3d3ee8","type":"e-mail","z":"cad50249.94c0e","server":"smtp.gmail.com","port":"465","secure":true,"tls":false,"name":"[email protected]","dname":"[email protected]","x":860,"y":180,"wires":[]},{"id":"1e8f1bff.5ff404","type":"moment","z":"cad50249.94c0e","name":"HH:mm:ss DD-MM-YYYY","topic":"","input":"xyz","inputType":"flow","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss DD-MM-YYYY","locale":"de_DE","output":"topic","outputType":"msg","outTz":"Europe/Berlin","x":490,"y":180,"wires":[["7b4c23b3.9cfebc"]]},{"id":"fa0726fd.a44fb8","type":"debug","z":"cad50249.94c0e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":350,"y":400,"wires":[]},{"id":"5de6d555.65fd4c","type":"inject","z":"cad50249.94c0e","name":"Ubig","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"1.0","x":110,"y":580,"wires":[["1ec43156.0d3ecf"]]},{"id":"1ec43156.0d3ecf","type":"http request","z":"cad50249.94c0e","name":"http://localhost:8080/json/all","method":"GET","ret":"txt","paytoqs":false,"url":"http://localhost:8080/json/all","tls":"","persist":false,"proxy":"","authType":"","x":320,"y":580,"wires":[["fadb47c7.8068d8"]]},{"id":"b0b395e7.71ed48","type":"catch","z":"cad50249.94c0e","name":"catch no success","scope":["1ec43156.0d3ecf","2dbeaf6.88fdf5"],"uncaught":false,"x":220,"y":640,"wires":[["1bbd0392.3fcfec","63a3399c.45f138"]]},{"id":"63a3399c.45f138","type":"delay","z":"cad50249.94c0e","name":"30 sec","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":390,"y":640,"wires":[["1ec43156.0d3ecf"]]},{"id":"1bbd0392.3fcfec","type":"debug","z":"cad50249.94c0e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"error","targetType":"msg","x":400,"y":680,"wires":[]},{"id":"2dbeaf6.88fdf5","type":"function","z":"cad50249.94c0e","name":"no success","func":"node.error(\"json/all no success\", msg); ","outputs":1,"noerr":0,"x":630,"y":640,"wires":[[]]},{"id":"fadb47c7.8068d8","type":"json","z":"cad50249.94c0e","name":"","property":"payload","action":"","pretty":false,"x":510,"y":580,"wires":[["f4c43419.9505e8"]]},{"id":"f4c43419.9505e8","type":"switch","z":"cad50249.94c0e","name":"success","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"success","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":640,"y":580,"wires":[["34618e75.c993a2"],["2dbeaf6.88fdf5"]]},{"id":"34618e75.c993a2","type":"function","z":"cad50249.94c0e","name":"split","func":"var ar = msg.payload.data;\nvar i;\nfor (i = 0; i < ar.length; i++) {\n node.send({payload:ar[i]});\n}\nreturn;","outputs":1,"noerr":0,"x":790,"y":580,"wires":[["a813b8d1.c4b208"]]},{"id":"a813b8d1.c4b208","type":"function","z":"cad50249.94c0e","name":"format","func":"/*\nvar t_loc = \"home/ug/Buero/unipi/1/\";\nmsg.topic = t_loc + msg.payload.dev + \"/\" + msg.payload.circuit;\nswitch (msg.payload.dev){\n case \"temp\":\n msg.payload = parseFloat(msg.payload.value).toFixed(2);\n break;\n case \"input\":\n msg.payload = msg.payload.value;\n break; \n case \"relay\":\n msg.payload = msg.payload.value;\n}\nreturn msg;\n*/\n\nvar t_loc = \"home/ug/Buero/unipi/1/\";\nvar mqtt_topic = t_loc + msg.payload.dev + \"/\" + msg.payload.circuit;\nswitch (msg.payload.dev){\n case \"temp\":\n return{payload:parseFloat(msg.payload.value).toFixed(2),topic:mqtt_topic};\n case \"input\":\n return{payload:msg.payload.value,topic:mqtt_topic};\n case \"relay\":\n return{payload:msg.payload.value,topic:mqtt_topic};\n}\nreturn;","outputs":1,"noerr":0,"x":910,"y":580,"wires":[["cdd4d544.02a9f8"]]},{"id":"c52a64.b19355a","type":"comment","z":"cad50249.94c0e","name":"init input, relay, temp","info":"","x":1120,"y":580,"wires":[]},{"id":"6749874e.7eb638","type":"switch","z":"cad50249.94c0e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"","vt":"prev"}],"checkall":"true","repair":false,"outputs":1,"x":910,"y":480,"wires":[["cdd4d544.02a9f8"]]},{"id":"7095cd82.073ff4","type":"switch","z":"cad50249.94c0e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"","vt":"prev"}],"checkall":"true","repair":false,"outputs":1,"x":910,"y":440,"wires":[["cdd4d544.02a9f8"]]},{"id":"84e45387.411c2","type":"websocket-client","z":"","path":"ws://localhost:8080/ws","tls":"","wholemsg":"false"},{"id":"e78c6663.280d38","type":"mqtt-broker","z":"","broker":"10.0.0.43","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]