A few months ago, I bought and installed a Zwave stick. However, I want to start adding some smart bulbs to my house, and Zigbee is typically the way to go for that. And from what I read, people were having problems with Zigbee USB sticks and Home Assistant. So I decided to buy a Hubitat(Amazon).

So far it’s been OK. I was able to add in one of my CT-101 Thermostats without problem. And as a bonus, humidity actually works, unlike in Home Assistant. And I also purchased some Sengled Bulbs in White and  RGBW. I haven’t tried out the White bulbs yet, but I’m sure they will work after my experience with the RGBW. I just went into the Hubitat, and clicked add device, turned on the light switch, and it showed up a few seconds later on the Hubitat.

Adding it was the easy part. However, I was a little disappointed in the interface for actually controlling the bulb. Even after installing the Dashboard addon, all I could do was turn it on and off and change the brightness ( The slider was very clunky via my iPhone). I couldn’t change the color or the temperature in the Dashboard addon. I was still able to do all those things in the basic web interface, but as you can see in the screenshot below, it’s not very user friendly or nice to look at. On top of that, there isn’t even a color picker. You have to manually change the Hue and Saturation to get your color(No Hex values either). I really hope they put more effort into the Dashboard and the interface. I was secretly hoping I would be able to abandon Home Assistant for this, but this along with a handful of other things (no Telegram support, no native MQTT ) put a quick stop to those thoughts.

The basic interface to control an RGBW bulb.

 

Now that the mini-review is out of the way, I’m going to start working on integrating it with HA. All the instructions are already on the github for the Hubitat MQTT Bridge, but I just wanted to type it up as I go in case there are any issues I run into that might help someone else.

  1. Install the MQTT Broker using the hass.io addon, and configured with a basic username and password. This was done previously. I’m not going to go into any detail as there are tons of resources on how to do this.
  2. Configure HA to point to the broker:
    mqtt:
      broker: core-mosquitto
      username: mqtt_user
      password: mqtt_pass
      discovery: true
  3. Installed the bridge on the HA box(running Ubuntu) using docker: sudo docker pull jeubanks/hubitat-mqtt-bridge 
  4. Started the bridge. I changed the default port since I was already using 8080: sudo docker run -d –name=”mqtt-bridge” -v /opt/mqtt-bridge:/config -p 6788:6788 jeubanks/hubitat-mqtt-bridge 
  5. Edit the config file sudo gedit /opt/mqtt-bridge/config.yml . I changed the host, username, password, and port. Make sure you uncomment the lines. I made that mistake and the bridge wouldn’t start, and nothing indicated that it didn’t start. Feel free to change the other things if you want to.
  6. Restart the bridge: docker restart mqtt-bridge 
  7. In Hubitat go to Drivers Code -> New Driver and copy/paste the Drivers Code and save it.
  8. Go to Devices -> Add Virtual Device and put in “MQTT Device” for the name and for the Type dropdown, select MQTT Bridge(It should be all the way at the bottom) and then Save.
  9. On the next screen, put in the IP, MAC, and the port you specified and click the save button directly under the IP address field.
  10. Go to Apps Code -> New App and copy/paste the App Code and save it.
  11. Go to Apps -> Load New App -> MQTT Bridge(at the bottom).
  12. Go through the list and put a check box next to the devices you want to send to the bridge.
  13. Near the bottom, click “Notify this bridge” and select the bridge we created and then Save.

Now I put the following into my HA install(‘RGBW LightBulb’ is the name of the light bulb):

        
- platform: mqtt
  name: "Night Stand"
  state_topic: "hubitat/RGBW LightBulb/switch/state"
  command_topic: "hubitat/RGBW LightBulb/switch/cmd"
  brightness_command_topic: "hubitat/RGBW LightBulb/level"
  brightness_state_topic: "hubitat/RGBW LightBulb/level"
  brightness_scale: 100
  qos: 0
  payload_on: "on"
  payload_off: "off"
  optimistic: false

The bad news here is that it looks like either Hubitat or the Sengled bulb ( not sure which one) can only use Hue/Saturation/Levels values to set their color. Home Assistant only supports RGB and (I think) XY values. The good news is that there is a Pull Request for this. Hopefully it gets merged soon. The MQTT JSON light component supports HSL, but I’m guessing that means the bridge would need work to get things working.

Another issue I ran into is one that I don’t think many others will see. I’m putting it here in case someone else does the same thing by accident. Anyways, I was able to turn the light off using HA, but not on. In the bridge logs, it kept saying the ‘on’ message was a duplicate and it was ignoring it. It turns out that when I was testing things, I had HA publishing to the ‘set_state’ topic instead of the ‘cmd’ topic. So I went into the /opt/mqt_bridge/state.json file and deleted the line for ‘set_state’ and everything is fairly close to working now.

Update1: I still have an issue where if I turn off the light, in order to turn it back on, I sometimes have to move the brightness slider. Turning it off and on via Hubitat sometimes resolves the issue. I can’t seem to reproduce the issue or the fix consistently.

Update2: It looks like the switch/state topic is not getting updated by Hubitat for some reason. And I think it might be going back to the ‘set_state’ topic. Even though I deleted it, it just keeps coming back in. The only consistent workaround seems to be manually publishing a random word to that ‘set_state’ topic. But even then, the issue appears to just randomly come back.

 

2 Replies to “First Experience with Hubitat and Bridging it with Home Assistant via MQTT

  1. I think that if you looked again at Hubitat, it would do all that you have specified here.

    Tremendous progress in just 1 short year!

    1. Yeah. I keep track of the updates. I’ve been trying to carve out some time to try it out again. Home Assistant has just been working so well for me, I couldn’t imagine Hubitat being that good. And HA has also made huge leaps in getting away from the config files.

Leave a Reply