In [34]:
#send random prediction to the server
#make send fake temperatures to the server
import requestAPI
import random
from time import sleep
import datetime as dt
import math
In [35]:
#make connection object
connection = requestAPI.ECWConnection(host='https://ecollectweb.herokuapp.com')
In [36]:
x=0
def make_random_prediction():
global x
t = dt.datetime.now(tz=requestAPI.utc)
d = dt.timedelta(seconds=5)
delta = 0.25
prediction = []
for i in range(6):
prediction.append({"datetime": str(t),"temp": math.sin(x)*20 + 70})
t+= d#increment time by 5 seconds
x+=delta
return prediction
In [ ]:
#make prediction
while True:
prediction = make_random_prediction()
res = connection.updatePrediction(prediction=prediction)
print res
sleep(6*2)
In [ ]: