Skip to content

Instantly share code, notes, and snippets.

@timleland

timleland/googlehome.py

Last active Apr 20, 2017
Embed
What would you like to do?
#!/usr/bin/env python
import urllib, json, subprocess, time
lastCommandDate = None
url = 'https://spreadsheets.google.com/feeds/list/YOUR_SPREADSHEET_ID/1/public/values?alt=json'
while True:
time.sleep(.5)
response = urllib.urlopen(url)
data = json.loads(response.read())
try:
lastIndex = len(data['feed']['entry']) - 1
currentCommandDate = data['feed']['entry'][lastIndex]['updated']['$t']
if lastCommandDate != currentCommandDate:
lastCommandDate = currentCommandDate
outletCode = data['feed']['entry'][lastIndex]['gsx$outletid']['$t']
subprocess.call(["/var/www/html/rfoutlet/codesend", outletCode])
except KeyError:
print "No commands exist."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.