fastapi + mqtt + nodered
1.2K
docker-compose.yml :
myapp:
image: duycop/app_api
container_name: myapp
env_file:
- env/.env.myapp
expose:
- 8080
ports:
- "8080:8080"
restart: unless-stopped
networks:
iotnet:
ipv4_address: 192.168.99.123
.env.app_fastapi :
TZ=Asia/Ho_Chi_Minh
MQTT_HOST=192.168.99.15
MQTT_PORT=1883
MQTT_USER=my_mqtt_user
MQTT_PASS=my_mqtt_pw
MQTT_CLIENT_ID=myapp_mqtt_client
SENSOR_API_BASE=http://nodered:1880/myapp-
MQTT_TOPIC_CHANGE_SUB=myapp/change
MQTT_TOPIC_ONLINE_PUB=myapp/online
Node-Red:
[
{
"id": "3c6f4350d8b2f439",
"type": "http response",
"z": "e433859738924377",
"g": "5ea79e93a7f71f31",
"name": "",
"statusCode": "200",
"headers": {
"content-type": "application/json"
},
"x": 860,
"y": 1200,
"wires": []
},
{
"id": "bb1ef1b5dd598e7b",
"type": "function",
"z": "e433859738924377",
"g": "5ea79e93a7f71f31",
"name": "ok",
"func": "msg.payload={\n ok:1,\n data:msg.payload\n}\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 1200,
"wires": [
[
"3c6f4350d8b2f439"
]
]
},
{
"id": "5c48077248a166d2",
"type": "mysql",
"z": "e433859738924377",
"g": "5ea79e93a7f71f31",
"mydb": "b8d3f24a8b0f3ac9",
"name": "myapp_db",
"x": 560,
"y": 1200,
"wires": [
[
"bb1ef1b5dd598e7b"
]
]
},
{
"id": "073fd15c4baea29c",
"type": "function",
"z": "e433859738924377",
"g": "5ea79e93a7f71f31",
"name": "sql get water",
"func": "msg.topic = \"SELECT id,name,value,TIMESTAMPDIFF(SECOND, `time`, NOW()) as `ss`,active,stt from `sensor` order by stt;\";\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 390,
"y": 1200,
"wires": [
[
"5c48077248a166d2"
]
]
},
{
"id": "7dcaad6ee4466374",
"type": "http in",
"z": "e433859738924377",
"g": "5ea79e93a7f71f31",
"name": "get_sensor",
"url": "/myapp-get_sensor",
"method": "get",
"upload": false,
"skipBodyParsing": false,
"swaggerDoc": "",
"x": 190,
"y": 1200,
"wires": [
[
"073fd15c4baea29c"
]
]
},
{
"id": "b8d3f24a8b0f3ac9",
"type": "MySQLdatabase",
"name": "MySQL",
"host": "mariadb",
"port": "3306",
"db": "myapp_db",
"tz": "+07:00",
"charset": "UTF8"
},
{
"id": "aaaa5e4076397c1d",
"type": "global-config",
"env": [],
"modules": {
"node-red-node-mysql": "2.0.0"
}
}
]
Content type
Image
Digest
sha256:e06d7e9a2…
Size
61.9 MB
Last updated
10 months ago
docker pull duycop/app_api