Node-HIU Flows

From Heatweb Wiki
Revision as of 14:11, 28 October 2017 by Rhg (talk | contribs)
Jump to navigationJump to search

Node-HIU Flows for Node-RED

automation phat

[{"id":"f13ecf89.2b5ad","type":"tab","label":"AutoPhat","disabled":false,"info":""},{"id":"ee3768b1.b8e648","type":"template","z":"f13ecf89.2b5ad","name":"python","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"#!/usr/bin/python\nimport time\nimport automationhat\nimport sys\nfrom sys import argv\nimport os.path\nimport os\n\ntry:\n\tscript, command, value = argv\nexcept ValueError:\n\tcommand = 'relay'\n\tvalue = '0'\n\noutput = 'error'\ncommand = 'relay'\n\nwhile 1==1:\n    time.sleep(5)\n    \n    if 1==1:\n        logFile = '/var/www/html/logs/automationphat.txt'\n        f1 = open(logFile, 'r')\n    \tusbuse = f1.read()\n#    \tprint usbuse\n    \tf1.close()\n    \tvalue,b,c = usbuse.split(',')\n\n    \t\n#    except:\n#    \tvalue = '0'\n    \n#    print command\n#    print value\n    if command == 'relay':\n    \tif value == '1':\n    \t\tautomationhat.relay.one.on()\n    \t\toutput = 'relay on'\n    \telif value == '0':\n    \t\tautomationhat.relay.one.off()\n    \t\toutput = 'relay off'\n    \n    print(\"%s,%s,%s,%s\" % (automationhat.analog.one.read(),automationhat.analog.two.read(),automationhat.analog.three.read(),output))\n    \n \n\n\n\n\n","output":"str","x":288,"y":81,"wires":[["d43925b4.057838"]]},{"id":"38ef97e2.c11c68","type":"inject","z":"f13ecf89.2b5ad","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":140,"y":80,"wires":[["ee3768b1.b8e648"]]},{"id":"d43925b4.057838","type":"file","z":"f13ecf89.2b5ad","name":"","filename":"/home/pi/node-hiu/automationphat.py","appendNewline":false,"createDir":true,"overwriteFile":"true","x":528,"y":81,"wires":[]},{"id":"672933b5.79e32c","type":"exec","z":"f13ecf89.2b5ad","command":"python /home/pi/node-hiu/automationphat.py","addpay":true,"append":"","useSpawn":"true","timer":"","oldrc":true,"name":"anain 2","x":380,"y":160,"wires":[["5fea12fa.d46c6c"],[],[]]},{"id":"7394647f.61427c","type":"inject","z":"f13ecf89.2b5ad","name":"","topic":"","payload":" anain 2","payloadType":"str","repeat":"","crontab":"","once":true,"x":160,"y":160,"wires":[["672933b5.79e32c"]]},{"id":"ec3e3980.218798","type":"debug","z":"f13ecf89.2b5ad","name":"","active":true,"console":"false","complete":"false","x":730,"y":160,"wires":[]},{"id":"de79b6c.48055c8","type":"inject","z":"f13ecf89.2b5ad","name":"kill","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":110,"y":220,"wires":[["f01c5f1a.35e4e"]]},{"id":"e2b7885c.8e4738","type":"comment","z":"f13ecf89.2b5ad","name":"install","info":"curl https://get.pimoroni.com/automationhat | bash","x":110,"y":620,"wires":[]},{"id":"e5e7eec.1798d1","type":"debug","z":"f13ecf89.2b5ad","name":"","active":true,"console":"false","complete":"false","x":650,"y":340,"wires":[]},{"id":"dfb795dc.bdae18","type":"range","z":"f13ecf89.2b5ad","minin":"0.5","maxin":"3.5","minout":"0","maxout":"100","action":"scale","round":false,"name":"Grundfos Temp","x":560,"y":260,"wires":[["7c3a636e.f51c1c"]]},{"id":"4215bc6d.5b7254","type":"function","z":"f13ecf89.2b5ad","name":"","func":"msg.payload=parseFloat(msg.payload.split(\",\")[1])\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":260,"wires":[["dfb795dc.bdae18"]]},{"id":"33599006.a52b7","type":"file","z":"f13ecf89.2b5ad","name":"","filename":"/var/www/html/logs/automationphat.txt","appendNewline":false,"createDir":false,"overwriteFile":"true","x":490,"y":540,"wires":[]},{"id":"46773a95.f49064","type":"inject","z":"f13ecf89.2b5ad","name":"","topic":"","payload":"1,0,0","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":540,"wires":[["33599006.a52b7"]]},{"id":"feb655e8.b10788","type":"template","z":"f13ecf89.2b5ad","name":"python","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"#!/usr/bin/python\nimport time\nimport automationhat\nimport sys\n\nfrom sys import argv\n\n\ntry:\n\tscript, command, value = argv\nexcept ValueError:\n\tcommand = 'anain'\n\tvalue = '1'\n\noutput = 'error'\n\nif 1==1:\n    time.sleep(1)\n    \n    if command == 'relay':\n    \tif value == '1':\n    \t\tautomationhat.relay.one.on()\n    \t\toutput = 'relay on'\n    \telif value == '0':\n    \t\tautomationhat.relay.one.off()\n    \t\toutput = 'relay off'\n    \n    elif command == 'anain':\n    \tif value == '1':\n    \t\toutput = automationhat.analog.one.read()\n    \telif value == '2':\n    \t\toutput = automationhat.analog.two.read()\n    \telif value == '3':\n    \t\toutput = automationhat.analog.three.read()\n    \n    print(output)\n\n\n\n\n","output":"str","x":270,"y":40,"wires":[[]]},{"id":"4ba18423.e9c64c","type":"inject","z":"f13ecf89.2b5ad","name":"","topic":"","payload":"0,0,0","payloadType":"str","repeat":"","crontab":"","once":false,"x":190,"y":580,"wires":[["33599006.a52b7"]]},{"id":"f01c5f1a.35e4e","type":"change","z":"f13ecf89.2b5ad","name":"kill","rules":[{"t":"set","p":"kill","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":220,"wires":[["672933b5.79e32c"]]},{"id":"5fea12fa.d46c6c","type":"switch","z":"f13ecf89.2b5ad","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":",","vt":"str"}],"checkall":"true","outputs":1,"x":530,"y":160,"wires":[["ec3e3980.218798","4215bc6d.5b7254"]]},{"id":"7c3a636e.f51c1c","type":"function","z":"f13ecf89.2b5ad","name":"","func":"msg.payload=parseInt(msg.payload*10) /10;\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":340,"wires":[["e5e7eec.1798d1"]]}]