Skip to content

Instantly share code, notes, and snippets.

@bassdread
Last active August 29, 2015 13:57
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bassdread/9559427 to your computer and use it in GitHub Desktop.
Extract from Skynet to Plot.ly
from pymongo import Connection
import time
from datetime import datetime
import plotly
conn = Connection('localhost', 27017)
db = conn.skynet
collection = db.events
# 24 hour time range
time = int(round((time.time() - 86400) * 1000))
results = collection.find({
"timestamp": {"$gte" : time },
"uuid": "UUID"
})
x = []
y = []
for i in results:
if 'temperature' in i.keys():
ts= str(int(i['timestamp']))[:-3]
x.append(datetime.fromtimestamp(int(ts)))
y.append(str(i['temperature']))
# start time
#print x[0]
# end time
#print x[-1]
py = plotly.plotly("USERNAME", "PASSWORD")
py.plot(x,y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment