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
b93bf231
Commit
b93bf231
authored
Nov 13, 2019
by
Kristian Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display todays cost
parent
d2aea06a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
8 deletions
+4
-8
app.py
app.py
+3
-5
main.html
templates/main.html
+1
-3
No files found.
app.py
View file @
b93bf231
...
...
@@ -77,13 +77,10 @@ def toggle_pin(change_pin):
# Toggle the selected pin
GPIO
.
output
(
change_pin
,
not
GPIO
.
input
(
change_pin
))
message
=
"Turned "
+
device_name
if
GPIO
.
input
(
change_pin
)
==
0
:
message
+=
" off."
if
pins
[
change_pin
][
'on_time'
]
is
not
None
:
create_entry
(
change_pin
)
else
:
message
+=
" on."
pins
[
change_pin
][
'on_time'
]
=
datetime
.
now
()
pins
[
change_pin
][
'on_date'
]
=
date
.
today
()
...
...
@@ -98,11 +95,12 @@ def toggle_pin(change_pin):
else
:
daily_total
=
0
todays_cost
=
0.1622
*
daily_total
template_data
=
{
'message'
:
message
,
'pins'
:
pins
,
'daily_total'
:
daily_total
'daily_total'
:
daily_total
,
'todays_cost'
:
todays_cost
}
return
render_template
(
'main.html'
,
**
template_data
)
...
...
templates/main.html
View file @
b93bf231
...
...
@@ -24,9 +24,6 @@
{% endfor %}
{# {% if message %}#}
{#
<h2>
{{ message }}
</h2>
#}
{# {% endif %}#}
</div>
<div
class=
"smart_meter"
>
...
...
@@ -40,6 +37,7 @@
</p>
{# Implement some way to display "No devices" message if none are in use#}
<p>
Total energy used today: {{ daily_total }} kWh.
</p>
<p>
Total cost of today's energy usage: £{{ todays_cost }}
</p>
</div>
</div>
</div>
...
...
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