Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoTSmartMeter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kristian.tan
IoTSmartMeter
Commits
160b2517
Commit
160b2517
authored
Nov 16, 2019
by
raspi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:KristianTan/IoTSmartMeter
parents
b4954136
5f3eb731
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
app.py
app.py
+7
-7
No files found.
app.py
View file @
160b2517
...
...
@@ -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
][
'
W
attage'
]
*
(
elapsed
/
3600
)
/
1000
kwh
=
pins
[
change_pin
][
'
w
attage'
]
*
(
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
,
'
W
attage'
:
15
},
8
:
{
'name'
:
None
,
'state'
:
GPIO
.
LOW
,
'on_time'
:
None
,
'on_date'
:
None
,
'
W
attage'
:
0
},
7
:
{
'name'
:
None
,
'state'
:
GPIO
.
LOW
,
'on_time'
:
None
,
'on_date'
:
None
,
'
W
attage'
:
0
},
12
:
{
'name'
:
None
,
'state'
:
GPIO
.
LOW
,
'on_time'
:
None
,
'on_date'
:
None
,
'
W
attage'
:
0
}
25
:
{
'name'
:
'Light'
,
'state'
:
GPIO
.
LOW
,
'on_time'
:
None
,
'on_date'
:
None
,
'
w
attage'
:
15
},
8
:
{
'name'
:
None
,
'state'
:
GPIO
.
LOW
,
'on_time'
:
None
,
'on_date'
:
None
,
'
w
attage'
:
0
},
7
:
{
'name'
:
None
,
'state'
:
GPIO
.
LOW
,
'on_time'
:
None
,
'on_date'
:
None
,
'
w
attage'
:
0
},
12
:
{
'name'
:
None
,
'state'
:
GPIO
.
LOW
,
'on_time'
:
None
,
'on_date'
:
None
,
'
w
attage'
:
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
][
'
W
attage'
]
=
new_wattage
pins
[
key
][
'
w
attage'
]
=
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
][
'
W
attage'
]
=
None
pins
[
delete_pin
][
'
w
attage'
]
=
None
break
template_data
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment