mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Attempt to catch errors from wemo-lookup
This is to catch errors when device is offline
This commit is contained in:
parent
60fcbc351d
commit
e9f0509cc6
@ -398,12 +398,17 @@ module.exports = function(RED) {
|
|||||||
node.status({fill: 'green',shape: 'dot',text: 'found'});
|
node.status({fill: 'green',shape: 'dot',text: 'found'});
|
||||||
}
|
}
|
||||||
|
|
||||||
node.on('input', function(msg) {
|
node.on('input', function(msg, send, done) {
|
||||||
var dev = wemo.get(node.dev);
|
var dev = wemo.get(node.dev);
|
||||||
|
|
||||||
|
send = send || function() { node.send.apply(node,arguments) }
|
||||||
|
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
//need to show that dev not currently found
|
//need to show that dev not currently found
|
||||||
console.log('no device found');
|
console.log('no device found');
|
||||||
|
if (done) {
|
||||||
|
done()
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +432,16 @@ module.exports = function(RED) {
|
|||||||
delete status.capabilities;
|
delete status.capabilities;
|
||||||
// }
|
// }
|
||||||
msg.payload = status;
|
msg.payload = status;
|
||||||
node.send(msg);
|
send(msg);
|
||||||
|
if (done) {
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
}).catch(function(err){
|
||||||
|
if (done) {
|
||||||
|
done(err)
|
||||||
|
} else {
|
||||||
|
node.error(err,msg)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if (dev.type === 'socket_insight') {
|
} else if (dev.type === 'socket_insight') {
|
||||||
console.log("socket_insight");
|
console.log("socket_insight");
|
||||||
@ -437,7 +451,16 @@ module.exports = function(RED) {
|
|||||||
msg.payload = insightParameters;
|
msg.payload = insightParameters;
|
||||||
// 'state' should be a number for backwards compatibility
|
// 'state' should be a number for backwards compatibility
|
||||||
msg.payload.state = parseInt(msg.payload.state);
|
msg.payload.state = parseInt(msg.payload.state);
|
||||||
node.send(msg);
|
send(msg);
|
||||||
|
if (done) {
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
}).catch(function(err){
|
||||||
|
if (done) {
|
||||||
|
done(err)
|
||||||
|
} else {
|
||||||
|
node.error(err,msg)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("socket");
|
console.log("socket");
|
||||||
@ -447,7 +470,17 @@ module.exports = function(RED) {
|
|||||||
msg.payload = {
|
msg.payload = {
|
||||||
state: status
|
state: status
|
||||||
};
|
};
|
||||||
node.send(msg);
|
send(msg);
|
||||||
|
if (done) {
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function(err){
|
||||||
|
if (done) {
|
||||||
|
done(err)
|
||||||
|
} else {
|
||||||
|
node.error(err,msg)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,7 +5,7 @@ var events = require('events');
|
|||||||
var util = require('util');
|
var util = require('util');
|
||||||
var Client = require('node-ssdp').Client;
|
var Client = require('node-ssdp').Client;
|
||||||
var xml2js = require('xml2js');
|
var xml2js = require('xml2js');
|
||||||
var request = require('request');
|
// var request = require('request');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var url = require('url');
|
var url = require('url');
|
||||||
var Q = require('q');
|
var Q = require('q');
|
||||||
@ -271,6 +271,11 @@ WeMoNG.prototype.start = function start() {
|
|||||||
post_request.abort();
|
post_request.abort();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
post_request.on('error', function(err){
|
||||||
|
// should log err
|
||||||
|
console.log(err);
|
||||||
|
})
|
||||||
|
|
||||||
post_request.write(util.format(getenddevs.body, udn));
|
post_request.write(util.format(getenddevs.body, udn));
|
||||||
post_request.end();
|
post_request.end();
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-node-wemo",
|
"name": "node-red-node-wemo",
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"description": "Input and Output nodes for Belkin WeMo devices",
|
"description": "Input and Output nodes for Belkin WeMo devices",
|
||||||
"repository": "https://github.com/node-red/node-red-nodes/tree/master/hardware",
|
"repository": "https://github.com/node-red/node-red-nodes/tree/master/hardware",
|
||||||
"main": "WeMoNG.js",
|
"main": "WeMoNG.js",
|
||||||
@ -12,11 +12,16 @@
|
|||||||
"wemo",
|
"wemo",
|
||||||
"belkin"
|
"belkin"
|
||||||
],
|
],
|
||||||
"author": {
|
"contributors": [
|
||||||
|
{
|
||||||
"email": "hardillb@gmail.com",
|
"email": "hardillb@gmail.com",
|
||||||
"name": "Benjamin Hardill",
|
"name": "Benjamin Hardill",
|
||||||
"url": "http://www.hardill.me.uk/wordpress/"
|
"url": "http://www.hardill.me.uk/wordpress/"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Bart Butenaers"
|
||||||
|
}
|
||||||
|
],
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-ssdp": "~3.2.5",
|
"node-ssdp": "~3.2.5",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user