Example: Send mail notification on motion detection
Posted: 11 Mar 2012 18:54
In this short topic I would like to show how to configure Z-Cloud to send E-Mail notifications on motion detection.We suppose you have gmail account or something similiar. For security reasons we suggest you to set up new account for these notification mails (not to type in Z-Cloud password from your mail account). You can then redirect messages from this account to any other mail address (or even many of them).First of all include your motion detector and configure the device.Then switch to Expert mode and create a new scene with a script:# Edit your gmail credentials and the message to be sent
gmail_user = "xxxxxxxxx@gmail.com"
gmail_pwd = "xxxxxxxxx"
subj = "test"
text = """
Text message...
Long text message...
"""
# Don't edit below
import smtplib
smtpserver = smtplib.SMTP("smtp.gmail.com", 587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(gmail_user, gmail_pwd)
smtpserver.sendmail(gmail_user, gmail_user, "From: %s
To: %s
Subject: %s
%s
" % (gmail_user, gmail_user, subj, text))
Then create new rule that will catch the event from the detector and activate the script above. Have fun!Here are screenshots of the config. Scene: Rule:
gmail_user = "xxxxxxxxx@gmail.com"
gmail_pwd = "xxxxxxxxx"
subj = "test"
text = """
Text message...
Long text message...
"""
# Don't edit below
import smtplib
smtpserver = smtplib.SMTP("smtp.gmail.com", 587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(gmail_user, gmail_pwd)
smtpserver.sendmail(gmail_user, gmail_user, "From: %s
To: %s
Subject: %s
%s
" % (gmail_user, gmail_user, subj, text))
Then create new rule that will catch the event from the detector and activate the script above. Have fun!Here are screenshots of the config. Scene: Rule: