Commit 5aa27570 authored by Kristian Tan's avatar Kristian Tan

remove prints

parent 39d285f3
...@@ -58,15 +58,12 @@ def create_entry(change_pin): ...@@ -58,15 +58,12 @@ def create_entry(change_pin):
# Formula to calculate kWh based on time and wattage # Formula to calculate kWh based on time and wattage
kwh = pins[change_pin]['wattage'] * (elapsed / 3600) / 1000 kwh = pins[change_pin]['wattage'] * (elapsed / 3600) / 1000
print(latest_entry)
# If there is already an entry for today, update on time # If there is already an entry for today, update on time
if latest_entry: if latest_entry:
print("HERE?")
latest_entry_date = date(latest_entry.date.year, latest_entry.date.month, latest_entry.date.day) latest_entry_date = date(latest_entry.date.year, latest_entry.date.month, latest_entry.date.day)
if latest_entry_date == start_date: if latest_entry_date == start_date:
latest_entry.kwhUsed += kwh latest_entry.kwhUsed += kwh
else: else:
print("CREATE ENTRY")
# If no entry for today, make one # If no entry for today, make one
entry = DailyUsage(date=start_date, kwhUsed=kwh) entry = DailyUsage(date=start_date, kwhUsed=kwh)
db.session.add(entry) db.session.add(entry)
...@@ -75,6 +72,8 @@ def create_entry(change_pin): ...@@ -75,6 +72,8 @@ def create_entry(change_pin):
pins[change_pin]['on_date'] = None pins[change_pin]['on_date'] = None
db.session.add(DailyUsage(date(2019, 11, 17), 8.9))
def generate_graph_data(): def generate_graph_data():
labels = [] labels = []
values = [] values = []
...@@ -143,14 +142,12 @@ def main(): ...@@ -143,14 +142,12 @@ def main():
@app.route("/toggle/<change_pin>") @app.route("/toggle/<change_pin>")
def toggle_pin(change_pin): def toggle_pin(change_pin):
change_pin = int(change_pin) change_pin = int(change_pin)
device_name = pins[change_pin]['name']
# Toggle the selected pin # Toggle the selected pin
GPIO.output(change_pin, not GPIO.input(change_pin)) GPIO.output(change_pin, not GPIO.input(change_pin))
if GPIO.input(change_pin) == 0: if GPIO.input(change_pin) == 0:
if pins[change_pin]['on_time'] is not None: if pins[change_pin]['on_time'] is not None:
print("GOTO CREATE_ENTRY")
create_entry(change_pin) create_entry(change_pin)
else: else:
......
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