Skip to content

Instantly share code, notes, and snippets.

@njregenwether
Last active December 30, 2019 07:02
Show Gist options
  • Select an option

  • Save njregenwether/5f58ee608ecfc9998d07f3a70cbc0590 to your computer and use it in GitHub Desktop.

Select an option

Save njregenwether/5f58ee608ecfc9998d07f3a70cbc0590 to your computer and use it in GitHub Desktop.
Turn Roku Off
#!/usr/bin/python
# Simple script to turn off roku. Send it an ip address of your roku and it'll turn it off.
# This script is so green and earth friendly it basically refrigerates the polar ice caps.
# Schedule this with cron to turn your roku and most likely TV off.
#
# crontab -e
# ex. shut off my roku at 8 am every day if roku is on 192.168.1.2
# 0 8 * * * ./rokuoff.py 192.168.1.2
import argparse, requests, sys
parser = argparse.ArgumentParser()
parser.add_argument("ip", help="The ip address of the roku", type=str)
args = parser.parse_args()
#ip = str(sys.argv[1])
request = "http://" + args.ip + ":8060/keypress/Home"
offrequest = "http://" + args.ip + ":8060/keypress/PowerOff"
response = requests.post(request)
response2 = requests.post(offrequest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment