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

Display todays cost

parent 50faf798
...@@ -43,6 +43,8 @@ if latest_entry: ...@@ -43,6 +43,8 @@ if latest_entry:
if latest_entry_date == datetime.today().date(): if latest_entry_date == datetime.today().date():
daily_total = format(latest_entry.kwhUsed, '.7f') daily_total = format(latest_entry.kwhUsed, '.7f')
todays_cost = format(float(daily_total) * 0.1622, '0.5f')
# Create dictionary to store pin info # Create dictionary to store pin info
pins = { pins = {
25: {'name': 'Light', 'state': GPIO.LOW, 'on_time': None, 'on_date': None, 'Wattage': 15} 25: {'name': 'Light', 'state': GPIO.LOW, 'on_time': None, 'on_date': None, 'Wattage': 15}
...@@ -63,7 +65,8 @@ def main(): ...@@ -63,7 +65,8 @@ def main():
# Set the template data for the HTML template # Set the template data for the HTML template
template_data = { template_data = {
'pins': pins, 'pins': pins,
'daily_total': daily_total 'daily_total': daily_total,
'todays_cost': todays_cost
} }
return render_template('main.html', **template_data) return render_template('main.html', **template_data)
...@@ -95,10 +98,7 @@ def toggle_pin(change_pin): ...@@ -95,10 +98,7 @@ def toggle_pin(change_pin):
else: else:
daily_total = 0 daily_total = 0
todays_cost = float(daily_total) * 0.1622 todays_cost = format(float(daily_total) * 0.1622, '0.5f')
print(todays_cost)
todays_cost = format(todays_cost, '.5f')
print(todays_cost)
template_data = { template_data = {
'pins': pins, 'pins': pins,
......
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