mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
node-red-node-wol: add host field to set target IP address (#252)
Thanks @nlecaude
This commit is contained in:
committed by
Dave Conway-Jones
parent
1bfda975ef
commit
5c1edc641a
@@ -7,14 +7,16 @@ module.exports = function(RED) {
|
||||
function WOLnode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.mac = n.mac.trim();
|
||||
this.host = n.host;
|
||||
var node = this;
|
||||
|
||||
this.on("input", function(msg) {
|
||||
var mac = this.mac || msg.mac || null;
|
||||
var host = this.host || msg.host || '255.255.255.255';
|
||||
if (mac != null) {
|
||||
if (chk.test(mac)) {
|
||||
try {
|
||||
wol.wake(mac, function(error) {
|
||||
wol.wake(mac, {address: host}, function(error) {
|
||||
if (error) { node.warn(error); }
|
||||
else if (RED.settings.verbose) {
|
||||
node.log("sent WOL magic packet");
|
||||
|
||||
Reference in New Issue
Block a user