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:
parent
1bfda975ef
commit
5c1edc641a
@ -4,16 +4,21 @@
|
|||||||
<label for="node-input-mac"><i class="fa fa-globe"></i> MAC Address</label>
|
<label for="node-input-mac"><i class="fa fa-globe"></i> MAC Address</label>
|
||||||
<input type="text" id="node-input-mac" placeholder="e.g. DE:AD:BE:EF:FE:ED">
|
<input type="text" id="node-input-mac" placeholder="e.g. DE:AD:BE:EF:FE:ED">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-host"><i class="fa fa-globe"></i> Host Address</label>
|
||||||
|
<input type="text" id="node-input-host" placeholder="e.g. 255.255.255.255">
|
||||||
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-tips">Tip: leave blank if you want to use <code>msg.mac</code> to dynamically set target mac address.</div>
|
<div class="form-tips">Tip: leave blank if you want to use <code>msg.mac</code> or <code>msg.host</code> to dynamically set target mac address.</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="wake on lan">
|
<script type="text/x-red" data-help-name="wake on lan">
|
||||||
<p>Sends a Wake-On-LAN magic packet to the mac address specified.</p>
|
<p>Sends a Wake-On-LAN magic packet to the mac address specified.</p>
|
||||||
<p>You may instead set <code>msg.mac</code> to dynamically set the target device mac to wake up.</p>
|
<p>You may instead set <code>msg.mac</code> to dynamically set the target device mac to wake up.</p>
|
||||||
|
<p>The target host address can optionally be set using <code>msg.host</code></p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -22,6 +27,7 @@
|
|||||||
color:"#999966",
|
color:"#999966",
|
||||||
defaults: {
|
defaults: {
|
||||||
mac: {value:""},
|
mac: {value:""},
|
||||||
|
host: {value:""},
|
||||||
name: {value:""}
|
name: {value:""}
|
||||||
},
|
},
|
||||||
inputs:1,
|
inputs:1,
|
||||||
|
@ -7,14 +7,16 @@ module.exports = function(RED) {
|
|||||||
function WOLnode(n) {
|
function WOLnode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.mac = n.mac.trim();
|
this.mac = n.mac.trim();
|
||||||
|
this.host = n.host;
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
this.on("input", function(msg) {
|
this.on("input", function(msg) {
|
||||||
var mac = this.mac || msg.mac || null;
|
var mac = this.mac || msg.mac || null;
|
||||||
|
var host = this.host || msg.host || '255.255.255.255';
|
||||||
if (mac != null) {
|
if (mac != null) {
|
||||||
if (chk.test(mac)) {
|
if (chk.test(mac)) {
|
||||||
try {
|
try {
|
||||||
wol.wake(mac, function(error) {
|
wol.wake(mac, {address: host}, function(error) {
|
||||||
if (error) { node.warn(error); }
|
if (error) { node.warn(error); }
|
||||||
else if (RED.settings.verbose) {
|
else if (RED.settings.verbose) {
|
||||||
node.log("sent WOL magic packet");
|
node.log("sent WOL magic packet");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-wol",
|
"name" : "node-red-node-wol",
|
||||||
"version" : "0.0.7",
|
"version" : "0.0.8",
|
||||||
"description" : "A Node-RED node to send Wake-On-LAN (WOL) magic packets",
|
"description" : "A Node-RED node to send Wake-On-LAN (WOL) magic packets",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"wake_on_lan" : "0.0.4"
|
"wake_on_lan" : "0.0.4"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user