def submit_fsr_tempodb(date, fsr_median):
	#print date
	#print fsr_median
	db = SQLite('db/coffee.db')
	db.insert_coffee(date, fsr_median)
	#data = [DataPoint(date, fsr_median)]
	#client.write_key('coffee', data)
	return
def json_last24h():
    db = SQLite("db/coffee.db")
    today = datetime.now()
    yesterday = datetime.now() - timedelta(hours=1)
    # fetch data and format it for javascript friendly format
    records = db.fetch_coffee_by_date(yesterday, today)
    ret = []
    for record in records:
        d = datetime.strptime(record[1].split(".")[0], "%Y-%m-%d %H:%M:%S")
        ret.append((d.year, d.month, d.day, d.hour, d.minute, d.second, record[2]))

    return json.dumps(ret)
def submit_rfid_tempodb(date, rfid_values):	
	# print date
	# print rfid_values
	
	# submit all the rfid values read
	#for rfid_value in rfid_values:
	consumers = []
	for consumer in rfid_values:
		if not consumer in consumers:
			consumers.append(consumer)
	
	db = SQLite('db/coffee.db')
	for consumer in consumers:
		db.insert_coffee_consumer(date, consumer)
		#db.insert_coffee_consumer(date, "ME")
	return