Nuimo countdown timer

A flow to use the rotary encoder and LED array of the Nuimo to set and display a countdown timer. Utilises the node mytimeout for the central timing function and google home notify for alerting once the timer has completed.

[{"id":"4b11b1bc.18b3f","type":"function","z":"15e38bf2.35c604","name":"","func":"msg.payload = \"off\";\nflow.set(\"timerActive\", \"notActive\")\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":920,"wires":[["9bd15581.6ff2b8"]]},{"id":"840e1155.bedbf","type":"switch","z":"15e38bf2.35c604","name":"","property":"timerActive","propertyType":"flow","rules":[{"t":"eq","v":"notActive","vt":"str"},{"t":"eq","v":"Active","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":900,"wires":[["98d8ca55.5ec6b8"],["4b11b1bc.18b3f"]]},{"id":"9bd15581.6ff2b8","type":"mytimeout","z":"15e38bf2.35c604","name":"","outtopic":"","outsafe":"on","outwarning":"Warning","outunsafe":"off","warning":"5","timer":"30","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":750,"y":980,"wires":[[],["fd66c7bc.5fda78","3d7dde69.776cb2"]]},{"id":"5e36a4ea.f1537c","type":"function","z":"15e38bf2.35c604","name":"START/STOP","func":"if (!flow.get(\"timerActive\")) {\n    flow.set(\"timerActive\", \"notActive\");\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":960,"wires":[["840e1155.bedbf"]]},{"id":"98d8ca55.5ec6b8","type":"function","z":"15e38bf2.35c604","name":"","func":"var raw = {};\nraw.payload = \"on\";\nraw.timeout = flow.get(\"timer\");\nraw.warning = 30;\n\nmsg = raw\nflow.set(\"timerActive\", \"Active\");\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":880,"wires":[["9bd15581.6ff2b8"]]},{"id":"af3395ba.0fa278","type":"nuimo-set-matrix","z":"15e38bf2.35c604","name":"Stop","appMatrixImage":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0","brightness":255,"timeout":2000,"onionSkinning":true,"nuimoConfig":"7066ddc3.dbbfa4","x":590,"y":1020,"wires":[["9bd15581.6ff2b8"]]},{"id":"fd66c7bc.5fda78","type":"change","z":"15e38bf2.35c604","name":"","rules":[{"t":"set","p":"int","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":980,"wires":[["5ef2b79d.035b08"]]},{"id":"3d7dde69.776cb2","type":"function","z":"15e38bf2.35c604","name":"Done notification","func":"if (msg.flag == \"off\") {\n    msg.payload = \"The timer is done\"\n    return msg;\n}","outputs":1,"noerr":0,"x":950,"y":1020,"wires":[["119292e9.b4ce2d"]]},{"id":"3f3d9c03.202a14","type":"switch","z":"15e38bf2.35c604","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"rotate","vt":"str"},{"t":"eq","v":"press","vt":"str"},{"t":"eq","v":"swipe","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":230,"y":920,"wires":[["16937663.945aba"],["5e36a4ea.f1537c"],["21ecc7c1.38e678"]]},{"id":"d8f8af94.5f3e7","type":"function","z":"15e38bf2.35c604","name":"","func":"context.set(\"hicount\", 0);\ncontext.set(\"lowcount\", 0);\nflow.set(\"timer\", 0);\nmsg.payload = \"cancel\";\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":1020,"wires":[["af3395ba.0fa278"]]},{"id":"5ef2b79d.035b08","type":"nuimo-set-matrix","z":"15e38bf2.35c604","name":"Countdown output","appMatrixImage":"","brightness":255,"timeout":"5000","onionSkinning":true,"nuimoConfig":"7066ddc3.dbbfa4","x":1150,"y":980,"wires":[[]]},{"id":"119292e9.b4ce2d","type":"googlehome-notify","z":"15e38bf2.35c604","server":"7178805e.2d499","name":"Notify","x":1110,"y":1020,"wires":[]},{"id":"16937663.945aba","type":"function","z":"15e38bf2.35c604","name":"Set timer value","func":"var lowCount = context.get(\"lowcount\")||0;\nvar hiCount = context.get(\"hicount\")||0;\nvar timer = flow.get(\"timer\")||0;\n\n    if (msg.amount > 20 && msg.amount < 200) {\n        lowCount += 1;\n        context.set(\"lowcount\", lowCount);\n    } else if (msg.amount >= 200) {\n        hiCount += 10;\n        context.set(\"hicount\", hiCount);\n    } else if (msg.amount < -20 && msg.amount > -200) {\n        lowCount -= 1;\n        context.set(\"lowcount\", lowCount);\n    } else if (msg.amount <= -200) {\n        hiCount -= 10;\n        context.set(\"hicount\", hiCount);\n    }\n    if (lowCount >= 3) {\n        if (timer <= 98) {\n        timer += 1;\n        } else {\n         timer = 99;\n        }\n        context.set(\"lowcount\", 0);\n        flow.set(\"timer\", timer)\n        msg.int = timer;\n    } else if (lowCount <= -3) {\n        if (timer >= 1) {\n        timer -= 1;\n        } else {\n         timer = 0;\n        }\n        context.set(\"lowcount\", 0);\n        flow.set(\"timer\", timer)\n        msg.int = timer;\n    }\n    if (hiCount >= 30) {\n        if (timer <= 89) {\n        timer += 10;\n        } else {\n         timer = 99;\n        }\n        context.set(\"hicount\", 0);\n        flow.set(\"timer\", timer)\n        msg.int = timer;\n    } else if (hiCount <= -30) {\n        if (timer >= 10) {\n        timer -= 10;\n        } else {\n         timer = 0;\n        }\n        context.set(\"hicount\", 0);\n        flow.set(\"timer\", timer)\n        msg.int = timer;\n    }\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":820,"wires":[["253ff18c.79a17e"]]},{"id":"21ecc7c1.38e678","type":"switch","z":"15e38bf2.35c604","name":"RESET/CHANGE MODE","property":"direction","propertyType":"msg","rules":[{"t":"eq","v":"DOWN","vt":"str"},{"t":"eq","v":"RIGHT","vt":"str"},{"t":"eq","v":"LEFT","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":290,"y":1060,"wires":[["d8f8af94.5f3e7"],["650c438b.358e2c"],["e1f326d0.05f3f8"]]},{"id":"29ba2938.bb8646","type":"nuimo-listener","z":"15e38bf2.35c604","name":"Timer","appChoice":"Timer","nuimoConfig":"7066ddc3.dbbfa4","x":110,"y":920,"wires":[["3f3d9c03.202a14"]]},{"id":"253ff18c.79a17e","type":"nuimo-set-matrix","z":"15e38bf2.35c604","name":"","appMatrixImage":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0","brightness":255,"timeout":2000,"onionSkinning":true,"nuimoConfig":"7066ddc3.dbbfa4","x":660,"y":820,"wires":[[]]},{"id":"650c438b.358e2c","type":"nuimo-set-matrix","z":"15e38bf2.35c604","name":"Second","appMatrixImage":"0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0","brightness":255,"timeout":2000,"onionSkinning":true,"nuimoConfig":"7066ddc3.dbbfa4","x":700,"y":1120,"wires":[[]]},{"id":"e1f326d0.05f3f8","type":"nuimo-set-matrix","z":"15e38bf2.35c604","name":"Minute","appMatrixImage":"0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0","brightness":255,"timeout":2000,"onionSkinning":true,"nuimoConfig":"7066ddc3.dbbfa4","x":690,"y":1160,"wires":[[]]},{"id":"7066ddc3.dbbfa4","type":"nuimo-config","z":"","name":"Nuimo"},{"id":"7178805e.2d499","type":"googlehome-config-node","z":"","ipaddress":"10.0.1.49","language":"en"}]

Flow Info

Created 6 years, 2 months ago
Updated 5 years, 4 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x1)
  • function (x6)
  • switch (x3)
Other

Tags

  • node-red-contrib-nuimo-controller
  • timer
  • countdown
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option