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
4cd2fdd9
Commit
4cd2fdd9
authored
Nov 14, 2019
by
Kristian Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
styling
parent
0c70fc93
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
15 deletions
+3
-15
app.py
app.py
+2
-11
main.css
static/css/main.css
+1
-4
No files found.
app.py
View file @
4cd2fdd9
...
...
@@ -4,6 +4,7 @@ from flask_sqlalchemy import SQLAlchemy
from
sqlalchemy
import
asc
,
desc
import
os
from
datetime
import
datetime
,
date
,
timedelta
# from daily_usage import DailyUsage
app
=
Flask
(
__name__
)
...
...
@@ -57,20 +58,12 @@ def create_entry(change_pin):
# Formula to calculate kWh based on time and wattage
kwh
=
pins
[
change_pin
][
'Wattage'
]
*
(
elapsed
/
3600
)
/
1000
print
(
pins
[
change_pin
][
'Wattage'
])
print
(
elapsed
)
print
(
kwh
)
print
(
"LATEST ENTRY: "
)
print
(
latest_entry
)
# 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
)
if
latest_entry_date
==
start_date
:
print
(
"LATEST ENTRY DATE: "
)
print
(
latest_entry_date
)
latest_entry
.
kwhUsed
+=
kwh
else
:
print
(
"NEW"
)
# If no entry for today, make one
entry
=
DailyUsage
(
date
=
start_date
,
kwhUsed
=
kwh
)
db
.
session
.
add
(
entry
)
...
...
@@ -87,7 +80,7 @@ def generate_graph_data():
# Create data for chart
# count = 0
records
=
DailyUsage
.
query
.
order_by
(
desc
(
DailyUsage
.
date
))
.
limit
(
7
)
.
all
()
print
(
records
)
(
records
)
for
record
in
records
:
labels
.
append
(
date
(
record
.
date
.
year
,
record
.
date
.
month
,
record
.
date
.
day
))
values
.
append
(
record
.
kwhUsed
)
...
...
@@ -115,13 +108,11 @@ pins = {
12
:
{
'name'
:
None
,
'state'
:
GPIO
.
LOW
,
'on_time'
:
None
,
'on_date'
:
None
,
'Wattage'
:
0
}
}
# Setup each pin
for
pin
in
pins
:
GPIO
.
setup
(
pin
,
GPIO
.
OUT
)
GPIO
.
output
(
pin
,
GPIO
.
LOW
)
labels
,
values
,
max
=
generate_graph_data
()
...
...
static/css/main.css
View file @
4cd2fdd9
...
...
@@ -16,13 +16,11 @@ body {
.containerRows
{
display
:
flex
;
flex-direction
:
row
;
/*background-color: darkkhaki;*/
/*height: 90%;*/
}
.device_list
{
width
:
25%
;
/*background-color: red;*/
margin-left
:
5%
;
text-align
:
left
;
border-bottom-style
:
solid
;
...
...
@@ -35,10 +33,9 @@ body {
.smart_meter
{
width
:
65%
;
margin-right
:
5
%
;
margin-right
:
2
%
;
margin-left
:
5%
;
margin-bottom
:
2%
;
/*background-color: coral;*/
border-style
:
solid
;
border-color
:
black
;
border-width
:
1px
;
...
...
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