The raspberry pi is responsible for sending email notification(s) when an alert event is received from the watch. I booted up a fresh install of Raspbian and created an ~/alerter folder to house my code.
Inside the ~/alerter folder is an alerter.py script that runs at startup to listen for chronos events, and it is based on the following code:
When an "S1" button press is received, alerter executes sendalert.py which calls a function in email_handler.py to actually send the email. The recipients are hard-coded in sendalert.py. Email_handler.py uses the smtplib, MIMEMultipart and MIMEText libs to handle sending - more info and instructions can be found here:
I set up a special gmail account for sending the alert emails and the information for that account is stored in a settings.ini file. The destination addresses can be any valid email address... I'm using a destination address from my mobile phone provider that converts the email to sms, so I get a text message when there's an alert.
To run the alerter.py script at startup, I modified the /etc/rc.local file with the following line: python /home/myrpi/alerter/alerter.py
/home/myrpi/alerter/alerter.py
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.