Individual distance value

This commit is contained in:
Gerrit Linnemann 2016-06-15 23:36:15 +02:00
parent 1b813fd749
commit 52344b9413
2 changed files with 18 additions and 12 deletions

View File

@ -40,16 +40,18 @@ Helper.each(Conf.items, function(item) {
function (distance) { function (distance) {
//Log.log('Distance Value: ' + distance); //Log.log('Distance Value: ' + distance);
if(distance < 200 && readyForNextNotification) { if(readyForNextNotification) {
counter++; if((item.mode === '<' && distance < item.value) || (item.mode === '>' && distance > item.value)) {
readyForNextNotification = false; counter++;
readyForNextNotification = false;
var url2callObj = (counter % 2 == 0 ? item.on.action.on : item.on.action.off); var url2callObj = (counter % 2 == 0 ? item.on.action.on : item.on.action.off);
Log.log('Distance Value: ' + distance + ', URL to call: ' + url2callObj.host + ':' + url2callObj.port + url2callObj.path); Log.log('Distance Value: ' + distance + ', URL to call: ' + url2callObj.host + ':' + url2callObj.port + url2callObj.path);
doHoBuDoorBellCall(url2callObj); doHoBuDoorBellCall(url2callObj);
setTimeout(function() { readyForNextNotification = true; }, item.on.action.timeout); setTimeout(function() { readyForNextNotification = true; }, item.on.action.timeout);
}
} }
} }
); );

View File

@ -4,9 +4,11 @@
"host": "192.168.2.124", "host": "192.168.2.124",
"port": 4223, "port": 4223,
"uid": "q2J", "uid": "q2J",
"mode": "<",
"value": 200,
"on": { "on": {
"action": { "action": {
"timeout": 4500, "timeout": 4000,
"on": { "on": {
"host": "hobu", "host": "hobu",
"port": "2999", "port": "2999",
@ -24,9 +26,11 @@
"host": "192.168.2.125", "host": "192.168.2.125",
"port": 4223, "port": 4223,
"uid": "z9q", "uid": "z9q",
"mode": ">",
"value": 2000,
"on": { "on": {
"action": { "action": {
"timeout": 4500, "timeout": 3500,
"on": { "on": {
"host": "hobu", "host": "hobu",
"port": "2999", "port": "2999",