database | ||
images | ||
own_modules | ||
public/html | ||
test | ||
.gitignore | ||
Dockerfile | ||
Jenkinsfile | ||
package-lock.json | ||
package.json | ||
README.md | ||
server.mjs |
MQTT <-> Webrequest-Bridge
This bridge delivers the functionality to post MQTT message on incoming web requests and call web requests on MQTT events. This all is bundles into a docker container.
Building the container yourself
One can eighter use the public docker container greinet/webmqttbridge or build the container yourself.
docker build . -t ownname/webmqttbridge.
Configuration
The configuration file is created by the docker container. The following command creates the config.js file in the current directory and deletes the docker container afterwards.
docker run --rm -v .:/usr/src/app/config agreiner/advancedmqttbridge npm run create_config
Running the container
The contaier can be run via normal docker run or via docker compose. It is recommended to use a https-proxy as passwords and other confidential information is transfered in clear-text otherwise.
-
docker run
docker run -v /home/ubuntu/config:/usr/src/app/config \ -v /home/ubuntu/database:/usr/src/app/database \ greinet/advancedmqttbridge npm run create_config
-
docker compose with traefik example
advancedmqttbridge: image: greinet/advancedmqttbridge labels: - "traefik.enable=true" - "traefik.http.routers.advancedmqttbridge.rule=Host(`advancedmqttbridge.url.com`)" - "traefik.http.routers.advancedmqttbridge.entrypoints=websecure" - "traefik.http.routers.advancedmqttbridge.tls=true" - "traefik.http.services.advancedmqttbridge.loadBalancer.server.port=3000" - "traefik.docker.network=traefik" restart: always volumes: - "/home/ubuntu/database:/usr/src/app/database" - "/home/ubuntu/config:/usr/src/app/config" networks: - traefik
Using the Bridge
-
/home endpoint Offers the functionality to add listeners to mqtt topics and message values with a request url to be called if the message is posted to the topic.
-
/mqttbridge endpoint Reacts to GET-Request and takes as parameters the auth-token defined in the config.js, a mqtt topic and a message and then sends the message to the topic. Example:
mqttbridge:3000/mqttbridge?auth=1234&topic=cmnd/kitchen/light&message=ON