State-indicating Wake-on-LAN dashboard button

Hey gang,
I've had so much generous help from people on this forum I wanted to share this Dashboard contraption I made. I'm pleased with and thought someone else might get some mileage out of it.
NR-WOL-DashboardButtonExample

Bascially, it is a Wake-on-LAN button. Its colour is orange when the device in question is off (not returning pings) and blue then it is turned on (returning pings). It checks once per hour if the device is on, but when you press the Wake-on-LAN button, for 5 minutes only it will increase that frequency to every 5 seconds.

I recommend using MAC addresses to trigger the WOL magic packet, as I've found IP address is pretty unreliable.

Remember to change the MAC and IP addresses (notes inside flow) to your system.

Requires packages:
*node-red-node-wol
*node-red-node-ping
*node-red-contrib-looptimer-advanced

All the best,
Dax Liniere.

[{"id":"2582e58c.cf8b8a","type":"ui_button","z":"1f80343e.bd1cac","name":"","group":"fb05ea75.c1a778","order":4,"width":0,"height":0,"passthru":false,"label":"Wake-On-Lan PC1","tooltip":"","color":"white","bgcolor":"{{msg.background}}","icon":"fa-desktop","payload":"DE:AD:BE:EF:FE:ED","payloadType":"str","topic":"topic","topicType":"msg","x":170,"y":160,"wires":[["4fda4030.718dc","6f5520f2.64748"]]},{"id":"5c34f6cd.103fe8","type":"ui_button","z":"1f80343e.bd1cac","name":"","group":"fb05ea75.c1a778","order":5,"width":0,"height":0,"passthru":false,"label":"Wake-On-Lan PC2","tooltip":"","color":"white","bgcolor":"{{msg.background}}","icon":"fa-desktop","payload":"DE:AD:BE:EF:FE:ED","payloadType":"str","topic":"topic","topicType":"msg","x":170,"y":200,"wires":[["4fda4030.718dc","5337f39d.68cccc"]]},{"id":"40e2efc.6bf4b1","type":"wake on lan","z":"1f80343e.bd1cac","mac":"","host":"","udpport":9,"name":"","x":590,"y":160,"wires":[]},{"id":"4fda4030.718dc","type":"change","z":"1f80343e.bd1cac","name":"","rules":[{"t":"set","p":"mac","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":160,"wires":[["40e2efc.6bf4b1"]]},{"id":"c9ff7d04.8c6cd","type":"conf ping","z":"1f80343e.bd1cac","name":"Ping IP address","host":"","timeout":"10","requests":"1","x":640,"y":320,"wires":[["c6caa3f5.53a43","e5805062.05059"]],"outputLabels":["ms"]},{"id":"2ff85154.8a665e","type":"inject","z":"1f80343e.bd1cac","name":"Ping PC 2 hourly","props":[{"p":"host","v":"192.168.1.11","vt":"str"}],"repeat":"3600","crontab":"","once":true,"onceDelay":"5","topic":"","x":170,"y":320,"wires":[["c9ff7d04.8c6cd"]],"icon":"node-red/timer.svg"},{"id":"13bfdbec.5d4984","type":"inject","z":"1f80343e.bd1cac","name":"Ping PC 1 hourly","props":[{"p":"host","v":"192.168.1.10","vt":"str"}],"repeat":"3600","crontab":"","once":true,"onceDelay":"5","topic":"","x":170,"y":280,"wires":[["c9ff7d04.8c6cd"]],"icon":"node-red/timer.svg"},{"id":"c6caa3f5.53a43","type":"function","z":"1f80343e.bd1cac","name":"Colour 192.168.1.10","func":"if (msg.topic==\"init\") {\n  //not real value\n  return {background: 'black'};\n}\n\nif (msg.topic == \"192.168.1.10\" && msg.payload > 0) {\n  return {background: 'dodgerblue'};\n} \n\nif (msg.topic == \"192.168.1.10\" && msg.payload == false) {\n  return {background: 'orange'};\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":900,"y":220,"wires":[["2582e58c.cf8b8a"]]},{"id":"e5805062.05059","type":"function","z":"1f80343e.bd1cac","name":"Colour 192.168.1.11","func":"if (msg.topic==\"init\") {\n  //not real value\n  return {background: 'black'};\n}\n\nif (msg.topic == \"192.168.1.11\" && msg.payload > 0) {\n  return {background: 'dodgerblue'};\n} \n\nif (msg.topic == \"192.168.1.11\" && msg.payload == false) {\n  return {background: 'orange'};\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":900,"y":260,"wires":[["5c34f6cd.103fe8"]]},{"id":"f23c9fa2.fabeb","type":"looptimer-advanced","z":"1f80343e.bd1cac","duration":"5","units":"Second","maxloops":"150","maxtimeout":"5","maxtimeoutunits":"Minute","name":"For 5 mins, ping every 5 secs ","x":640,"y":260,"wires":[["c9ff7d04.8c6cd"],[]]},{"id":"6f5520f2.64748","type":"change","z":"1f80343e.bd1cac","name":"PC 1","rules":[{"t":"set","p":"host","pt":"msg","to":"192.168.1.10","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":240,"wires":[["f23c9fa2.fabeb"]]},{"id":"5337f39d.68cccc","type":"change","z":"1f80343e.bd1cac","name":"PC 2","rules":[{"t":"set","p":"host","pt":"msg","to":"192.168.1.11","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":280,"wires":[["f23c9fa2.fabeb"]]},{"id":"e112c7ba.ff0318","type":"comment","z":"1f80343e.bd1cac","name":"Instructions","info":"Remember to change:\n*MAC addresses in the Dashboard button settings\n*Corresponding IP addresses in the ping, change and colour nodes\n\n\nRequires packages:\n*node-red-node-wol\n*node-red-node-ping\n*node-red-contrib-looptimer-advanced","x":160,"y":120,"wires":[]},{"id":"fb05ea75.c1a778","type":"ui_group","name":"System Information","tab":"6513d922.c36558","order":1,"disp":true,"width":"6","collapse":false},{"id":"6513d922.c36558","type":"ui_tab","name":"Raspberry Pi Control Centre","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
5 Likes