Connector to read data from MQTT and dump it into Deep Intelligence. Also retrieves the MQTT's topic relation with Deep Intelligence Source information from the project's API.
First install prerequisites
sudo apt update
sudo apt install python3 python3-pip -y
Then install tool, for that purpose go to the repository root and run the following command
sudo python3 -m pip install . --upgrade
Once installed, the application can be accesed via terminal with the command co2-mqtt-deepint-connector
. A execution example is attached bellow:
co2-mqtt-deepint-connector 212.128.140.31 2780 JKM1wuXItbZ0JRF8ZdaNE6PW9iGmND2_Kyq2KVnG1MIPch_czSLXC1N24GLWjAZszI4eQrQuxRvdUxsNtF0KLw example-id 1 False
It also attaches a help mode as follows:
co2-mqtt-deepint-connector [OPTIONS] [MQTT_BROKER] [MQTT_PORT]
[MQTT_USER] [MQTT_PASSWORD] [CONFIG_URL]
[DEEPINT_AUTH_TOKEN] [MQTT_CLIENT_ID]
[FLUSH_INTERVAL_SECONDS] [QUIET_MODE_SET]
While running dumps messages received from MQTT into deepint.
Arguments:
[MQTT_BROKER] MQTT's broker IP
[MQTT_PORT] MQTT's broker port
[MQTT_USER] MQTT's broker user
[MQTT_PASSWORD] MQTT's broker password
[CONFIG_URL] URL of the mapping (between MQTT and Deep
Intelligence) configuration server's endpoint.
[DEEPINT_AUTH_TOKEN] Authentication token for AIR Institute
[MQTT_CLIENT_ID] MQTT's client id. If not provided, an UUIDv4 will
be generated
[FLUSH_INTERVAL_SECONDS] number of seconds to wait between message queue
flushes [default: 600]
[QUIET_MODE_SET] if set to true no logging information is
provided. [default: False]
Options:
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.
--help Show this message and exit.
For deploying the application in the deploy
folder, two deployment medium are attached:
- A Linux Systemd unit
- A PM2 deployment script
- install package as follows in
Usage
function - go to deploy folder
- configure systemd unit replacing the variables between
<
and>
- copy the unit file to folder
/etc/systemd/system
as follows:cp deploy/co2-mqtt-deepint-connector.service /etc/systemd/system/co2-mqtt-deepint-connector.service
- enable unit with
sudo systemctl enable co2-mqtt-deepint-connector.service
- start service with
sudo systemctl start co2-mqtt-deepint-connector.service
[Unit]
Description=MQTT Deep Intelligence connector
After=multiuser.target
StartLimitIntervalSec=0
[Service]
Type=simple
ExecStart=co2-mqtt-deepint-connector <MQTT_BROKER> <MQTT_PORT> <MQTT_USER> <MQTT_PASSWORD> <CONFIG_URL> <DEEPINT_AUTH_TOKEN> <MQTT_CLIENT_ID> <MQTT_NUM_MESAGE_QUEUE_FLUSH> <QUIET_MODE_SET>
[Install]
WantedBy=multi-user.target
- install Node.js and npm with
sudo apt install nodejs npm -y
- install PM2 with
sudo npm install -g pm2
- configure systemd unit replacing the variables between
<
and>
in thelaunch.sh
file. - register the service with
sudo pm2 start co2-mqtt-deepint-connector.pm2.json
- enable the service with
sudo pm2 startup
{
"apps" : [
{
"name": "co2-mqtt-deepint-connector",
"interpreter": "/bin/bash",
"script": "launch.sh",
"out_file": "/var/log/co2-mqtt-deepint-connector.log",
"error_file": "/var/log/co2-mqtt-deepint-connector.log"
}
]
}