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):
start_date = pins[change_pin]['on_date']
# 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 latest_entry:
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()
# Create dictionary to store pin info
pins = {
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},
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}
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},
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}
}
# Setup each pin
......@@ -208,7 +208,7 @@ def handle_new_device():
for key in pins:
if pins[key]['name'] is None:
pins[key]['name'] = new_name
pins[key]['Wattage'] = new_wattage
pins[key]['wattage'] = new_wattage
break
template_data = {
......@@ -229,7 +229,7 @@ def delete_pin(delete_pin):
for key in pins:
if key == delete_pin:
pins[delete_pin]['name'] = None
pins[delete_pin]['Wattage'] = None
pins[delete_pin]['wattage'] = None
break
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