mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Add Wemo node and update READ.me
This commit is contained in:
parent
4375b32b84
commit
6ed75458c9
@ -57,11 +57,13 @@ Copyright 2013 IBM Corp. under [the Apache 2.0 license](LICENSE).
|
|||||||
|
|
||||||
**78-ledborg** - A simple driver for the LEDborg plug on module for Raspberry Pi.
|
**78-ledborg** - A simple driver for the LEDborg plug on module for Raspberry Pi.
|
||||||
|
|
||||||
|
**60-wemo** - Basic node to drive a WeMo socket and switch. Does not use discovery.
|
||||||
|
|
||||||
**76-blinkstick** - Provides support for the BlinkStick USB LED device.
|
**76-blinkstick** - Provides support for the BlinkStick USB LED device.
|
||||||
|
|
||||||
**77-blink1** - Provides support for the Blink1 USB LED from ThingM.
|
**77-blink1** - Provides support for the Blink1 USB LED from ThingM.
|
||||||
|
|
||||||
**78-digiRGB** - Provides support for the DigiPark RGB USB LED.
|
**78-digiRGB** - Provides support for the DigiSpark RGB USB LED.
|
||||||
|
|
||||||
**79-sensorTag** - Reads data from the Ti BLE SensorTag device.
|
**79-sensorTag** - Reads data from the Ti BLE SensorTag device.
|
||||||
|
|
||||||
|
90
hardware/wemo/60-wemo.html
Normal file
90
hardware/wemo/60-wemo.html
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<!--
|
||||||
|
Copyright 2013 IBM Corp.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<script type="text/x-red" data-template-name="wemo out">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-ipaddr"><i class="icon-globe"></i> IP Address</label>
|
||||||
|
<input type="text" id="node-input-ipaddr" placeholder="192.168.1.100">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
|
</div>
|
||||||
|
<div class="form-tips">Expects a msg.payload with either 1/0, on/off, or true/false</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/x-red" data-help-name="wemo out">
|
||||||
|
<p>Wemo output node. Expects a <b>msg.payload</b> with either 1/0, on/off or true/false.</p>
|
||||||
|
<p>It doesn't yet do any ip address discovery of the wemo devices.</p>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
RED.nodes.registerType('wemo out',{
|
||||||
|
category: 'advanced-output',
|
||||||
|
color:"GoldenRod",
|
||||||
|
defaults: {
|
||||||
|
ipaddr: {value:"",required:true},
|
||||||
|
name: {value:""}
|
||||||
|
},
|
||||||
|
inputs:1,
|
||||||
|
outputs:0,
|
||||||
|
icon: "light.png",
|
||||||
|
align: "right",
|
||||||
|
label: function() {
|
||||||
|
return this.name||"wemo";
|
||||||
|
},
|
||||||
|
labelStyle: function() {
|
||||||
|
return this.name?"node_label_italic":"";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/x-red" data-template-name="wemo in">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-ipaddr"><i class="icon-globe"></i> IP Address</label>
|
||||||
|
<input type="text" id="node-input-ipaddr" placeholder="192.168.1.100">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
|
</div>
|
||||||
|
<div class="form-tips">Creates a msg.payload with either 1, 0, nc or na.</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/x-red" data-help-name="wemo in">
|
||||||
|
<p>Wemo input node. Creates a <b>msg.payload</b> with either 1, 0, nc (no change), or na (not available).</p>
|
||||||
|
<p>It doesn't yet do any ip address discovery of the wemo devices.</p>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
RED.nodes.registerType('wemo in',{
|
||||||
|
category: 'advanced-input',
|
||||||
|
color:"GoldenRod",
|
||||||
|
defaults: {
|
||||||
|
ipaddr: {value:"",required:true},
|
||||||
|
name: {value:""}
|
||||||
|
},
|
||||||
|
inputs:0,
|
||||||
|
outputs:1,
|
||||||
|
icon: "light.png",
|
||||||
|
label: function() {
|
||||||
|
return this.name||"wemo";
|
||||||
|
},
|
||||||
|
labelStyle: function() {
|
||||||
|
return this.name?"node_label_italic":"";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
60
hardware/wemo/60-wemo.js
Normal file
60
hardware/wemo/60-wemo.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2013 IBM Corp.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
**/
|
||||||
|
|
||||||
|
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
||||||
|
var WeMo = new require('wemo');
|
||||||
|
|
||||||
|
function WeMoOut(n) {
|
||||||
|
RED.nodes.createNode(this,n);
|
||||||
|
this.ipaddr = n.ipaddr;
|
||||||
|
this.wemoSwitch = new WeMo(n.ipaddr);
|
||||||
|
var node = this;
|
||||||
|
|
||||||
|
this.on("input", function(msg) {
|
||||||
|
if (msg != null) {
|
||||||
|
var state = 0;
|
||||||
|
if ( msg.payload == 1 || msg.payload == true || msg.payload == "on" ) { var state = 1; }
|
||||||
|
node.wemoSwitch.setBinaryState(state, function(err, result) {
|
||||||
|
if (err) node.warn(err);
|
||||||
|
//else { node.log(result); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("wemo out",WeMoOut);
|
||||||
|
|
||||||
|
function WeMoIn(n) {
|
||||||
|
RED.nodes.createNode(this,n);
|
||||||
|
this.ipaddr = n.ipaddr;
|
||||||
|
this.wemoSwitch = new WeMo(n.ipaddr);
|
||||||
|
this.wemoSwitch.state = 0;
|
||||||
|
var node = this;
|
||||||
|
|
||||||
|
var tick = setInterval(function() {
|
||||||
|
wemoSwitch.getBinaryState(function(err, result) {
|
||||||
|
if (err) node.warn(err);
|
||||||
|
if (parseInt(result) != wemoSwitch.state) {
|
||||||
|
wemoSwitch.state = parseInt(result);
|
||||||
|
node.send({payload:wemoSwitch.state,topic:"wemo/"+node.ipaddr});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
this.on("close", function() {
|
||||||
|
clearInterval(tick);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("wemo in",WeMoOut);
|
Loading…
x
Reference in New Issue
Block a user