A bit more complex local intelligence

by 00:39 0 commenti

NODE-RED FLOW

[{"id":"d841eafa.45c728","type":"inject","z":"51acd361.27dd1c","name":"Sense Temp","topic":"temp","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"x":193.25,"y":212.50000286102295,"wires":[["49d1d538.a03a1c"]]},{"id":"a5898d5e.54668","type":"inject","z":"51acd361.27dd1c","name":"Sense Hum","topic":"hum","payload":"3","payloadType":"num","repeat":"","crontab":"","once":false,"x":196,"y":364,"wires":[["49d1d538.a03a1c"]]},{"id":"49d1d538.a03a1c","type":"function","z":"51acd361.27dd1c","name":"Think","func":"// initialise the counter to 0 if it doesn't exist already\n// http://nodered.org/docs/writing-functions.html\n\nvar hum = context.get('hum')||false;\nvar temp = context.get('temp')||false;\n\nmsg.payload=\"false\";\n\nif (msg.topic==\"hum\"){\n    context.set('hum',true);\n    hum = true;\n}\n    \nif (msg.topic==\"temp\"){\n    context.set('temp',true);\n    temp = true;\n}\n\nmsg.payload = hum && temp;\nif (hum && temp){\n   context.set('hum',false);\n   context.set('temp',false);\n}\n    \nreturn msg;","outputs":1,"noerr":0,"x":329.00000381469727,"y":293.2500047683716,"wires":[["4ab8dff8.39a75"]]},{"id":"4ab8dff8.39a75","type":"debug","z":"51acd361.27dd1c","name":"Actuate","active":false,"console":"false","complete":"payload","x":501.00000762939453,"y":296.50000381469727,"wires":[]}]

andrea

Developer

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 commenti:

Posta un commento

Nota. Solo i membri di questo blog possono postare un commento.