One thing I like best about NodeRED is that you can make almost everything with it.
I came to a point where I needed to limit the time my kids spend playing on PC. At first I tried to find some dedicated software, be it open source or commercial. There's plenty of choice, starting from built-in Windows 10 parental controls (that require MS account, so meh). I tried a few, but all of them but all had one flaw - I could only limit access to a time frame on daily basis. Like between X and Y from Monday to Friday etc. I wanted to do it differently - give them some time a week, but let them decide how to use it - either use all of it on the first day, or bit by bit through the whole week.
As I couldn't find any software with this ability it was NodeRED time.
First, some prerequisites:
- NodeRED must be run as Windows Service
- every kid must have his/her own Windows account (I use local, MS should work too)
- user name should not contain spaces as it would make parsing it more difficult
- if you want to play voice messages ffmpeg should be installed
- in my flow there is one non standard node called "mytimeout"
The logic behind the flow is as follows.
At first we need to determine who is using the PC. For this a "quser" command is executed every 10 seconds. The output splits quite nicely on a standard split node. Results are sorted between users on a switch node and then user status is determined. "Active" is used for further processing, Inactive is send to stop a time counter if it is running.
Any record matching one of the kids user name is then sent to a simple parser to get user session ID. The record is split and the only thing in that stream on messages that can be parsed into number by parseInt() is either user ID or IDLE TIME. So anything greater than number of users on the system is discarded. A bit stupid, but it works Parsed user ID is then stored as global variable.
Upon determining that user session is Active a message is sent to a specific user flow. There a file that contains remaining usage time is red and that number is used to start the counter. Counter records its countdown to a file, so it's reboot proof.
On reaching 0 a pre recorded message saying that the time is up and there are two more minutes to save the data is played and user account is diabled via "net user USERNAME /active:no"
Then after two minutes user is forcibly logged out via "logoff " + global.get("userID").
There are gauges on our home dashboard that show the remaining time.
[{"id":"4944690eb8d79eca","type":"tab","label":"Sprawdzanie kto jest zalogowany","disabled":false,"info":"","env":[]},{"id":"bd770db15a225df3","type":"exec","z":"4944690eb8d79eca","command":"quser","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":150,"y":200,"wires":[["42e68db6119925ed","81b21fd51dfc7d09"],[],[]]},{"id":"42e68db6119925ed","type":"debug","z":"4944690eb8d79eca","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":260,"y":40,"wires":[]},{"id":"fc41fd2b475b3e5b","type":"inject","z":"4944690eb8d79eca","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":260,"wires":[["bd770db15a225df3"]]},{"id":"81b21fd51dfc7d09","type":"split","z":"4944690eb8d79eca","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":350,"y":240,"wires":[["ccdddc0d08cd21f5","3d9abe20f45ed620"]]},{"id":"ccdddc0d08cd21f5","type":"debug","z":"4944690eb8d79eca","name":"debug 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":200,"y":540,"wires":[]},{"id":"3d9abe20f45ed620","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"radek","vt":"str"},{"t":"cont","v":"lila","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":530,"y":240,"wires":[["ec3880fda72ae2fc","68b6c55902631271"],["28b7e967a548b6ac","a48eb8694a93266c"],[]]},{"id":"1c51b03a389a6e78","type":"debug","z":"4944690eb8d79eca","name":"debug 3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":460,"y":40,"wires":[]},{"id":"ec3880fda72ae2fc","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Active","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":180,"wires":[["1c51b03a389a6e78","0f541fe6c5fa929e","952a7953ffd679f4"],["2ce836fd1eb21ce9","07cad09f0f582ff1"]]},{"id":"2ce836fd1eb21ce9","type":"debug","z":"4944690eb8d79eca","name":"debug 4","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":460,"y":80,"wires":[]},{"id":"28b7e967a548b6ac","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Active","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":320,"wires":[["9feb4026403b5cdb","e74c838224f594ee","7db6e26ea7343ff6"],["a50ffe59f84762e6","71d617153cb31091"]]},{"id":"a50ffe59f84762e6","type":"debug","z":"4944690eb8d79eca","name":"debug 5","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":80,"y":620,"wires":[]},{"id":"9feb4026403b5cdb","type":"debug","z":"4944690eb8d79eca","name":"debug 6","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":80,"y":580,"wires":[]},{"id":"0f541fe6c5fa929e","type":"change","z":"4944690eb8d79eca","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"active","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":120,"wires":[["d8bc67dcb9f2bad3"]]},{"id":"07cad09f0f582ff1","type":"change","z":"4944690eb8d79eca","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"inactive","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":180,"wires":[["d8bc67dcb9f2bad3"]]},{"id":"980795c168a7adc8","type":"mytimeout","z":"4944690eb8d79eca","name":"","outtopic":"","outsafe":"","outwarning":"Warning","outunsafe":"off","warning":"0","timer":"15","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1030,"y":260,"wires":[["5a7c0a3fbaffd002","baa48679bac09940"],[]]},{"id":"952a7953ffd679f4","type":"change","z":"4944690eb8d79eca","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{ \"payload\": \"on\", \"timeout\": 15 }","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":260,"wires":[["980795c168a7adc8"]]},{"id":"122cd7212564552b","type":"inject","z":"4944690eb8d79eca","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":860,"y":320,"wires":[["952a7953ffd679f4"]]},{"id":"baa48679bac09940","type":"debug","z":"4944690eb8d79eca","name":"debug 7","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1240,"y":280,"wires":[]},{"id":"5a7c0a3fbaffd002","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1230,"y":240,"wires":[["07cad09f0f582ff1"]]},{"id":"cf76563e79bf678d","type":"exec","z":"4944690eb8d79eca","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":450,"y":860,"wires":[[],[],[]]},{"id":"b18448c61e23be56","type":"inject","z":"4944690eb8d79eca","name":"Dezaktywuj konto RADEK","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"net user Radek /active:no","payloadType":"str","x":150,"y":800,"wires":[["cf76563e79bf678d"]]},{"id":"b6f3fc3198a10e9c","type":"inject","z":"4944690eb8d79eca","name":"Aktywuj konto RADEK","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"net user Radek /active:yes","payloadType":"str","x":140,"y":900,"wires":[["cf76563e79bf678d"]]},{"id":"68b6c55902631271","type":"split","z":"4944690eb8d79eca","name":"","splt":" ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":670,"y":20,"wires":[["46b6673155c2b874","481ba737b6ed5844"]]},{"id":"46b6673155c2b874","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":830,"y":20,"wires":[["537494735f1f1cbc"]]},{"id":"537494735f1f1cbc","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":":","vt":"str"},{"t":"cont","v":".","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":1010,"y":20,"wires":[[],[],["a323160b1230cca0"]]},{"id":"a323160b1230cca0","type":"function","z":"4944690eb8d79eca","name":"Parse ID to number","func":"var a = msg.payload;\nvar b = parseInt(a);\nif (isNaN(b)) {\n return null; //halt flow\n}\nmsg.payload = b;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1210,"y":20,"wires":[["1693a25c67bc9e36","1092e4d0c403c3da"]]},{"id":"d8bc67dcb9f2bad3","type":"link out","z":"4944690eb8d79eca","name":"Radek Active?","mode":"link","links":["c9a3442cec1edcbb"],"x":1035,"y":140,"wires":[]},{"id":"b7bb7a0578a6e826","type":"change","z":"4944690eb8d79eca","name":"","rules":[{"t":"set","p":"radekID","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1590,"y":20,"wires":[[]]},{"id":"a48eb8694a93266c","type":"split","z":"4944690eb8d79eca","name":"","splt":" ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":610,"y":700,"wires":[["42b4323d9880d4f6"]]},{"id":"42b4323d9880d4f6","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":770,"y":700,"wires":[["c31a3e6dc6cb2615"]]},{"id":"c31a3e6dc6cb2615","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":":","vt":"str"},{"t":"cont","v":".","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":950,"y":700,"wires":[[],[],["82e786b4fdb5df55"]]},{"id":"82e786b4fdb5df55","type":"function","z":"4944690eb8d79eca","name":"Parse ID to number","func":"var a = msg.payload;\nvar b = parseInt(a);\nif (isNaN(b)) {\n return null; //halt flow\n}\nmsg.payload = b;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1150,"y":700,"wires":[["908b2b9c06ce7bf1","a8d878fcbcb70976"]]},{"id":"c365d74c60280b4e","type":"change","z":"4944690eb8d79eca","name":"","rules":[{"t":"set","p":"lilaID","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1520,"y":700,"wires":[[]]},{"id":"e74c838224f594ee","type":"change","z":"4944690eb8d79eca","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"active","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":380,"wires":[["a14153acf88a1ea3"]]},{"id":"71d617153cb31091","type":"change","z":"4944690eb8d79eca","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"inactive","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":440,"wires":[["a14153acf88a1ea3"]]},{"id":"3afc601f41531bf1","type":"mytimeout","z":"4944690eb8d79eca","name":"","outtopic":"","outsafe":"","outwarning":"Warning","outunsafe":"off","warning":"0","timer":"15","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1030,"y":520,"wires":[["250f8f1773840d83","7191ca74c2752295"],[]]},{"id":"7db6e26ea7343ff6","type":"change","z":"4944690eb8d79eca","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{ \"payload\": \"on\", \"timeout\": 15 }","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":520,"wires":[["3afc601f41531bf1"]]},{"id":"2bdd3bbf4b9f14df","type":"inject","z":"4944690eb8d79eca","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":860,"y":580,"wires":[["7db6e26ea7343ff6"]]},{"id":"7191ca74c2752295","type":"debug","z":"4944690eb8d79eca","name":"debug 10","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1240,"y":540,"wires":[]},{"id":"250f8f1773840d83","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1230,"y":500,"wires":[["71d617153cb31091"]]},{"id":"a14153acf88a1ea3","type":"link out","z":"4944690eb8d79eca","name":"Lila Active?","mode":"link","links":["898a7c93bfebb016"],"x":1045,"y":400,"wires":[]},{"id":"5bd92c148299b15c","type":"inject","z":"4944690eb8d79eca","name":"Dezaktywuj konto LILA","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"net user Lila /active:no","payloadType":"str","x":140,"y":840,"wires":[["cf76563e79bf678d"]]},{"id":"448cfefb4da7674d","type":"inject","z":"4944690eb8d79eca","name":"Aktywuj konto LILA","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"net user LILA /active:yes","payloadType":"str","x":150,"y":940,"wires":[["cf76563e79bf678d"]]},{"id":"481ba737b6ed5844","type":"debug","z":"4944690eb8d79eca","name":"debug 13","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":60,"wires":[]},{"id":"1693a25c67bc9e36","type":"debug","z":"4944690eb8d79eca","name":"debug 14","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1400,"y":120,"wires":[]},{"id":"908b2b9c06ce7bf1","type":"debug","z":"4944690eb8d79eca","name":"debug 15","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1280,"y":760,"wires":[]},{"id":"1092e4d0c403c3da","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"4","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1410,"y":20,"wires":[["b7bb7a0578a6e826"]]},{"id":"a8d878fcbcb70976","type":"switch","z":"4944690eb8d79eca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"4","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1350,"y":700,"wires":[["c365d74c60280b4e"]]}]
[{"id":"2efe8addcaca7c6f","type":"mytimeout","z":"b21bc4af0d64f5b3","name":"","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"30","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":490,"y":160,"wires":[["ee2d2f347b482b0e"],["72bc6d6b9a894add","2ad85ba28c1b6d5a"]]},{"id":"05ed8abe3836c8a1","type":"debug","z":"b21bc4af0d64f5b3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":240,"wires":[]},{"id":"ee2d2f347b482b0e","type":"debug","z":"b21bc4af0d64f5b3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":100,"wires":[]},{"id":"08e0a0716a742867","type":"file in","z":"b21bc4af0d64f5b3","name":"","filename":"C:\\Users\\Andrzej\\Documents\\Timery\\radek.txt","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":240,"y":420,"wires":[["c3dce8d14350a10f"]]},{"id":"2c525199f14fbafb","type":"inject","z":"b21bc4af0d64f5b3","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"stop","payloadType":"str","x":310,"y":60,"wires":[["2efe8addcaca7c6f"]]},{"id":"72bc6d6b9a894add","type":"switch","z":"b21bc4af0d64f5b3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"-1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":770,"y":300,"wires":[["05ed8abe3836c8a1","d2b0ceeb20702c0b","a8f0d59fa4a2f5a6","80fe46755c6fec4b"]]},{"id":"d2b0ceeb20702c0b","type":"file","z":"b21bc4af0d64f5b3","name":"","filename":"C:\\Users\\Andrzej\\Documents\\Timery\\radek.txt","filenameType":"str","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":1120,"y":300,"wires":[[]]},{"id":"c3dce8d14350a10f","type":"switch","z":"b21bc4af0d64f5b3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":150,"y":140,"wires":[["f63d1ab5f5ca6b08"]]},{"id":"f63d1ab5f5ca6b08","type":"template","z":"b21bc4af0d64f5b3","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"payload\": \"on\",\n \"timeout\": {{payload}}\n}\n","output":"str","x":320,"y":120,"wires":[["2efe8addcaca7c6f"]]},{"id":"612113c1847a6007","type":"inject","z":"b21bc4af0d64f5b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":520,"wires":[["08e0a0716a742867"]]},{"id":"4f15f88eb5bfd636","type":"ui_button","z":"b21bc4af0d64f5b3","d":true,"name":"","group":"34be13f43736e264","order":0,"width":0,"height":0,"passthru":false,"label":"URUCHOM ZEGAR","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"start","payloadType":"str","topic":"topic","topicType":"msg","x":110,"y":360,"wires":[["08e0a0716a742867"]]},{"id":"a8f0d59fa4a2f5a6","type":"ui_gauge","z":"b21bc4af0d64f5b3","name":"","group":"34be13f43736e264","order":1,"width":0,"height":0,"gtype":"gage","title":"RADEK","label":"sekund","format":"{{value}}","min":0,"max":"7000","colors":["#b50000","#e6e600","#0ff21b"],"seg1":"1800","seg2":"3600","className":"","x":1360,"y":420,"wires":[]},{"id":"f6cacfaa28f13bf4","type":"inject","z":"b21bc4af0d64f5b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":930,"y":540,"wires":[["7b203e5cdce41805"]]},{"id":"7b203e5cdce41805","type":"file in","z":"b21bc4af0d64f5b3","name":"","filename":"C:\\Users\\Andrzej\\Documents\\Timery\\radek.txt","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1040,"y":460,"wires":[["a8f0d59fa4a2f5a6","80fe46755c6fec4b"]]},{"id":"7724e8d3a80ebd98","type":"ui_button","z":"b21bc4af0d64f5b3","d":true,"name":"","group":"34be13f43736e264","order":0,"width":0,"height":0,"passthru":false,"label":"ZATRZYMAJ ZEGAR","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"stop","payloadType":"str","topic":"topic","topicType":"msg","x":120,"y":320,"wires":[["2efe8addcaca7c6f"]]},{"id":"d1a54cd9db1a0a87","type":"switch","z":"b21bc4af0d64f5b3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":670,"y":660,"wires":[["08e0a0716a742867"],["40df95d237f877e3"]]},{"id":"40df95d237f877e3","type":"change","z":"b21bc4af0d64f5b3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":300,"wires":[["2efe8addcaca7c6f"]]},{"id":"3e1a25212a569a23","type":"switch","z":"b21bc4af0d64f5b3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":660,"wires":[["456ae235ec5d3937","d1a54cd9db1a0a87"],["456ae235ec5d3937","d1a54cd9db1a0a87"]]},{"id":"db1b4dcbfe657728","type":"mytimeout","z":"b21bc4af0d64f5b3","name":"","outtopic":"","outsafe":"","outwarning":"Warning","outunsafe":"off","warning":"0","timer":"15","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":430,"y":480,"wires":[["b7dabd6d63e5a0d3"],[]]},{"id":"456ae235ec5d3937","type":"change","z":"b21bc4af0d64f5b3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{ \"payload\": \"on\", \"timeout\": 15 }","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":560,"wires":[["db1b4dcbfe657728"]]},{"id":"b7dabd6d63e5a0d3","type":"switch","z":"b21bc4af0d64f5b3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":460,"wires":[["40df95d237f877e3"]]},{"id":"c9a3442cec1edcbb","type":"link in","z":"b21bc4af0d64f5b3","name":"Radek Active?","links":["d8bc67dcb9f2bad3"],"x":175,"y":660,"wires":[["3e1a25212a569a23"]]},{"id":"354b6907ad414e7e","type":"exec","z":"b21bc4af0d64f5b3","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":1490,"y":180,"wires":[[],["1b6a34d1ff7a4aa2"],[]]},{"id":"2ad85ba28c1b6d5a","type":"switch","z":"b21bc4af0d64f5b3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":140,"wires":[["f18e61d074cbee34","4fb2ce274648ae18"]]},{"id":"cfc11ea0457eb125","type":"change","z":"b21bc4af0d64f5b3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"net user Radek /active:no","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1140,"y":80,"wires":[["354b6907ad414e7e"]]},{"id":"6cbcb208e6f174ac","type":"function","z":"b21bc4af0d64f5b3","name":"function 2","func":"msg.payload = \"logoff \" + global.get(\"radekID\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1300,"y":140,"wires":[["bff4b2713101519b","354b6907ad414e7e"]]},{"id":"bff4b2713101519b","type":"debug","z":"b21bc4af0d64f5b3","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1480,"y":120,"wires":[]},{"id":"881cb8f9c70f1a05","type":"inject","z":"b21bc4af0d64f5b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30","payloadType":"str","x":230,"y":200,"wires":[["f63d1ab5f5ca6b08"]]},{"id":"f18e61d074cbee34","type":"exec","z":"b21bc4af0d64f5b3","command":"c:\\ffmpeg\\bin\\ffplay.exe -nodisp -autoexit C:\\Users\\Andrzej\\Documents\\Timery\\radek.wav","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":1150,"y":20,"wires":[[],[],[]]},{"id":"e8f6409704a62b88","type":"inject","z":"b21bc4af0d64f5b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":720,"y":20,"wires":[["f18e61d074cbee34"]]},{"id":"2b603e5575d8deda","type":"mytimeout","z":"b21bc4af0d64f5b3","name":"","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"120","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":970,"y":140,"wires":[["bd7b277addcd1d91"],[]]},{"id":"4fb2ce274648ae18","type":"change","z":"b21bc4af0d64f5b3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":80,"wires":[["2b603e5575d8deda","cfc11ea0457eb125"]]},{"id":"bd7b277addcd1d91","type":"switch","z":"b21bc4af0d64f5b3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1130,"y":140,"wires":[["6cbcb208e6f174ac"]]},{"id":"e1985ae109bbdc11","type":"inject","z":"b21bc4af0d64f5b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":880,"y":200,"wires":[["2b603e5575d8deda"]]},{"id":"80fe46755c6fec4b","type":"mqtt out","z":"b21bc4af0d64f5b3","name":"","topic":"rzeszow/timery/radek","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f3c32205a2d85d0f","x":1360,"y":360,"wires":[]},{"id":"dafa5744ef68f8d6","type":"link in","z":"b21bc4af0d64f5b3","name":"link in 2","links":["978b80e36147dde0"],"x":805,"y":400,"wires":[["d2b0ceeb20702c0b","e21ff93267427be7"]]},{"id":"e21ff93267427be7","type":"delay","z":"b21bc4af0d64f5b3","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":940,"y":400,"wires":[["7b203e5cdce41805"]]},{"id":"ac3801ba61390c12","type":"link in","z":"b21bc4af0d64f5b3","name":"link in 4","links":["180c6703bea88caa"],"x":1045,"y":200,"wires":[["2b603e5575d8deda"]]},{"id":"8a8c8ae2587a483b","type":"inject","z":"b21bc4af0d64f5b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":200,"wires":[["6cbcb208e6f174ac"]]},{"id":"954812c3fe8571f5","type":"inject","z":"b21bc4af0d64f5b3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"logoff 1","payloadType":"str","x":1290,"y":240,"wires":[["354b6907ad414e7e"]]},{"id":"1b6a34d1ff7a4aa2","type":"debug","z":"b21bc4af0d64f5b3","name":"debug 12","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1700,"y":180,"wires":[]},{"id":"020967bba74c629a","type":"comment","z":"b21bc4af0d64f5b3","name":"logoff userID","info":"","x":1490,"y":240,"wires":[]},{"id":"34be13f43736e264","type":"ui_group","name":"LICZNIKI","tab":"3955435cc2667a51","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"f3c32205a2d85d0f","type":"mqtt-broker","name":"RPi HTPC","broker":"192.168.1.107","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"3955435cc2667a51","type":"ui_tab","name":"CZAS","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
This system cannot be turned off without administrative privileges and files containing remaining time cannot be edited. Of course NodeRED is accesible from kids web browsers, so the flow can be altered... but I'm willingly leaving this hole open, encouraging them to try and hack it For now they didn't figure it out.