Extractor hood controll with amazon echo

Al flow to controll a extractor hood by Amazon echo, UI on you smatphone or console and physical button on the extractor hood. Pressing a button twice on the extrator hood will start a timer to delay power off.

[{"id":"f5229fd2.73d47","type":"tab","label":"Extractor hood","disabled":false,"info":""},{"id":"9958f323.d9a4d","type":"rpi-gpio out","z":"f5229fd2.73d47","name":"light","pin":"15","set":"","level":"0","freq":"","out":"out","x":1070,"y":500,"wires":[]},{"id":"7f38880.5527778","type":"rpi-gpio out","z":"f5229fd2.73d47","name":"speed 1","pin":"7","set":"","level":"0","freq":"","out":"out","x":1080,"y":320,"wires":[]},{"id":"fd9023ed.968da","type":"rpi-gpio out","z":"f5229fd2.73d47","name":"speed 2","pin":"11","set":false,"level":"1","freq":"","out":"out","x":1080,"y":380,"wires":[]},{"id":"b422224a.d965d","type":"rpi-gpio out","z":"f5229fd2.73d47","name":"speed 3","pin":"13","set":false,"level":"1","freq":"","out":"out","x":1080,"y":440,"wires":[]},{"id":"aee1b1f7.507de","type":"alexa-home","z":"f5229fd2.73d47","conf":"8867bf48.2d483","device":"4915","acknoledge":true,"name":"Extractor hood one","topic":"speedone","x":570,"y":100,"wires":[["295581a0.44586e"]]},{"id":"33117d19.d37232","type":"alexa-home","z":"f5229fd2.73d47","conf":"8867bf48.2d483","device":"4916","acknoledge":true,"name":"Extractor hood two","topic":"speedtwo","x":570,"y":160,"wires":[["295581a0.44586e"]]},{"id":"7f174858.93a188","type":"alexa-home","z":"f5229fd2.73d47","conf":"8867bf48.2d483","device":"4917","acknoledge":true,"name":"Extractor hood three","topic":"speedthree","x":570,"y":220,"wires":[["295581a0.44586e"]]},{"id":"c001aa41.616378","type":"ui_button","z":"f5229fd2.73d47","name":"","group":"b6f71680.9527d8","order":0,"width":0,"height":0,"passthru":true,"label":" Speed 1 ","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"speedone","x":480,"y":460,"wires":[["295581a0.44586e"]]},{"id":"9440d5df.7839b8","type":"ui_button","z":"f5229fd2.73d47","name":"","group":"b6f71680.9527d8","order":0,"width":0,"height":0,"passthru":true,"label":"Speed 2","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"speedtwo","x":480,"y":500,"wires":[["295581a0.44586e"]]},{"id":"af743ada.cbb8b8","type":"ui_button","z":"f5229fd2.73d47","name":"","group":"b6f71680.9527d8","order":0,"width":0,"height":0,"passthru":true,"label":" Speed 3 ","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"speedthree","x":480,"y":680,"wires":[["295581a0.44586e"]]},{"id":"e5cdeed.c6c1b1","type":"ui_button","z":"f5229fd2.73d47","name":"","group":"b6f71680.9527d8","order":0,"width":0,"height":0,"passthru":true,"label":"OFF","color":"","bgcolor":"","icon":"","payload":"false","payloadType":"bool","topic":"default","x":90,"y":220,"wires":[["295581a0.44586e","96504b4b.0e60a8"]]},{"id":"e9400a1.ce6f5f8","type":"alexa-home","z":"f5229fd2.73d47","conf":"8867bf48.2d483","device":"4970","acknoledge":true,"name":"Extractor hood","topic":"default","x":560,"y":40,"wires":[["295581a0.44586e"]]},{"id":"842c3431.1f0b58","type":"comment","z":"f5229fd2.73d47","name":"explanation","info":"Extractor hood relais function.\nspeed 1 relais one is on.\nspeed 2 relais two is on.\nspeed 3 relais three is on.\npressing a button will set the speed.\npressing a button twice onm the extractor hood will start the button timer and send a signal to the delay.\nThe off butoon on the extractor hood will send a signal to button 2 and 3 almostthe same time. \nwhen this accours Ad-hoc OFF will send a signal.\n\nInitialisatie will set flow Z to the right position.","x":130,"y":40,"wires":[]},{"id":"295581a0.44586e","type":"function","z":"f5229fd2.73d47","name":"ON","func":"var one = null;\nvar two = null;\nvar three = null;\nvar ON = 0;\nvar OFF = 1;\nvar light = null;\n\nif (msg.payload){ var status = 0;}\nif (!msg.payload){ var status = 1;}\n\nswitch (msg.topic)\n    {\n    case \"speedone\":\n        one = {payload:status};\n        two = {payload:OFF};\n        three = {payload:OFF};\n        light = {payload:ON};\n        break;\n    case \"speedtwo\":\n        one = {payload:OFF};\n        two = {payload:status};\n        three = {payload:OFF};\n        light = {payload:ON};\n        break;\n    case \"speedthree\":\n        one = {payload:OFF};\n        two = {payload:OFF};\n        three = {payload:status};\n        light = {payload:ON};\n        break;\n    case \"light\":\n        if (msg.payload){light = {payload:ON};}\n        else if (!msg.payload){light = {payload:OFF};}\n        break;\n    case \"default\":\n        if (msg.payload){\n            one = {payload:ON};\n            two = {payload:OFF};\n            three = {payload:OFF};\n            light = {payload:ON};\n        } else if (!msg.payload){\n            one = {payload:OFF};\n            two = {payload:OFF};\n            three = {payload:OFF};\n            light = {payload:OFF};\n            }\n        break;    \n    default:\n        node.status({fill:\"red\",shape:\"dot\"});\n    }\nnode.status({fill:\"green\",shape:\"ring\",text:msg.topic});\nreturn [one,two,three,light];","outputs":"4","noerr":0,"x":850,"y":420,"wires":[["7f38880.5527778"],["fd9023ed.968da"],["b422224a.d965d"],["9958f323.d9a4d"]]},{"id":"59ace212.0cd6fc","type":"ui_button","z":"f5229fd2.73d47","name":"","group":"b6f71680.9527d8","order":0,"width":0,"height":0,"passthru":true,"label":"Verlichting","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"light","x":110,"y":340,"wires":[["422a148b.9f85bc"]]},{"id":"422a148b.9f85bc","type":"function","z":"f5229fd2.73d47","name":"Toggle","func":"if(!flow.get(\"Z\")){\n  msg.payload = true;\n  flow.set(\"Z\",true);\n}else{\n  msg.payload = false;\n  flow.set(\"Z\",false);\n}\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":400,"wires":[["295581a0.44586e"]]},{"id":"5f77633c.84202c","type":"alexa-home","z":"f5229fd2.73d47","conf":"8867bf48.2d483","device":"4988","acknoledge":true,"name":"Extractor hood light","topic":"light","x":570,"y":280,"wires":[["295581a0.44586e"]]},{"id":"93966dde.c5dad","type":"rpi-gpio in","z":"f5229fd2.73d47","name":"button 1","pin":"29","intype":"up","debounce":"25","read":true,"x":100,"y":480,"wires":[["6c4481e3.9e7fa","da30bd77.4f5bb"]]},{"id":"97a3e8ca.aa0988","type":"rpi-gpio in","z":"f5229fd2.73d47","name":"button 2","pin":"31","intype":"up","debounce":"25","read":true,"x":100,"y":560,"wires":[["a764e36e.1428a","da30bd77.4f5bb"]]},{"id":"305e44e8.8c2b8c","type":"rpi-gpio in","z":"f5229fd2.73d47","name":"button 3","pin":"37","intype":"up","debounce":"25","read":true,"x":100,"y":640,"wires":[["da30bd77.4f5bb","c8a7296.bdb1ad8"]]},{"id":"113f950f.a8286b","type":"rpi-gpio in","z":"f5229fd2.73d47","name":"button light","pin":"32","intype":"down","debounce":"25","read":true,"x":100,"y":400,"wires":[["794dcb7c.a14814"]]},{"id":"6c4481e3.9e7fa","type":"function","z":"f5229fd2.73d47","name":"conversie","func":"if (msg.payload===0){return {topic:\"speedone\",payload:true};}","outputs":"1","noerr":0,"x":260,"y":480,"wires":[["c001aa41.616378"]]},{"id":"ff5dec7e.0f7ad","type":"delay","z":"f5229fd2.73d47","name":"Delay Off","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":720,"y":560,"wires":[["295581a0.44586e"]]},{"id":"a764e36e.1428a","type":"function","z":"f5229fd2.73d47","name":"conversie","func":"if (msg.payload===0){\n    flow.set(\"t3\",Date.now());\n    return {topic:\"speedtwo\",payload:true};\n    }","outputs":"1","noerr":0,"x":260,"y":560,"wires":[["9440d5df.7839b8","d80e771c.2b4478"]]},{"id":"794dcb7c.a14814","type":"function","z":"f5229fd2.73d47","name":"convesie","func":"if (msg.payload===0){\nmsg.topic = \"light\"; \nmsg.payload=true;    \n}else return null;\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":400,"wires":[["422a148b.9f85bc"]]},{"id":"d049ebf5.c0c468","type":"inject","z":"f5229fd2.73d47","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":110,"y":280,"wires":[["96504b4b.0e60a8"]]},{"id":"96504b4b.0e60a8","type":"function","z":"f5229fd2.73d47","name":"Initialisatie","func":"flow.set(\"Z\",false);","outputs":1,"noerr":0,"x":310,"y":180,"wires":[[]]},{"id":"d0521231.4c5b3","type":"mqtt in","z":"f5229fd2.73d47","name":"","topic":"GroundFloor/Kitchen/HoodLight","qos":"2","broker":"91690c08.1c763","x":170,"y":720,"wires":[["ef0da822.777bf8"]]},{"id":"ef0da822.777bf8","type":"function","z":"f5229fd2.73d47","name":"conversie","func":"msg.topic = \"light\";\nif (msg.payload===\"On\"){msg.payload=true;}\nif (msg.payload===\"Off\"){msg.payload=false;}\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":720,"wires":[["295581a0.44586e"]]},{"id":"da30bd77.4f5bb","type":"function","z":"f5229fd2.73d47","name":"button timming","func":"if (msg.payload===0){\nflow.set(\"t1\",Date.now());\nif (flow.get(\"t1\")>=flow.get(\"t2\")) {var c= flow.get(\"t1\")-flow.get(\"t2\");}\nflow.set(\"t2\",Date.now());\nnode.status({fill:\"green\",shape:\"dot\",text:\"vertraging: \"+c});\nif (c <= 2000){return {topic:\"default\",payload:false};}}","outputs":1,"noerr":0,"x":500,"y":560,"wires":[["ff5dec7e.0f7ad"]]},{"id":"c8a7296.bdb1ad8","type":"function","z":"f5229fd2.73d47","name":"conversie","func":"if (msg.payload===0){\n    flow.set(\"t4\",Date.now());\n    return {topic:\"speedthree\",payload:true};\n    }","outputs":1,"noerr":0,"x":260,"y":640,"wires":[["af743ada.cbb8b8","d80e771c.2b4478"]]},{"id":"d80e771c.2b4478","type":"function","z":"f5229fd2.73d47","name":"Ad-hoc OFF","func":"//var c = Math.abs(flow.get(\"t3\") - flow.get(\"t4\"));\nnode.status({fill:\"green\",shape:\"dot\",text:\"off: \"+ Math.abs(flow.get(\"t3\") - flow.get(\"t4\"))});\n\n\n\nif (Math.abs(flow.get(\"t3\") - flow.get(\"t4\"))<=200) {return {topic:\"default\",payload:false};}\n","outputs":1,"noerr":0,"x":490,"y":620,"wires":[["295581a0.44586e"]]},{"id":"8867bf48.2d483","type":"alexa-home-conf","z":"","username":"Bosscout"},{"id":"b6f71680.9527d8","type":"ui_group","z":"","name":"Afzuigkap","tab":"53212f53.4a377","disp":true,"width":"6"},{"id":"91690c08.1c763","type":"mqtt-broker","z":"","broker":"10.73.141.45","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"53212f53.4a377","type":"ui_tab","z":"","name":"Keuken","icon":"fa-free-code-camp"}]
pcmvanveen

Flow Info

created 2 months, 2 weeks ago
updated 1 month, 1 week ago

Node Types

Core
  • comment (x1)
  • delay (x1)
  • function (x10)
  • inject (x1)
  • mqtt in (x1)
  • mqtt-broker (x1)
  • rpi-gpio in (x4)
  • rpi-gpio out (x4)
Other

Tags

  • Raspberry_pi
  • extractor_hood
  • timer
  • alexa
  • echo
  • Amazon
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option