import time import serial import smtplib import actioncharts import subprocess TO = 'actioncharts@gmail.com' GMAIL_USER = 'actioncharts@gmail.com' GMAIL_PASS = 'Sarla2013' SUBJECT = 'Intrusion!!' TEXT = 'Your PIR sensor detected movement. Watch Live feed http://twitcasting.tv/f:100007874763342' passcode = "6040db48-5c14-41eb-bd45-8906558dbbbc" # your 32 digit ActionCharts UID email = "demo@actioncharts.com" # the email (or group) that has access to this report name1 = "Intruder Alert" # the main title of the report name2 = "ActionBurglarAlarm" # the secondary title, used with name1 to create an unique ID info = "Call security at 401-495-4041 | watch live feed here http://twitcasting.tv/f:100007874763342" # any additional information about the report decimal = "" # the decimal mark if other than a decimal point separator = "" # the thousands separator if other than a comma myreport = actioncharts.ActionReport(passcode, name1, name2, email, info) ser = serial.Serial('COM25', 9600) def send_email(): print("Sending Email") smtpserver = smtplib.SMTP("smtp.gmail.com",587) smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo smtpserver.login(GMAIL_USER, GMAIL_PASS) header = 'To:' + TO + '\n' + 'From: ' + GMAIL_USER header = header + '\n' + 'Subject:' + SUBJECT + '\n' print header msg = header + '\n' + TEXT + ' \n\n' smtpserver.sendmail(GMAIL_USER, TO, msg) smtpserver.close() while True: message = ser.readline() print(message) myreport.add_tag("ActionAlarm", "Intruder Alert!!!","Call security at 401-495-4041 | watch live feed here http://twitcasting.tv/f:100007874763342" ) r = myreport.update() print r if message[0] == 'M' : send_email() time.sleep(0.5)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question