Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PIoT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Volkor Barbarian Warrior
PIoT
Commits
d44a84de
Commit
d44a84de
authored
6 years ago
by
rmit-s3661720-daniel-linford
Browse files
Options
Downloads
Patches
Plain Diff
Added ability to read API token from token.json
parent
7fd33331
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+3
-0
3 additions, 0 deletions
.gitignore
greenhouse_bluetooth.py
+5
-3
5 additions, 3 deletions
greenhouse_bluetooth.py
monitorAndNotify.py
+6
-5
6 additions, 5 deletions
monitorAndNotify.py
with
14 additions
and
8 deletions
.gitignore
+
3
−
0
View file @
d44a84de
# Ignore Visual Studio settings
.vscode
# Ignore api token file
token.json
\ No newline at end of file
This diff is collapsed.
Click to expand it.
greenhouse_bluetooth.py
+
5
−
3
View file @
d44a84de
...
...
@@ -10,11 +10,9 @@ import socket
# Bluetooth notification class
class
BluetoothNotifier
:
# Initialization
def
__init__
(
self
,
accessToken
):
def
__init__
(
self
):
# Get sense hat access
self
.
__sense
=
sense_hat
.
SenseHat
()
# Access token for pushbullet notification
self
.
__accessToken
=
accessToken
# Load JSON config variables
with
open
(
"
config.json
"
,
"
r
"
)
as
jsonFile
:
config
=
json
.
load
(
jsonFile
)
...
...
@@ -22,6 +20,10 @@ class BluetoothNotifier:
self
.
__maxTemp
=
float
(
config
[
"
max_temperature
"
])
self
.
__minHumid
=
float
(
config
[
"
min_humidity
"
])
self
.
__maxHumid
=
float
(
config
[
"
max_humidity
"
])
# Load Pushbullet access token from JSON file
with
open
(
"
token.json
"
,
"
r
"
)
as
jsonFile
:
token
=
json
.
load
(
jsonFile
)
self
.
__accessToken
=
token
[
"
PB_api_token
"
]
# Checks if a paired device is nearby, returning true if so
# Note: Avoids the use of bt-device to get paired devices
...
...
This diff is collapsed.
Click to expand it.
monitorAndNotify.py
+
6
−
5
View file @
d44a84de
...
...
@@ -10,11 +10,9 @@ import socket
# Monitor and notification class
class
MonitorNotifier
:
def
__init__
(
self
,
databaseName
,
accessToken
):
def
__init__
(
self
,
databaseName
):
# Get sense hat access
self
.
__sense
=
sense_hat
.
SenseHat
()
# Access token for pushbullet notifications
self
.
__accessToken
=
accessToken
# Load JSON config variables
with
open
(
"
config.json
"
,
"
r
"
)
as
jsonFile
:
config
=
json
.
load
(
jsonFile
)
...
...
@@ -22,6 +20,10 @@ class MonitorNotifier:
self
.
__maxTemp
=
float
(
config
[
"
max_temperature
"
])
self
.
__minHumid
=
float
(
config
[
"
min_humidity
"
])
self
.
__maxHumid
=
float
(
config
[
"
max_humidity
"
])
# Load Pushbullet access token from JSON file
with
open
(
"
token.json
"
,
"
r
"
)
as
jsonFile
:
token
=
json
.
load
(
jsonFile
)
self
.
__accessToken
=
token
[
"
PB_api_token
"
]
# Connect to database for logging climate data
self
.
__connectToDatabase
(
databaseName
)
...
...
@@ -123,9 +125,8 @@ class MonitorNotifier:
if
__name__
==
"
__main__
"
:
# Database name and access token variables
databaseName
=
"
climate_data.db
"
accessToken
=
""
# Initialize monitor class
monitor
=
MonitorNotifier
(
databaseName
,
accessToken
)
monitor
=
MonitorNotifier
(
databaseName
)
# Check climate conditions every minute
while
True
:
monitor
.
recordClimate
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment