Skip to content

Commit d3cdd0f

Browse files
committed
more events & ui fixes
1 parent 0931d5b commit d3cdd0f

File tree

4 files changed

+74
-42
lines changed

4 files changed

+74
-42
lines changed

gateway.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// **********************************************************************************
2-
// Websocket server backend for the Moteino IoT Framework
2+
// Websocket server backend for the Moteino IoT Gateway
33
// Hardware and software stack details: http://lowpowerlab.com/gateway
44
// This is a work in progress and is released without any warranties expressed or implied.
55
// See license.txt for license and limitations of use of this software.
@@ -21,7 +21,7 @@
2121
//
2222
// This script is configured to compact the database every 24 hours since time of start.
2323
// ********************************************************************************************
24-
// Copyright Felix Rusu, Low Power Lab LLC (2015), http://lowpowerlab.com/contact
24+
// Copyright Felix Rusu, Low Power Lab LLC (2018), http://lowpowerlab.com/contact
2525
// ********************************************************************************************
2626
// IMPORTANT details about NeDB:
2727
// _id field is special - if not used it is automatically added and used as unique index

metrics.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ exports.motes = {
317317
icon : 'icon_garage.png',
318318
settings: { ipcam_snapURL: '' },
319319
controls : { refresh : { states: [{ label:'Refresh', action:'STS', icon:'refresh' }]},
320-
opencls : { states: [{ label:'Open!', action:'OPN', icon:'arrow-u', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['Status'].value == 'CLOSED';}},
321-
{ label:'Opening..', action:'', icon:'forbidden', css:'background-color:#FFF000;', condition:''+function(node) { return node.metrics['Status'].value == 'OPENING';}},
322-
{ label:'Close!', action:'CLS', icon:'arrow-d', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['Status'].value == 'OPEN';}},
323-
{ label:'Closing..', action:'', icon:'forbidden', css:'background-color:#FFF000;', condition:''+function(node) { return node.metrics['Status'].value == 'CLOSING';}}]
320+
opencls : { states: [{ label:'Open!', action:'OPN', icon:'arrow-u', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['Status']!=null && node.metrics['Status'].value == 'CLOSED';}},
321+
{ label:'Opening..', action:'', icon:'forbidden', css:'background-color:#FFF000;', condition:''+function(node) { return node.metrics['Status']!=null && node.metrics['Status'].value == 'OPENING';}},
322+
{ label:'Close!', action:'CLS', icon:'arrow-d', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['Status']!=null && node.metrics['Status'].value == 'OPEN';}},
323+
{ label:'Closing..', action:'', icon:'forbidden', css:'background-color:#FFF000;', condition:''+function(node) { return node.metrics['Status']!=null && node.metrics['Status'].value == 'CLOSING';}}]
324324
}
325325
}
326326
},
@@ -356,24 +356,24 @@ exports.motes = {
356356
label : 'Sprinkler Controller',
357357
icon : 'icon_sprinklers.png',
358358
controls : {
359-
Z1 : { states: [{ label:'1', action:'ON:1', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '1'; }},
360-
{ label:'1', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '1'; }}]},
361-
Z2 : { states: [{ label:'2', action:'ON:2', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '2'; }},
362-
{ label:'2', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '2'; }}]},
363-
Z3 : { states: [{ label:'3', action:'ON:3', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '3'; }},
364-
{ label:'3', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '3'; }}]},
365-
Z4 : { states: [{ label:'4', action:'ON:4', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '4'; }},
366-
{ label:'4', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '4'; }}]},
367-
Z5 : { states: [{ label:'5', action:'ON:5', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '5'; }},
368-
{ label:'5', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '5'; }}]},
369-
Z6 : { states: [{ label:'6', action:'ON:6', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '6'; }},
370-
{ label:'6', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '6'; }}]},
371-
Z7 : { states: [{ label:'7', action:'ON:7', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '7'; }},
372-
{ label:'7', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '7'; }}]},
373-
Z8 : { states: [{ label:'8', action:'ON:8', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '8'; }},
374-
{ label:'8', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '8'; }}]},
375-
Z9 : { states: [{ label:'9', action:'ON:9', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE'].value != '9'; }},
376-
{ label:'9', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE'].value == '9'; }}], breakAfter:true},
359+
Z1 : { states: [{ label:'1', action:'ON:1', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '1'; }},
360+
{ label:'1', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '1'; }}]},
361+
Z2 : { states: [{ label:'2', action:'ON:2', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '2'; }},
362+
{ label:'2', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '2'; }}]},
363+
Z3 : { states: [{ label:'3', action:'ON:3', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '3'; }},
364+
{ label:'3', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '3'; }}]},
365+
Z4 : { states: [{ label:'4', action:'ON:4', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '4'; }},
366+
{ label:'4', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '4'; }}]},
367+
Z5 : { states: [{ label:'5', action:'ON:5', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '5'; }},
368+
{ label:'5', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '5'; }}]},
369+
Z6 : { states: [{ label:'6', action:'ON:6', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '6'; }},
370+
{ label:'6', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '6'; }}]},
371+
Z7 : { states: [{ label:'7', action:'ON:7', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '7'; }},
372+
{ label:'7', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '7'; }}]},
373+
Z8 : { states: [{ label:'8', action:'ON:8', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '8'; }},
374+
{ label:'8', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '8'; }}]},
375+
Z9 : { states: [{ label:'9', action:'ON:9', css:'background-color:#FF9B9B;', condition:''+function(node) { return node.metrics['ZONE']!=null && node.metrics['ZONE'].value != '9'; }},
376+
{ label:'9', action:'OFF', css:'background-color:#9BFFBE;color:#000000', condition:''+function(node) { return node.metrics['ZONE']==null || node.metrics['ZONE'].value == '9'; }}], breakAfter:true},
377377
MN : { states: [{ label:'Run Z1-8 5min', action:'PRG 1:300 2:300 3:300 4:200 5:300 5:300 6:300 7:300 8:300'}]},
378378
},
379379
},
@@ -450,7 +450,7 @@ exports.motes = {
450450
var thejson = { 'tmode':2, 't_cool' : ++targetNow };
451451
exports.tstatRequest(thejson, node._id);
452452
},
453-
condition:''+function(node) { return node.metrics['MODE'] && node.metrics['MODE'].value == 'COOL'; }
453+
condition:''+function(node) { return node.metrics['MODE']!=null && node.metrics['MODE'].value == 'COOL'; }
454454
},
455455
{ label:'Cool', action:'', icon:'fa-ge',
456456
serverExecute:function(node){
@@ -461,7 +461,7 @@ exports.motes = {
461461
var thejson = { 'tmode':2, 't_cool' : ++targetNow };
462462
exports.tstatRequest(thejson, node._id);
463463
},
464-
condition:''+function(node) { return node.metrics['MODE'] && node.metrics['MODE'].value != 'COOL'; }
464+
condition:''+function(node) { return node.metrics['MODE']!=null && node.metrics['MODE'].value != 'COOL'; }
465465
}]
466466
},
467467
//switch to HEAT mode
@@ -474,7 +474,7 @@ exports.motes = {
474474
var thejson = { 'tmode':1, 't_heat' : --targetNow };
475475
exports.tstatRequest(thejson, node._id);
476476
},
477-
condition:''+function(node) { return node.metrics['MODE'] && node.metrics['MODE'].value == 'HEAT'; }
477+
condition:''+function(node) { return node.metrics['MODE']!=null && node.metrics['MODE'].value == 'HEAT'; }
478478
},
479479
{ label:'Heat', action:'', icon:'fa-fire',
480480
serverExecute:function(node){
@@ -485,7 +485,7 @@ exports.motes = {
485485
var thejson = { 'tmode':1, 't_heat' : --targetNow };
486486
exports.tstatRequest(thejson, node._id);
487487
},
488-
condition:''+function(node) { return node.metrics['MODE'] && node.metrics['MODE'].value != 'HEAT'; }
488+
condition:''+function(node) { return node.metrics['MODE']!=null && node.metrics['MODE'].value != 'HEAT'; }
489489
}]
490490
},
491491
//switch to AUTO mode
@@ -496,7 +496,7 @@ exports.motes = {
496496
if (modeNow=='AUTO') return;
497497
exports.tstatRequest({ 'tmode':3 }, node._id);
498498
},
499-
condition:''+function(node) { return node.metrics['MODE'] && node.metrics['MODE'].value == 'AUTO'; }
499+
condition:''+function(node) { return node.metrics['MODE']!=null && node.metrics['MODE'].value == 'AUTO'; }
500500
},
501501
{ label:'Auto', action:'', icon:'fa-balance-scale',
502502
serverExecute:function(node){
@@ -505,7 +505,7 @@ exports.motes = {
505505
if (modeNow=='AUTO') return;
506506
exports.tstatRequest({ 'tmode':3 }, node._id);
507507
},
508-
condition:''+function(node) { return node.metrics['MODE'] && node.metrics['MODE'].value != 'AUTO'; }
508+
condition:''+function(node) { return node.metrics['MODE']!=null && node.metrics['MODE'].value != 'AUTO'; }
509509
}]
510510
},
511511
//switch thermostat OFF
@@ -516,7 +516,7 @@ exports.motes = {
516516
if (modeNow=='OFF') return;
517517
exports.tstatRequest({ 'tmode':0 }, node._id);
518518
},
519-
condition:''+function(node) { return node.metrics['MODE'] && node.metrics['MODE'].value == 'OFF'; }
519+
condition:''+function(node) { return node.metrics['MODE']!=null && node.metrics['MODE'].value == 'OFF'; }
520520
},
521521
{ label:'Off', action:'', icon:'fa-power-off',
522522
serverExecute:function(node){
@@ -525,7 +525,7 @@ exports.motes = {
525525
if (modeNow=='OFF') return;
526526
exports.tstatRequest({ 'tmode':0 }, node._id);
527527
},
528-
condition:''+function(node) { return node.metrics['MODE'] && node.metrics['MODE'].value != 'OFF'; }
528+
condition:''+function(node) { return node.metrics['MODE']!=null && node.metrics['MODE'].value != 'OFF'; }
529529
}],
530530
breakAfter:true,
531531
},
@@ -538,7 +538,7 @@ exports.motes = {
538538
var thejson = (fanNow == 'AUTO' ? { 'fmode':2 } : { 'fmode':0 }); //toggle between ON and AUTO
539539
exports.tstatRequest(thejson, node._id);
540540
},
541-
condition:''+function(node) { return node.metrics['FSTATE'] && node.metrics['FSTATE'].value == 'AUTO'; }
541+
condition:''+function(node) { return node.metrics['FSTATE']!=null && node.metrics['FSTATE'].value == 'AUTO'; }
542542
},
543543
{ label:'Turn fan AUTO', action:'', icon:'fa-lock', css:'background-color:#9BFFBE',
544544
serverExecute:function(node){
@@ -548,7 +548,7 @@ exports.motes = {
548548
var thejson = (fanNow == 'AUTO' ? { 'fmode':2 } : { 'fmode':0 }); //toggle between ON and AUTO
549549
exports.tstatRequest(thejson, node._id);
550550
},
551-
condition:''+function(node) { return node.metrics['FSTATE'] && node.metrics['FSTATE'].value == 'ON'; }
551+
condition:''+function(node) { return node.metrics['FSTATE']!=null && node.metrics['FSTATE'].value == 'ON'; }
552552
}],
553553
},
554554
//toggle HOLD on/off
@@ -560,7 +560,7 @@ exports.motes = {
560560
var thejson = (holdNow == 'OFF' ? { 'hold':1 } : { 'hold':0 });
561561
exports.tstatRequest(thejson, node._id);
562562
},
563-
condition:''+function(node) { return node.metrics['HOLD'] && node.metrics['HOLD'].value == 'OFF'; }
563+
condition:''+function(node) { return node.metrics['HOLD']!=null && node.metrics['HOLD'].value == 'OFF'; }
564564
},
565565
{ label:'HOLD', action:'', icon:'fa-lock', css:'background-color:#9BFFBE',
566566
serverExecute:function(node){
@@ -570,7 +570,7 @@ exports.motes = {
570570
var thejson = (holdNow == 'OFF' ? { 'hold':1 } : { 'hold':0 });
571571
exports.tstatRequest(thejson, node._id);
572572
},
573-
condition:''+function(node) { return node.metrics['HOLD'] && node.metrics['HOLD'].value == 'ON'; }
573+
condition:''+function(node) { return node.metrics['HOLD']!=null && node.metrics['HOLD'].value == 'ON'; }
574574
}],
575575
},
576576
},

0 commit comments

Comments
 (0)