10
10
exports . thermostatDeviceTypeIds = { 2 :null , 3 :null } ;
11
11
12
12
13
+ const consoleLogAlertInfo = function ( alertInfo ) {
14
+ console . log ( 'alerts consoleLogAlertInfo' ) ;
15
+ for ( id in alertInfo ) {
16
+ console . log ( 'id: ' + id + ' alertInfo[id]: ' + JSON . stringify ( alertInfo [ id ] ) ) ;
17
+ }
18
+ } ;
19
+
20
+
13
21
//typically called with:
14
22
//alertInfo as object that is built with buildInitialAlertInfo and then updated with updateAlertInfo
15
23
//alertsConfig loaded from config file, alerts section
@@ -19,6 +27,7 @@ exports.thermostatDeviceTypeIds = {2:null, 3:null};
19
27
//
20
28
exports . alertLoop = function ( alertInfo , alertsConfig , sendAlertFunction , checksFunction , sleepTime ) {
21
29
console . log ( 'alerts alertLoop' ) ;
30
+ consoleLogAlertInfo ( alertInfo ) ;
22
31
23
32
if ( ! ( 'loopIndex' in alertInfo ) ) {
24
33
alertInfo . loopIndex = 0 ;
@@ -42,7 +51,7 @@ exports.alertLoop = function(alertInfo, alertsConfig, sendAlertFunction, checksF
42
51
43
52
exports . buildInitialAlertInfo = function ( db , callback ) {
44
53
database . getDeviceMetadata ( db , function ( deviceMetadata ) {
45
- database . getAlertSettings ( db , function ( alertSettings ) {
54
+ database . getAlertSettings ( db , function ( alertSettings ) {
46
55
for ( var id in deviceMetadata ) {
47
56
var curDevice = deviceMetadata [ id ] ;
48
57
curDevice . lastTime = null ;
@@ -186,6 +195,7 @@ exports.checkForTemperatureAlert = function(deviceAlertInfo) {
186
195
//sendAlertFunction as sendAlerts function in this module
187
196
exports . checkForAlerts = function ( alertInfo , sendAlertFunction , alertsConfig ) {
188
197
console . log ( 'alerts checkForAlerts' ) ;
198
+ consoleLogAlertInfo ( alertInfo ) ;
189
199
190
200
if ( sendAlertFunction == 'undefined' || sendAlertFunction == null ) {
191
201
sendAlertFunction = exports . SendAlert ;
@@ -195,6 +205,7 @@ exports.checkForAlerts = function(alertInfo, sendAlertFunction, alertsConfig) {
195
205
var alerts = [ ] ;
196
206
for ( var id in alertInfo ) {
197
207
var deviceAlertInfo = alertInfo [ id ] ;
208
+ console . log ( 'checking all alerts for id: ' + id + ' deviceAlertInfo: ' + JSON . stringify ( deviceAlertInfo ) ) ;
198
209
199
210
for ( var i = 0 ; i < alertFunctions . length ; i ++ ) {
200
211
var aFun = alertFunctions [ i ] ;
@@ -206,6 +217,9 @@ exports.checkForAlerts = function(alertInfo, sendAlertFunction, alertsConfig) {
206
217
alerts . push ( r ) ;
207
218
}
208
219
}
220
+
221
+ console . log ( 'finished checking for id: ' + id ) ;
222
+ console . log ( ) ;
209
223
}
210
224
211
225
if ( alerts . length > 0 ) {
0 commit comments