You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Voltage logging/graphing by default
- logging is done only if data value is different or enough time has
passed (1h)
- fixed bug with graph showing on non graphed metrics
- added ability to override graph Yaxis min/max/autoscaleMargin in
metrics definitions
- added sample motion/temperature SMS events with limiter (SMS only once
per N unit of time)
- other minor adjustments
@@ -440,15 +440,15 @@ global.processSerialData = function (data) {
440
440
}
441
441
442
442
//check for duplicate messages - this can happen when the remote node sends an ACK-ed message but does not get the ACK so it resends same message repeatedly until it receives an ACK
Copy file name to clipboardExpand all lines: metrics.js
+60-1Lines changed: 60 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,8 @@
27
27
// - value - this can be hardcoded, or if left blank the value will be the first captured parentheses from the regex expression
28
28
// - pin:1/0 - if '1' then by default this metric will show up in the main homepage view for that node, otherwise it will only show in the node page; it can then manually be flipped in the UI
29
29
// - graph:1/0 - if '1' then by default this metric will be logged in gatewayLog.db every time it comes in
30
+
// - if '0' then this would not be logged but can be turned on from the metric details page
31
+
// - if not defined then metric is not logged and toggle button is hidden in metric detail page
30
32
// - logValue - you can specify a hardcoded value that should be logged instead of the captured metric (has to always be numeric!)
31
33
// - graphOptions - this is a javascript object that when presend is injected directly into the FLOT graph for the metric - you can use this to highly customize the appearance of any metric graph
32
34
// - it should only be specified one per each metric - the first one (ie one for each set of metrics that have multiple entries with same 'name') - ex: GarageMote 'Status' metric
mailboxAlert : {label:'Mailbox Open Alert!',icon:'audio',descr:'Message sound when mailbox is opened',serverExecute:function(node){if(node.metrics['M']&&node.metrics['M'].value=='MOTION'&&(Date.now()-newDate(node.metrics['M'].updated).getTime()<2000)){io.sockets.emit('PLAYSOUND','sounds/incomingmessage.wav');};}},
125
127
motionEmail : {label:'Motion : Email',icon:'mail',descr:'Send email when MOTION is detected',serverExecute:function(node){if(node.metrics['M']&&node.metrics['M'].value=='MOTION'&&(Date.now()-newDate(node.metrics['M'].updated).getTime()<2000)){sendEmail('MOTION DETECTED','MOTION WAS DETECTED ON NODE: ['+node._id+':'+node.label+'] @ '+(newDate().toLocaleTimeString()+(newDate().getHours()>12 ? 'PM':'AM')));};}},
126
128
motionSMS : {label:'Motion : SMS',icon:'comment',descr:'Send SMS when MOTION is detected',serverExecute:function(node){if(node.metrics['M']&&node.metrics['M'].value=='MOTION'&&(Date.now()-newDate(node.metrics['M'].updated).getTime()<2000)){sendSMS('MOTION DETECTED','MOTION WAS DETECTED ON NODE: ['+node._id+':'+node.label+'] @ '+(newDate().toLocaleTimeString()+(newDate().getHours()>12 ? 'PM':'AM')));};}},
129
+
130
+
motionSMSLimiter : {label:'Motion : SMS Limited',icon:'comment',descr:'Send SMS when MOTION is detected, once per hour',
131
+
serverExecute:function(node){
132
+
if(node.metrics['M']&&node.metrics['M'].value=='MOTION'&&(Date.now()-node.metrics['M'].updated<2000))/*check if M metric exists and value is MOTION, received less than 2s ago*/
133
+
{
134
+
varapproveSMS=false;
135
+
if(node.metrics['M'].lastSMS)/*check if lastSMS value is not NULL ... */
136
+
{
137
+
if(Date.now()-node.metrics['M'].lastSMS>1800000)/*check if lastSMS timestamp is more than 1hr ago*/
138
+
{
139
+
approveSMS=true;
140
+
}
141
+
}
142
+
else
143
+
{
144
+
approveSMS=true;
145
+
}
146
+
147
+
if(approveSMS)
148
+
{
149
+
node.metrics['M'].lastSMS=Date.now();
150
+
sendSMS('MOTION DETECTED','MOTION WAS DETECTED ON NODE: ['+node._id+':'+node.label+'] @ '+(newDate().toLocaleTimeString()+(newDate().getHours()>12 ? 'PM':'AM')));
151
+
db.update({_id: node._id},{$set : node},{},function(err,numReplaced){console.log(' ['+node._id+'] DB-Updates:'+numReplaced);});/*save lastSMS timestamp to DB*/
temperatureSMSLimiter : {label:'THAlert : SMS Limited',icon:'comment',descr:'Send SMS when F>75°, once per hour',
159
+
serverExecute:function(node){
160
+
if(node.metrics['F']&&node.metrics['F'].value>75&&(Date.now()-node.metrics['F'].updated<2000))/*check if M metric exists and value is MOTION, received less than 2s ago*/
161
+
{
162
+
varapproveSMS=false;
163
+
if(node.metrics['F'].lastSMS)/*check if lastSMS value is not NULL ... */
164
+
{
165
+
if(Date.now()-node.metrics['F'].lastSMS>1800000)/*check if lastSMS timestamp is more than 1hr ago*/
mailboxSMS : {label:'Mailbox open : SMS',icon:'comment',descr:'Send SMS when mailbox is opened',serverExecute:function(node){if(node.metrics['M']&&node.metrics['M'].value=='MOTION'&&(Date.now()-newDate(node.metrics['M'].updated).getTime()<2000)){sendSMS('MAILBOX OPENED','Mailbox opened ['+node._id+':'+node.label+'] @ '+(newDate().toLocaleTimeString()+(newDate().getHours()>12 ? 'PM':'AM')));};}},
128
187
motionLightON23 : {label:'Motion: SM23 ON!',icon:'action',descr:'Turn SwitchMote:23 ON when MOTION is detected',serverExecute:function(node){if(node.metrics['M']&&node.metrics['M'].value=='MOTION'&&(Date.now()-newDate(node.metrics['M'].updated).getTime()<2000)){sendMessageToNode({nodeId:23,action:'MOT:1'});};}},
0 commit comments