Code: Select all
# We're going to twitter at midnight, 8am and 4pm
# Determine the hour of the day (ie 6:42 -> '6')
currhour = datetime.datetime.now().hour
# twitter every 8 hours
if (((time.time() - twittertimer) >= 3660.0) and (currhour % 8 == 0)):
print "twittertime!"
twittertimer = time.time();
if not LOGFILENAME:
message = appengineauth.gettweetreport()
print "getting tweet report\n"
else:
# sum up all the sensors' data
wattsused = 0
whused = 0
print time.time()
for history in sensorhistories.sensorhistories:
wattsused += history.avgwattover5min()
whused += history.dayswatthr
message = "Currently using "+str(int(wattsused))+" Watts, "+str(int(whused))+" Wh today so far #tweetawatt"
# write something ourselves
if message:
print message
TwitterIt(twitterusername, twitterpassword, message)
#clear out Wh history at midnight, after twitter.
if (currhour == 0):
history.dayswatthr = 0