Commit 4cd2fdd9 authored by Kristian Tan's avatar Kristian Tan

styling

parent 0c70fc93
...@@ -4,6 +4,7 @@ from flask_sqlalchemy import SQLAlchemy ...@@ -4,6 +4,7 @@ from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import asc, desc from sqlalchemy import asc, desc
import os import os
from datetime import datetime, date, timedelta from datetime import datetime, date, timedelta
# from daily_usage import DailyUsage # from daily_usage import DailyUsage
app = Flask(__name__) app = Flask(__name__)
...@@ -57,20 +58,12 @@ def create_entry(change_pin): ...@@ -57,20 +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(pins[change_pin]['Wattage'])
print(elapsed)
print(kwh)
print("LATEST ENTRY: ")
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:
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:
print("LATEST ENTRY DATE: ")
print(latest_entry_date)
latest_entry.kwhUsed += kwh latest_entry.kwhUsed += kwh
else: else:
print("NEW")
# 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)
...@@ -87,7 +80,7 @@ def generate_graph_data(): ...@@ -87,7 +80,7 @@ def generate_graph_data():
# Create data for chart # Create data for chart
# count = 0 # count = 0
records = DailyUsage.query.order_by(desc(DailyUsage.date)).limit(7).all() records = DailyUsage.query.order_by(desc(DailyUsage.date)).limit(7).all()
print(records) (records)
for record in records: for record in records:
labels.append(date(record.date.year, record.date.month, record.date.day)) labels.append(date(record.date.year, record.date.month, record.date.day))
values.append(record.kwhUsed) values.append(record.kwhUsed)
...@@ -115,13 +108,11 @@ pins = { ...@@ -115,13 +108,11 @@ pins = {
12: {'name': None, 'state': GPIO.LOW, 'on_time': None, 'on_date': None, 'Wattage': 0} 12: {'name': None, 'state': GPIO.LOW, 'on_time': None, 'on_date': None, 'Wattage': 0}
} }
# Setup each pin # Setup each pin
for pin in pins: for pin in pins:
GPIO.setup(pin, GPIO.OUT) GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, GPIO.LOW) GPIO.output(pin, GPIO.LOW)
labels, values, max = generate_graph_data() labels, values, max = generate_graph_data()
......
...@@ -16,13 +16,11 @@ body { ...@@ -16,13 +16,11 @@ body {
.containerRows { .containerRows {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
/*background-color: darkkhaki;*/
/*height: 90%;*/ /*height: 90%;*/
} }
.device_list { .device_list {
width: 25%; width: 25%;
/*background-color: red;*/
margin-left: 5%; margin-left: 5%;
text-align: left; text-align: left;
border-bottom-style: solid; border-bottom-style: solid;
...@@ -35,10 +33,9 @@ body { ...@@ -35,10 +33,9 @@ body {
.smart_meter { .smart_meter {
width: 65%; width: 65%;
margin-right: 5%; margin-right: 2%;
margin-left: 5%; margin-left: 5%;
margin-bottom: 2%; margin-bottom: 2%;
/*background-color: coral;*/
border-style: solid; border-style: solid;
border-color: black; border-color: black;
border-width: 1px; border-width: 1px;
......
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