SMS - Email - Metrics.JS

Started by LaneF, October 18, 2015, 11:01:00 PM

LaneF

Anyone...

One step at a time -- Tonight, it's SMS and email Alerts.

I tried my first one tied to my GarageMote.  GM works great.

I went into the Metrics.js and editing the "Export.Events" to reflect this:
QuoteGarageOpen : { label:'Garage Open Alert : SMS', icon:'comment', descr:'Send SMS when Garge is opened', serverExecute:function(node) { if (node.metrics['M'] && node.metrics['M'].value == 'MOTION' && (Date.now() - new Date(node.metrics['M'].updated).getTime() < 2000)) { sendSMS('GARAGE DOOR OPENED', 'Garge Door Opened [' + node._id + ':' + node.label + '] @ ' + (new Date().toLocaleTimeString() + (new Date().getHours() > 12 ? 'PM':'AM'))); }; } },

I went into Settings.js and edited the communications stuff:
QuotesmsAlertsTo : '[email protected]',
(I added the 555# as an example - my phone # is in the js.)

Turned on the Event Action under the Garage Door Event box:  (see attached pic)

No SMS - Anything standout that I did wrong on this ???

Thanks All

LaneF


Hit the close button on the Moteino Gateway

hrant

gmail never worked for me (probably due to security)
so instead of using
emailservice : 'Gmail',

I defined in settings file
  emailhost : 'smtp.yourmailserver.com',   // Change to match your mail server
  emailport : 587,                                       // change to match your mail server port

and updated the transporter in gateway.js to this
var transporter = nodemailer.createTransport({
	    host: settings.credentials.emailhost,
	    port: settings.credentials.emailport,
	    secure: false,
	    auth: {
	        user: settings.credentials.email,
	        pass: settings.credentials.emailpass,
	    }
	});


Good luck

Felix

Gmail has several ways of sending email from what I remember when I first played with this. The nodemailer nodejs client has predefined settings for gmail (and other major email providers) so instead of going through all the specific settings of smtp and port numbers all you do is specify 'Gmail', I think that's a plus since a lot of people use gmail and it's similar for other providers.
There may be better ways to do this but I never had an issue so I just left it at that. There are many services online that can push notifications, one example is Pushover. I went the email route since that's free when you use your own email to send email/sms notifications. Once you figure out the settings (each provider has them published somewhere) it just works. I would always send with a secured connection.

For more on how to setup an email client in nodemailer visit this page, it has examples and walkthroughs and the whole API of nodemailer.

MikesTechBlog

Hrant, you said that gmail never worked for you. I too had that problem. It looks like gmail has tighter security settings for such things that according to google, "do not use modern security standards".

I ha to go to gmail's "Less secure apps" section and tell it to allow logins.

Here is their link for the full explanation.: https://support.google.com/accounts/answer/6010255

-- Mike

PS. I know this is an older post, and slightly off topic, but I was looking for a solution to gmail not working, so I figure someone else might need this info as well.
My Tech Blog:

Mike's Tech Blog

rlramirez77

I am working on using mailgun service, which is supported in nodemailer - so far it's looking like it might work.

Russ