Hubitat MQTT Integration

OK. Figured out how to install your version via npm

sudo npm install -g jeubanks/hubitat-mqtt-bridge

When running it this way (via node vs docker), the problem is it's using the same config/log files as the st-mqtt file. I'm not too familiar with node. If I can't figure out another way, I may just fork yours and modify this section in server.js to have unique file names

image

I have both running via node (PM2 to keep persisted) w/o containers.

I cloned them into separate directories - left my ST config.yml untouched then changed the preface and port number in the habitat config.yml - each uses a different MQTT login (optional) but you will want to make sure you have separate client ids to avoid constant competition - one will drop.

I have been running since I received my hub over a month ago

I was finally able to get this to work alongside my ST mqtt install

1. Install bridge from jeubank's github


        sudo npm install -g jeubanks/hubitat-mqtt-bridge


2. Create new directory


    mkdir hubitat


3. Start bridge from new directory


    cd hubitat
    hubitat-mqtt-bridge


4 .Edit Config (prefix is already updated to hubitat in his version)


        sudo nano config.yml
        edit port (8081)



5. PM2 to run at startup


    sudo pm2 start hubitat-mqtt-bridge --cwd ~/hubitat
    pm2 save
    pm2 startup


6. Reboot

Man, I really want MQTT for local wifi device communications, but it seems like things are very difficult still. It's no wonder nothing other than DIY stuff uses MQTT.

I agree. I've got Hubitat talking to Home Assistant and can see status updates in HA but for the life of me, I can't get HA to talk to Hubitat. I can see the MQTT messages in the logs for the bridge but Hubitat doesn't respond. I'll give it another go this weekend.

1 Like

Interested to hear. I'd love to implement MQTT into my Particle Photons to make them locally controllable.

What are you using HA for the cmd?

It's been a bit while since I was messing with this, but there was a difference in the cmd structure that was needed to be changed between SmartThings and Hubitat.

If I have time this weekend I'll take a look as well.

Did you manage to get the 2-way working @nathangraham ?

It looks like the driver ( hubitat-mqtt-bridge-driver.groovy ) has a small error in the "parse" function (or perhaps something changed in HE since the original bridge code was published).

I believe that "msg.data" should be "msg.body" since the bridge posts the JSON data in the body of the message.

I updated msg.data to msg.body but that ended up throwing a heap of errors in the logs so I changed it back. I didn't make any progress so have parked this for now.

Does anyone actually have the app for Hubitat working? Because I can't seem to install it. It doesn't store the Bridge device when I select it. It makes another entry in the list of devices. So, it thinks it's still blank.

I don't have it installed right now but did. I know nothing about coding, but I had to go into the app code and change a field that said required to no/false. Seemed to fix the error. I think I saved once. Then went back into the app and selected the bridge device.

Had to remove the bridge capability from the list.

After I said that I was going to park MQTT and HA integration, I ended carrying on for another 5hrs (9pm-2am) and got some success.

Since the MQTT bridge is running in Docker, I reinstalled the container with host network (instead of being bridged) and configured the MQTT Bridge MAC Address to the physical NIC of the host. I then saw messages appearing (Devices > Hubitat MQTT Bridge > Events) where previously, they weren't.

So, the MAC address configuration of the bridge is very important.

Next couple of issues;

  1. HA is updating the state of my lock. It's always appearing as 'unlocked' even when it's locked. I'm running MQTT.fx and have subscribed to the 'state' topic which I can see is changing when the my lock (DanaLock v3) is locked and unlocked.
  2. When the lock is 'unlocked', it will randomly lock by itself. This only started last night after I configured the bridge with the correct MAC address.
  3. I need to get a Fibaro Switch FGS-213 working too.

@Ryan780, did you copy in the Apps and Driver code into Hubitat?

I had to remove the "Bridges" capability from the capabilities list in the code in order for it to safe the bridge when I select it down below. However, I have to figure out somewhere else to load the bridge because I'm already running an app that uses the same network ID (cast-web-api) so still don't have it running yet.

1 Like

New to MQTT but just trying to set this up to sync some devices in homeassistant.

Got MQTT up and running on the homeassistant side

Trying the MQTT-Hubitat bridge under docker. In the config.yaml file: what does the host refer to? Is this the host of the broker running under homeassistant? Also the port? Is that the port the broker under homeassistant is running?

Apologies for the 101 questions!

The host is where your MQTT broker is.
(I vaguely, and without details. remember someone suggesting that "127.0.0.1" should be used instead of 'local').

For the port, any number you choose. However:

  1. That number needs to be entered in "MQTT Bridge Port " of your Hubitat MQTT Bridge device.
  2. (I am not familiar with the docker thing but) if there is a firewall, make sure the respective port is open.

What’s your goal with this as there are now other easier ways to accomplish it ?

The path your taking existed because ST didn’t support direct communication with an MQTT broker but Hubitat does.

I am running homeassitant for some integration not supported by Hubitat and richer dashboards.

Via the MakerAPI I can control things in Hubitat from HA. However, I want to be able to push sensor data from HA to Hubitat as well...

Thanks @mag

Yes the HA integration app is only for HE devices into HA. I have written an MQTT app that works either way so you will be able to bring HA sensors into HE. It uses HA statestream protocol for auto discovery of such devices in HE. It can also bring any MQTT payload into a suitable HE device.

It’s been in beta for quite some time but is about to become a release version after perhaps one final ‘check‘ release and a long overdue documentation update. It’s stable.

PS If you use NodeRED you could achieve it that way too.

1 Like