Skip to content

Automate wake-on-lan while away from home through Twitter

Notifications You must be signed in to change notification settings

maxrjohnson23/tweetwake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TweetWake - Wake up your desktop while away from home

Want to be able to wake up your PC at home while outside your home network? TweetWake monitors your Twitter account and can send a wake-on-lan packet when a tweet is detected on your timeline.

Benefits / Use Cases

  • Can run on a low-power device, such as a Raspberry Pi, allowing you to save energy by letting your desktop sleep
  • Enable remote desktop apps to start up and become available
  • No external static IP configurations from your ISP
  • Avoid network vulnerabilities associated with opening your home network to the internet

How it Works

  • Send a Tweet using any device using your monitored Twitter account. The Tweet can have any text you want.
  • The script runs on an interval to query Twitter pull the home timeline for a specified Twitter account every minute
  • If any tweets are detected in the past X minutes, send a magic packet to the specified MAC address on your home network
  • Schedule as a cron job to adjust the polling interval (recommended once per minute)

Setting up the Script

  1. Create a Twitter application with your Twitter developer account. Credentials are required to use Twitter's API. More Info
  2. Clone the repository to a location on your machine, or the device you will run it on git clone [email protected]:maxrjohnson23/tweetwake.git

Configuration

  1. Copy/rename the file sample_config.py to config.py
  2. Edit config.py and add the following
    1. Twitter API credentials
    2. Twitter handle (your account that you would like to poll)
    3. The MAC address of your device to wake.
      Note: This device must be on the same network and have wake-on-lan enabled in the BIOS and wake-on-magic-packet enabled in the network device driver: setup instructions
    4. Detection window in minutes. On each run the script will check for a tweet within the past X minutes

Deployment to Raspberry Pi (Raspbian Stretch)

  1. ssh into your Raspberry Pi using the devices IP address:

    ssh [email protected]

  2. Make sure python3 and pip3 are installed:

    sudo apt-get update && sudo apt-get install python3 && sudo apt-get install python3-pip

  3. If you downloaded the files to your main computer, you will need to copy them to the Raspberry Pi home directory

    1. From your main computer, navigate one folder up from the cloned repository. You should be able to see the tweetwake folder

    2. Run the copy command to transfer the files to the Raspberry Pi using the correct path and IP address

      scp -pr <DESKTOP-FOLDER-PATH>/tweetwake/ [email protected]:/home/pi/tweetwake

    3. You should now have all the same contents available in /home/pi/tweetwake on the Raspberry Pi

  4. Navigate to the folder /home/pi/tweetwake. Run pip install to pull the script's dependencies

    pip3 install -r requirements.txt

  5. Update your cron configuration to run the script every minute. This appends an entry if there are existing cron jobs. This causes python3 to execute the script every minute and output the log to /home/pi/tweetwake/log.txt

    (crontab -l && echo "* * * * * python3 /home/pi/tweetwake/tweetwake.py > /home/pi/tweetwake/log.txt") | crontab -

Troubleshooting

  • View the contents of /home/pi/tweetwake/log.txt for any errors using cat log.txt
  • Ensure the script is configured to run every minute. You can run crontab -l to view the file. There should be an entry: * * * * * python3 /home/pi/twitterwake/tweetwake.py > /home/pi/twitterwake/log.txt
  • Make sure your config.py file has the correct credentials and settings
  • Make sure your computer is enabled for wake-on-lan: setup instructions

About

Automate wake-on-lan while away from home through Twitter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages