Need help with MQTT bridge with Home Assistant

I’m new to Hubitat and I mainly got it for its Zwave and zigbee capabilities. I want to continue using HA as my front end and hub for all non zwave/zigbee devices.

I was looking at the MQTT bridge and I feel dumb for not understanding what I need to do. Is there a step by step guide for this? If not can someone help me out with what I need to do? I’m running HA on Ubuntu using HASS.io. I’ve got an MQTT broker hass.io add on running and confirmed it’s working(that’s how I control my garage, fireplace, and sump pump monitor).

I can even give back by putting together detailed instructions if someone can help me out with this so it can help people in the future.

have you see this already? the first link there seems to have the installation instructions on github.

Are you also running Node-RED either within HASS.io or separately ? You would find it very useful as a topic mapper / translator between Hubitat and HA.

No. Don't know a whole lot about Node Red. I've simply just heard of it. I will look into to it to see what it does. Thanks.

Basically HA posts its updates to MQTT using a fixed topic structure that you set up when you configure it. Hubitat does similar. What Node-RED can do is watch one topic for any update and repost that update (optionally with some changes to the actual information) to another topic on the same broker. This aids in mapping a Hubitat topic to a HA one and vv. A couple of Node-RED add-ons are available for HASS.io (including one from frenck) , or you can install it separately.

Node-RED is hugely powerful and useful and there is a HomeAssistant plug in available for it. This allows you to even use it as an alternative logic engine for HA .. whilst also keeping YAML if you like.

P.S. Lots of posts in the HA community on Node-RED...

EDIT: I think I got it. I has to make sure I uncomment the password and username lines.

Thanks. I followed all the steps there. And I think I did it all right, but I'm not seeing any messages being posted to my MQTT Broker. And in 'Devices' the MQTT Device just shows unknown. Any ideas as to what I might have done wrong?

OK. I've got almost everything working, but for some reason, I can turn the light off, but I can't turn it on via Home Assistant. Any ideas why that might be the case? It's definitely updating the cmd topic to 'on'. I can see it on the broker that is happening.

EDIT:I figured it out. Instead of the using the cmd topic, at first I was using the set_state topic. And that set the state to 'on'. I fixed it, but it remembered that set state was set it on, and there wasn't anything changing that set state. So I just deleted that line out of the state.json file for the MQTT Bridge and everything is working.

Great... sounds like you’re on a roll. MQTT coupled with NodeRed are really powerful as your system becomes multi controller.

1 Like

Where did you find the username and password? And did you mean comment them out?

I've got this working pretty well now as well. All of my zigbee and z-wave devices are paired with the hubitat, but my automations are in appDaemon on HA. It really works! My experience so far is that it's both stable and fast, and I'm just running hass.io on a VirtualBox.

I wish I had an identical app running locally in groovy to do an apples to apples comparison to my appDaemon python apps for speed, but it seems pretty damn quick to me. Makes me wonder how much of the slowness/weirdness I was seeing on SmartThings with WebCoRE was coming from WebCoRE.

At some point I intend to look into re-writing the MQTT app for Hubitat. First off, it shouldn't need the broker component as ported from SmartThings since your hubitat and mosquitto server are probably behind the same firewall.

Second feature I'd like to add is creation of the topic names in such a way that HA will auto-populate discovered devices. Looking at the HA docs, this doesn't seem to be too much of a stretch.

Final feature would be ssl support on the HE side. Not sure exactly what would be involved in that.

Maybe over the xmas break...

Oh... as for the mqtt broker component, I packaged it up as a hass.io add-on if anybody's interested:

Configs to get it working with mosquitto look like this:

-------------------
Mosquitto config
cut below
-------------------
{

  "logins": [

    {

      "username": "myuser",

      "password": "mypass"

    }

  ],

  "anonymous": true,

  "customize": {

    "active": false,

    "folder": "mosquitto"

  },

  "certfile": "fullchain.pem",

  "keyfile": "privkey.pem"

}

--------------------------
hubitat bridge config
cut below
--------------------------

{

  "broker_host": "localhost",

  "broker_port": 1883,

  "preface": "hubitat",

  "state_suffix": "state",

  "command_suffix": "cmd",

  "login": "myuser",

  "password": "mypass",

  "bridge_port": 2081

}
2 Likes

I would love to see a Hubitat rewrite eliminating the bridge component. It was necessary on ST but not needed on HE and causes issues.

BTW is your Hass.io addon an MQTT broker or the bridge part .. or both ?

it's just the bridge part, and I just packaged up the jeubanks version as an add-on. I made no mods to it at all. For the broker, I'm using the standard hass.io Mosquitto add-on.

So hubitat app -> hubitat device -> hubitat broker container on hass.io -> mosquitto container on hass.io -> HASS

The other things you need to do to get this stable are on the hubitat app side:

Modify line 47. Required should be false or you can never select the output device.

input "bridge", "capability.notification", title: "Notify this Bridge", required: false, multiple: false

Comment line 971:

//runEvery15Minutes(initialize)

I have set up this bridge now and got it running.
I have made en Viritual Temperaturesensor and trying to update it via MQTT.

This is what I find in the logs, but the sensor is not updating:
Received device event from bridge: [name:Billader temp, type:temperature, value:16, command:true]

Any idea on how to fix it?
On ST I ran the same bridge, en there I think I edited the VirTempsensor DH to be able to update it, but when I went from ST to Hubitat I deleted my account at ST...

@bill - I am slowly migrating off WINK 2 hub and moving to hubitat... I have been using Node-Red and HA for a year now... and would like to get this working.
Has there been any further developments on this integration piece?
I have MQTT broker installed on the HA part and its running on a ESXi Intel based server.

How would I install your bridge add-on?

1 Like

@jlvandusen as I said above, I didn't write the bridge, I just packed it up in container for hass.io. Is that what you're running on ESXi?

The layers get pretty damn complex. Containers inside a VM on an OS on Hardware.

Basically you need 3 pieces to make this work, one of which it sounds like you have:

  1. You need the Hubitat MQTT Bridge app on your hubitat
  2. You need the Hubitat MQTT bridge for HA
  3. You need a mosquitto broker

the hubitat MQTT app sends device state to the MQTT bridge container on hass.io, which writes it to the mosquitto db, where its read by HA.

I'm not sure how well auto device discovery works on the HA end since I'm only using explicitly defined devices, but in theory it shouldn't be too much of a stretch to get HA to automagically populate with all your hubitat devices.

1 Like

This any use ?

Links bidirectionally with HA using MQTT statestream and will support the HA MQTT discovery protocol very soon

2 Likes

Wow, yes that certainly looks like it could be of use...

1 Like

Man this is confusing as hell...

The only thing I use HA for is my irrigation and I would like to add them to HE but I am stumped at this and I write drivers for HE !

What are you referring to ?
Home Assistant ?
My alpha MQTT app ?
Your MQTT driver / app ?

Linking Hassio to HE