Commit 160b2517 authored by raspi's avatar raspi

Merge branch 'master' of github.com:KristianTan/IoTSmartMeter

parents b4954136 5f3eb731
...@@ -57,7 +57,7 @@ def create_entry(change_pin): ...@@ -57,7 +57,7 @@ def create_entry(change_pin):
start_date = pins[change_pin]['on_date'] start_date = pins[change_pin]['on_date']
# 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
# 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)
...@@ -102,10 +102,10 @@ todays_cost = get_todays_cost() ...@@ -102,10 +102,10 @@ todays_cost = get_todays_cost()
# 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},
8: {'name': None, 'state': GPIO.LOW, 'on_time': None, 'on_date': None, 'Wattage': 0}, 8: {'name': None, 'state': GPIO.LOW, 'on_time': None, 'on_date': None, 'wattage': 0},
7: {'name': None, 'state': GPIO.LOW, 'on_time': None, 'on_date': None, 'Wattage': 0}, 7: {'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} 12: {'name': None, 'state': GPIO.LOW, 'on_time': None, 'on_date': None, 'wattage': 0}
} }
# Setup each pin # Setup each pin
...@@ -208,7 +208,7 @@ def handle_new_device(): ...@@ -208,7 +208,7 @@ def handle_new_device():
for key in pins: for key in pins:
if pins[key]['name'] is None: if pins[key]['name'] is None:
pins[key]['name'] = new_name pins[key]['name'] = new_name
pins[key]['Wattage'] = new_wattage pins[key]['wattage'] = new_wattage
break break
template_data = { template_data = {
...@@ -229,7 +229,7 @@ def delete_pin(delete_pin): ...@@ -229,7 +229,7 @@ def delete_pin(delete_pin):
for key in pins: for key in pins:
if key == delete_pin: if key == delete_pin:
pins[delete_pin]['name'] = None pins[delete_pin]['name'] = None
pins[delete_pin]['Wattage'] = None pins[delete_pin]['wattage'] = None
break break
template_data = { template_data = {
......
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