Garage Open Event sending Text

Started by megasis, May 09, 2015, 06:24:07 PM

megasis

I just want to share my experience,
added a new event called Garage SMS in the metrics.js and it is showing in the event types list. :)
I set up my gmail account on the gateway.js for email and my  mobile AT&T SMS address.

Now, when I open the garage, I know the PiGateway is trying to send the email, but the problem is Google Mail, it doesn't allow all email clients, what I received instead was an email from Gmail telling somebody tried to send an email but with a weak clien. Apparently for a year or so, gmail only support  rubust and secure clients, or changing the security setting in GMail, but I don't won't that. Fortunately I have several emails accounts and I know AOL works when I was texting my Raspberry Pi and Python.  That's my next test I'll keep you all post.
Maximo

megasis

#1
Finally, I'm getting Text Messages from my Pi Gateway  ;D 8),

I had to change the email server from Gmail to AOL in the gateway.js, Gmail has extra security controls that I don't want to disable just for this, AOL works fine and I already have an account.  The only change I needed to have it working with AOL (Other than the emai addresses) was the service:

var transporter = nodemailer.createTransport({
   service: [b]'Aol'[/b],
   auth: {
        user: "Moteino" <[email protected]>,


Originally, I just wanted to get a Text when the garage door was open, never the less, after testing for a couple of hours, I decided to create the switchSMS Alert because I wanted something simple and less noisy   :-\ for my SMS tests, instead of opening and closing my Garage every 2 minutes and the fact that my wife gave me an ultimatum >:( .

I configured 2 new events types in metrics.js under the section SAMPLE EVENTS/ALERTS, garageSMS and switchSMS, the code is as follow:

  garageSMS : { label:'Garage open : SMS', icon:'comment', descr:'Send SMS when Garage is opened',  serverExecute:function(node) { if (node.metrics['Status'] && node.metrics['Status'].value  == 'OPEN' && (Date.now() - new Date(node.metrics['Status'].updated).getTime() < 2000)) { sendSMS('GARAGE OPENED',  'GARAGE WAS OPENED, NODE:' + node._id + ' ' + node.label); }; } },

  switchSMS : { label:'Switch On : SMS',  icon:'comment', descr:'Send SMS when Switch is No', serverExecute:function(node) { if (node.metrics['B0'] && node.metrics['B0'].value == 'ON' && (Date.now() - new Date(node.metrics['B0'].updated).getTime() < 2000)) { sendSMS('SWITCH BO IS ON', 'SWITCH BO IS ON, NODE:' + node._id + ' ' + node.label); }; } },


I've attached a couple of screen shots showing the two new Alerts

Best regards



Felix