Skip to content

Instantly share code, notes, and snippets.

@zone13
Last active September 1, 2022 20:46
Show Gist options
  • Save zone13/947e9eea96294a6e070b630378349e70 to your computer and use it in GitHub Desktop.
Save zone13/947e9eea96294a6e070b630378349e70 to your computer and use it in GitHub Desktop.
Python script to post an alert tweet when motion is detected by MotionEyeOS
#!/usr/bin/env python
##########################################################################
### Python Script to post a tweet when motion is detected by MotionEyeOS
### run 'sudo pip install python-twitter' before execution
### Author: Sid
### https://zone13.io
### Version 1.0
##########################################################################
import twitter, time
# Populate the Twitter API keys below
consumer_key = ''
consumer_secret = ''
access_token_key = ''
access_token_secret = ''
api = twitter.Api(
consumer_key=consumer_key,
consumer_secret=consumer_secret,
access_token_key=access_token_key,
access_token_secret=access_token_secret)
# Get current time
t = time.strftime("%d-%m-%Y %H:%M:%S", time.gmtime())
status = "Alert !! Motion detected at " + t
# Tweet motion detection alert
status = api.PostUpdate(status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment