Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel2
Web
Commits
fa5008bb
Commit
fa5008bb
authored
1 month ago
by
Gezer
Browse files
Options
Download
Email Patches
Plain Diff
fixed docker-compose
parent
5851d8d7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
backend/.env.docker
+2
-2
backend/.env.docker
backend/stream_processing/mQTTClientHandler.py
+9
-2
backend/stream_processing/mQTTClientHandler.py
backend/stream_processing/mac_to_room.json
+3
-1
backend/stream_processing/mac_to_room.json
backend/utils/influx.py
+6
-0
backend/utils/influx.py
docker-compose.yaml
+2
-2
docker-compose.yaml
with
22 additions
and
7 deletions
+22
-7
backend/.env.docker
+
2
-
2
View file @
fa5008bb
...
...
@@ -2,7 +2,7 @@
INFLUXDB_URL=http://influxdb2:8086
INFLUXDB_ORG=docs
INFLUXDB_BUCKET=co2-test
INFLUXDB_TOKEN=
35aKI6fq8SRli6cTmSGgvrqn8t4jYKp-ABgL7HGjwez9rh6YXqEt2F4ZGf_jJ_yATjcE8d4aMlqsmu_VaybTW
A==
INFLUXDB_TOKEN=
w-Isk1D35T90Srj_auFTxsbksn1zRB5MiNZf6h6RuNdb9-2s9ie5c1488JqoYILKrceVm0LaE5KCN2dXdDM-j
A==
# MQTT config
MQTT_BROKER_URL=mosquitto
MQTT_BROKER_URL=mosquitto
-broker
MQTT_TOPIC="co2/#"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/stream_processing/mQTTClientHandler.py
+
9
-
2
View file @
fa5008bb
...
...
@@ -5,10 +5,16 @@ from datetime import datetime
import
paho.mqtt.client
as
mqtt
from
stream_processing
import
jsonhandler
from
utils.influx
import
InfluxDBHelper
import
os
class
MQTTClientHandler
:
MAPPING_FILE_NAME
=
"backend/stream_processing/mac_to_room.json"
MAPPING_FILE_NAME
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"mac_to_room.json"
)
MEASUREMENT_NAME
=
"sensor_data"
TAG_ROOM
=
"room"
TAG_MAC
=
"mac"
...
...
@@ -83,6 +89,7 @@ class MQTTClientHandler:
f
"Wrote to InfluxDB:
{
msg
}
"
)
print
(
f
"Token:
{
self
.
influx_writer
.
get_token
()
}
"
)
print
(
f
"Url:
{
self
.
influx_writer
.
get_url
()
}
"
)
print
(
f
"Wrote to InfluxDB:
{
msg
}
"
)
print
(
f
"Ping:
{
self
.
influx_writer
.
ping
()
}
"
)
except
Exception
as
e
:
...
...
This diff is collapsed.
Click to expand it.
backend/stream_processing/mac_to_room.json
+
3
-
1
View file @
fa5008bb
...
...
@@ -15,5 +15,7 @@
"TE:ST:TE:ST:TE:ST"
:
""
,
"AB:CD:EF:12:34:56"
:
""
,
"a1:b2:c3:d4:e5:f6"
:
""
,
"77:88:99:aa:bb:cc"
:
""
"77:88:99:aa:bb:cc"
:
""
,
"test"
:
""
,
"aaron"
:
""
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/utils/influx.py
+
6
-
0
View file @
fa5008bb
...
...
@@ -5,6 +5,7 @@ from influxdb_client.client.write_api import WriteOptions
class
InfluxDBHelper
:
def
__init__
(
self
,
url
:
str
,
token
:
str
,
org
:
str
,
bucket
:
str
):
self
.
url
=
url
self
.
token
=
token
self
.
client
=
InfluxDBClient
(
url
=
url
,
token
=
token
,
org
=
org
)
self
.
bucket
=
bucket
...
...
@@ -27,9 +28,14 @@ class InfluxDBHelper:
if
timestamp
:
point
.
time
(
timestamp
,
WritePrecision
.
NS
)
self
.
write_api
.
write
(
bucket
=
self
.
bucket
,
org
=
self
.
org
,
record
=
point
)
def
get_token
(
self
):
return
self
.
token
def
get_url
(
self
):
return
self
.
url
def
ping
(
self
):
return
self
.
client
.
ping
()
...
...
This diff is collapsed.
Click to expand it.
docker-compose.yaml
+
2
-
2
View file @
fa5008bb
...
...
@@ -10,7 +10,7 @@ services:
volumes
:
-
./backend/stream_processing:/app/backend/stream_processing
env_file
:
-
./backend/.env
-
./backend/.env
.docker
restart
:
unless-stopped
depends_on
:
-
influxdb2
...
...
@@ -23,7 +23,7 @@ services:
image
:
django-backend
container_name
:
django-backend
env_file
:
-
./backend/.env
-
./backend/.env
.docker
ports
:
-
"
8000:8000"
volumes
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment