MQTT to WebRequest bridge.
Go to file
2022-03-30 16:57:53 +02:00
database Added database directory 2021-08-07 14:30:31 +02:00
images Initial commit 2021-08-02 17:04:26 +02:00
own_modules Changed config to env variables 2021-08-07 14:27:24 +02:00
public/html Initial commit 2021-08-02 17:04:26 +02:00
test Initial commit 2021-08-02 17:04:26 +02:00
.drone.yml „.drone.yml“ ändern 2022-03-30 16:14:14 +02:00
.gitignore Initial commit 2021-08-02 17:04:26 +02:00
Dockerfile „Dockerfile“ ändern 2022-03-30 16:57:53 +02:00
Jenkinsfile Added Jenkinsfile 2021-08-08 21:02:22 +02:00
package-lock.json Maybe fixed now 2022-03-30 16:55:35 +02:00
package.json Maybe fixed now 2022-03-30 16:55:35 +02:00
README.md Initial commit 2021-08-02 17:04:26 +02:00
server.mjs Changed config to env variables 2021-08-07 14:27:24 +02:00

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

  • /login endpoint Offers basic login and sign-up funcionality Login and Sign-up page

  • /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.

home page

  • /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