Skip to content
HTTP to MQTT bridge
Branch: master
Clone or download
Pull request Compare This branch is 10 commits ahead, 21 commits behind petkov:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.env-sample
.gitignore
LICENSE
Procfile
README.md
app.json
index.js
package.json

README.md

HTTP to MQTT bridge

I needed a solution that connected IFTTT to Home Assistant and came across http_to_mqtt

I wanted to host it locally along with my MQTT server so I made some modifications. If you want host this at Heroku: Cloud Application Platform then I suggest grabbing http_to_mqtt, otherwise feel free to use mine. I have only made some modifications to .env variables and how status is output to the console if testing via curl.

@petkov wrote the HTTP to MQTT bridge using Node JS with Express for HTTP server and MQTT.js client and could be hosted on Heroku: Cloud Application Platform.

I preferred to host it locally.

The Ingredients

  1. Configure Home Assistant MQTT trigger.
  2. Clone this repo to your host
  3. Update the env variables in .env-sample and rename to .env
    • AUTH_KEY - can be any string eg.: makeitreallyrandom.
    • MQTT_HOST - the host of your MQTT broker (eg.: mqtt://:).
    • MQTT_USER
    • MQTT_PASS
  4. Create IFTTT applet the same way as described in BRUH Automation video.
  5. Configure Maker Webhooks service with below parameters.
    • URL: https://:/post/
    • Method: POST
    • Content Type: application/json
    • Body: {"topic":"<mqtt_topic>","message":"<mqtt_message>","key":"<AUTH_KEY>"}
  6. Make sure to enable any required port forwarding.

Test HTTP to MQTT Bridge

Before attempting to connect IFTTT to your new Bridge I suggest testing to make sure your bridge is . You can use curl for this.

For example:

curl -X POST -H "Content-Type: application/json" -d '{"topic":"testing/dev/message","message":"Working!","key":"makeitreallyrandom"}' http://<host>:5000/post/

Then just subscribe to the topic you just sent your test message to:

mosquitto_sub -d -h <mqtt_server> -p <port> -t 'testing/#' -u <mqtt_user> -P <mqtt_pass>

Once you validated your bridge is working then you should be good to go on setting up your Maker Webhooks

Todo

  • Log to a file so data can be splunked.

Thanks

I would not have been able to do this without inspiration and the work of others.

First, @petkov who did the initial work to create this HTTP to MQTT bridge. I am using his blood, sweat, and tears for my own benefit and do so with the greatest of thanks.

Now, I wouldn't even been working on this project if it wasn't for Home Assistant. Seriously, if you are not using this project in your Home Automation you are doing it wrong. And of course, to Ben from BRUH Automation who I first came across when looking for Home Assistant configs to copy use for inspiration. Ben also does some awesome video tutorials on both Home Assistant and making your own IoT devices cheap. Check out Ben's youtube.

You can’t perform that action at this time.