Example: Send mail notification on motion detection

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
Locked
User avatar
PoltoS
Posts: 5103
Joined: 26 Jan 2011 19:36

Example: Send mail notification on motion detection

Post by PoltoS » 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:

eligv
Posts: 30
Joined: 08 Jun 2012 17:50

Hello,

Post by eligv » 11 Mar 2012 18:54

Hello,
As instructed him to send me an email manually triggering the routine. The detection do with the EZ-motion LED is activated when motion is detected but does not trigger a routine. It happens as with temperature decteccion for shooting scene heating. The EZmotion is updated every minute, but not active routines. How could verify that the system collects real-time data from the detector?
Any idea of possible failure?

thanks

User avatar
PoltoS
Posts: 5103
Joined: 26 Jan 2011 19:36

Enable verbose or even debug

Post by PoltoS » 11 Mar 2012 18:54

Enable verbose or even debug logging. You will see that incoming events do not match the rule you have created. Otherwise it must work ;)

eligv
Posts: 30
Joined: 08 Jun 2012 17:50

solved!

Post by eligv » 11 Mar 2012 18:54

solved!
Changing the instance 1 instance EZmotion and put the 0 in the rule condition. ;)

Thank you!

Locked