In trying to create an event as shown in the following thread;
https://lowpowerlab.com/forum/pi-gateway/dynamic-node-specific-event-trigger/msg21232/#msg21232I keep getting the following error in the gateway.sys.log;
[01-04-20_10:53:30.630] [WARN] Event tempTooColdSMSLimiter execution failed: Cannot read property 'lowTempValue' of undefined
[01-04-20_10:53:30.633] [WARN] Event tempTooHotSMSLimiter execution failed: Cannot read property 'highTempValue' of undefined
The following was added to exports.events;
tempTooColdSMSLimiter : { label:'TooColdAlert : SMS', icon:'comment', descr:'Send SMS when Temp is < than the lowValue setting, once per 30 min.',
serverExecute:function(node) {
if (node.metrics['F'] && node.metrics['F'].value < node.settings['lowTempValue'] && (Date.now() - node.metrics['F'].updated < 2000)) /*check if M metric exists and value is MOTION, received less than 2s ago*/
{
var approveSMS = false;
if (node.metrics['F'].lastSMS) /*check if lastSMS value is not NULL ... */
{
if (Date.now() - node.metrics['F'].lastSMS > 1800000) /*check if lastSMS timestamp is more than 1hr ago */
{
approveSMS = true;
}
}
else
{
approveSMS = true;
}
if (approveSMS)
{
node.metrics['F'].lastSMS = Date.now();
sendSMS('Too cold!', 'Temperature alert on: [' + node._id + '] :' + node.label.replace(/\{.+\}/ig, '') + ' @ ' + new Date().toLocaleTimeString());
db.update({ _id: node._id }, { $set : node}, {}, function (err, numReplaced) { console.log(' ['+node._id+'] DB-Updates:' + numReplaced);}); /*save lastSMS timestamp to DB*/
}
else console.log(' ['+node._id+'] TooColdAlert SMS skipped.');
};
}
},
tempTooHotSMSLimiter : { label:'TooHotAlert : SMS', icon:'comment', descr:'Send SMS when Temp is > than the highValue setting, once per 30 min.',
serverExecute:function(node) {
if (node.metrics['F'] && node.metrics['F'].value > node.settings['highTempValue'] && (Date.now() - node.metrics['F'].updated < 2000)) /*check if M metric exists and value is MOTION, received less than 2s ago*/
{
var approveSMS = false;
if (node.metrics['F'].lastSMS) /*check if lastSMS value is not NULL ... */
{
if (Date.now() - node.metrics['F'].lastSMS > 1800000) /*check if lastSMS timestamp is more than 1hr ago*/
{
approveSMS = true;
}
}
else
{
approveSMS = true;
}
if (approveSMS)
{
node.metrics['F'].lastSMS = Date.now();
sendSMS('Too hot!', 'Temperature alert on: [' + node._id + '] :' + node.label.replace(/\{.+\}/ig, '') + ' @ ' + new Date().toLocaleTimeString());
db.update({ _id: node._id }, { $set : node}, {}, function (err, numReplaced) { console.log(' ['+node._id+'] DB-Updates:' + numReplaced);}); /*save lastSMS timestamp to DB*/
}
else console.log(' ['+node._id+'] TooHotAlert SMS skipped.');
};
}
},
The following was added to exports.motes;
},
settings: { ip:'',
lowTempValue: '',
highTempValue: ''}, //blank will inherit ip value from global settings.json
}
}
and this is the section of the system.json5 file that was edited;
radiothermostat: {
editable: true,
exposed: true,
ip: {
value: '10.0.0.41',
description: 'If you have a wifi RadioThermostat CT50/CT80 this is the IP address',
},
lowTempValue: {
value: 68,
type: 'range',
min:32,
max:75,
description: 'Send SMS when Temp is < than the lowValue setting, once per 30 min.'
},
highTempValue: {
value: 75,
type: 'range',
min:50,
max:90,
description: 'Send SMS when Temp is > than the highValue setting, once per 30 min.'
},
},
Any help into what I have done wrong would be greatly appreciated. Thank you!
Attached are a couple screenshots from phone.