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
87f9bcd5
Commit
87f9bcd5
authored
Nov 13, 2019
by
Kristian Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Haandle no on time
parent
3e377690
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
app.py
app.py
+11
-10
No files found.
app.py
View file @
87f9bcd5
...
...
@@ -74,16 +74,17 @@ def toggle_pin(change_pin):
message
=
"Turned "
+
device_name
if
GPIO
.
input
(
change_pin
)
==
0
:
message
+=
" off."
uptime
=
datetime
.
now
()
-
pins
[
change_pin
][
'on_time'
]
uptime
=
datetime
.
strptime
(
uptime
,
'
%
b
%
d
%
Y
%
I:
%
M
%
p'
)
date
=
datetime
.
strptime
(
pins
[
change_pin
][
'on_time'
],
'
%
b
%
d
%
Y
%
I:
%
M
%
p'
)
d
=
DailyUsage
(
date
=
date
,
hours
=
uptime
)
db
.
session
.
add
(
d
)
db
.
session
.
commit
()
pins
[
change_pin
][
'on_time'
]
=
None
print
(
"=========="
)
print
(
DailyUsage
.
query
.
all
())
print
(
"=========="
)
if
pins
[
change_pin
][
'on_time'
]
is
not
None
:
uptime
=
datetime
.
now
()
-
pins
[
change_pin
][
'on_time'
]
uptime
=
datetime
.
strptime
(
uptime
,
'
%
b
%
d
%
Y
%
I:
%
M
%
p'
)
date
=
datetime
.
strptime
(
pins
[
change_pin
][
'on_time'
],
'
%
b
%
d
%
Y
%
I:
%
M
%
p'
)
d
=
DailyUsage
(
date
=
date
,
hours
=
uptime
)
db
.
session
.
add
(
d
)
db
.
session
.
commit
()
pins
[
change_pin
][
'on_time'
]
=
None
print
(
"=========="
)
print
(
DailyUsage
.
query
.
all
())
print
(
"=========="
)
else
:
message
+=
" on."
pins
[
change_pin
][
'on_time'
]
=
datetime
.
now
()
...
...
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