1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Merge pull request #60 from hindessm/possible-wemo-bugs

Possible wemo node bugs? - confirmed !
This commit is contained in:
Dave Conway-Jones 2014-07-18 12:16:49 +01:00
commit 1c410476c6

View File

@ -40,16 +40,16 @@ module.exports = function(RED) {
function WemoIn(n) { function WemoIn(n) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.ipaddr = n.ipaddr; this.ipaddr = n.ipaddr;
this.wemoSwitch = new WeMo(n.ipaddr); this.wemoSwitch = new Wemo(n.ipaddr);
this.wemoSwitch.state = 0; this.wemoSwitch.state = 0;
var node = this; var node = this;
var tick = setInterval(function() { var tick = setInterval(function() {
wemoSwitch.getBinaryState(function(err, result) { node.wemoSwitch.getBinaryState(function(err, result) {
if (err) { node.warn(err); } if (err) { node.warn(err); }
if (parseInt(result) != wemoSwitch.state) { if (parseInt(result) != node.wemoSwitch.state) {
wemoSwitch.state = parseInt(result); node.wemoSwitch.state = parseInt(result);
node.send({payload:wemoSwitch.state,topic:"wemo/"+node.ipaddr}); node.send({payload:node.wemoSwitch.state,topic:"wemo/"+node.ipaddr});
} }
}); });
}, 2000); }, 2000);