I made a couple of updates to metrics.js I thought someone might find useful so here they are.
1. Update the battery voltage regex recognize V > 9.99
At the end of the exports.metrics section there are the special metrics containing the battery regex.
V : { name:'V', regexp:/(?:V?BAT|VOLTS|V)\:(\d\.\d+)v?/i, value:'', unit:'v'},
All you need to do is to change the sequence (\d.\d+) to (\d+.\d+) which will match 0.00 through 99.99 volts
2. Developing a generic email action for my door sensor.
Somewhat a work in progress, I want to have one event for all of the door sensors around the house (currently 2, hoping to install 7!). For now, I'm making do with 2 events, one for open, another for close, as I get more familiar with the gateway, I'll just have one for both open and close. I also wanted to email the current temperature - I might add the battery voltage if these motes are hard on power (they're using normally open reed switches that are closed when the door is closed, consuming power all the time).
DoorOpenEmail :
{
label:'Door Open : Email', icon:'mail', descr:'Send email when door opens',
serverExecute:function(node)
{
if (node.metrics['DOOR'] && node.metrics['DOOR'].value == 'OPEN' && (Date.now() - new Date(node.metrics['DOOR'].updated).getTime() < 2000))
{
var tempStr = "unk";
var now = new Date();
if (node.metrics['F'])
tempStr = node.metrics['F'].value;
sendEmail(node.label + ' Opened', node.label + ' opened. Node: [' + node._id + ':' + node.label + '] @ ' + now.toLocaleTimeString() + ' Temperature: ' + tempStr + 'F');
}
}
},
Good stuff, yes the \d+ is a good suggestion, it will match any number of integer digits, even 99999999999999999999.99 ;)