Commit cd5edaf7 authored by Kristian Tan's avatar Kristian Tan

Query db for latest entry

parent 94072405
......@@ -72,7 +72,13 @@ def toggle_pin(change_pin):
if GPIO.input(change_pin) == 0:
message += " off."
if pins[change_pin]['on_time'] is not None:
latest_entry = db.session.query(DailyUsage).order_by(DailyUsage.id.desc()).first()
print("========= LATEST")
print(latest_entry)
print("=========")
start_time = pins[change_pin]['on_time']
# Get the elapsed time and strip away milliseconds
elapsed = str(datetime.now() - start_time).split(".")[0]
# Format the time
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment