HomeKit device sync w/ Hubitat Elevation (No Apple devices or Node-Red required)

[UPDATE] There's a far better way to do this now that isn't limited to binary devices and lets you do all the automation in Hubitat where it's easy and powerful.

I've been chasing this one for a while. I'm not a fan of working too hard at making home automation work for me. This is one of the primary reasons why I'm here and no longer a SmartThings user, among several other disadvantages of that platform.

I'm addicted to home automation, so it should come of no surprise that I'm willing to try different systems, but I personally still haven't found anything I like as much, or offers as much capability in a single platform, with as little effort as Hubitat Elevation requires. My stuff just works. I don't have to spend time maintaining it or chasing hardware issues beyond the occasional device trouble that is just not completely avoidable. Everyone encounters it on every platform. But despite my early sketchy results with keeping many Xiaomi devices joined with HE due to their non-standard Zigbee, I have become very fond of them when attached to a Xiaomi Aqara hub. Like my beloved HE hub, the Xiaomi device, when paired to an Aqara Hub just work. No drops, no failures, incredible battery life, nice styling, small and very inexpensive.

But the downside of them is there's no direct way to sync the most commonly available hubs which include the current Aqara HomeKit hub and the Mijia Multimode Gateway. By using a HomeKit hub such as an Apple TV, HomePod, HomePod Mini, an always on iPad, there were simple ways to get the state of these devices synced with Hubitat, but only by investment in Apple hardware. And if you're not an Apple MacOS or iOS user, you simply couldn't do it very easily at all. Yes I've been told by Node-Red users that you could achieve it with Home Assistant and Node-Red. Now I know that Node-Red users swear by it for their automations, but setting up, learning and maintaining both Home Assistant and Node-Red seemed a fairly steep hill to climb for just a few Xiaomi devices.

So I've been playing with leveraging a specific capability of Home Assistant which, to my knowledge is completely unique to that platform. Don't mistake this for an "I'm now a fan of Home Assistant" post. For a free software, it's not unbearable, but for ease of use it's a far cry from Hubitat Elevation. And from what I've read, Open Z-Wave and many devices that don't fully function leaves one heck of a gap as a user friendly choice. So no, this is very much a post about getting really inexpensive, small and reliable Xiaomi devices into Hubitat for the purpose of automation with Rule Machine.

I would love for these device integrations to be created for HE. It would solve a lot of issues when it comes to the gaps in device compatibility. The Hubitat team has done a tremendous job in getting a ton of devices all working properly with the Hubitat Elevation hub, but there's a mountain of devices out there, and not all of them are well made or possible to integrate. One thing that remains very apparent is there's almost always a way to integrate devices with at least one system, but one stop shopping is a massive challenge. Hobbyists that want something and have the time can usually achieve it eventually. No business pressures or customers to please. If it works it works, if not, there's typically no company that's going to suffer as a result.

Compatibility

After setting up a simple to use Hubitat Elevation and Hoobs smart apartment for my daughter, I became a little more interested in what Hoobs is doing. Not because it's more powerful than pure Homebridge, but mainly because it was so very simple to setup and use. I downloaded the free image and wrote it to an SD card. About 10 minutes later I was adding HE devices to HomeKit. So I started toying with the concept of using Hoobs to facilitate the syncing of devices. To be clear, it cannot do that on its own, but there are some compatibility surprises with Home Assistant that make the two together a very easy link that can be run on a single computer, and probably would work fine on a Raspberry Pi 4 or in Docker.

Bridging the gap

HOOBS

Hoobs, for the unfamiliar is a fancy UI on top of Homebridge. But it's actually a little bit more than just that. It's also a simple dashboard for anything exposed to Hoobs. So with a very simple setup that takes only a few minutes, you can expose just about any device joined with Hubitat Elevation to Hoobs, and if you're an iOS or Mac user, you can also see them in the Apple Home app.

Home Assistant

Explaining what Home Assistant to this crowd seems almost silly, but there might be someone that's never heard of it. :man_shrugging: This open source home automation platform has been around for many years. It has been, and for the most part remains purely something that only home automation geeks like me would dare to touch (even though I've mostly avoided it until now). It's UI is not too bad looking, but it has a lot of terminology that I don't see used in other platforms, and it's apparent that it's a UI layered on top of Yaml. Home Assistant has a reputation of being difficult to install and setup at times. They definitely lived up to that for me trying to install it on a spare Mac. Several hours over the holidays were consumed to get that working. I would recommend anyone without a ton of patience and several hours to spare, just download the all in one image for Raspberry Pi.

[Edit]
For installation on the Mac (or any other computer), I really wish I had tried Virtual Box first, before going through all the struggle to install it through the Mac terminal by creating with a virtual volume and the adding all the dependencies. First, it doesn't support Hass.io so you don't have access to the Supervisor and the add-ons store, and second, it's SO MUCH more difficult to setup. I downloaded Oracle Virtual Box on a very old (2009 MacBook) and it installed in a minute, without requiring any additional downloads. I then followed the simple instructions for Virtual Box here, and the full Hass.io was ready in 5 minutes! :man_facepalming:

I gave the VM have the amount of RAM (1024) than the suggested 2GB (because 2GB is all the MacBook I'm using for this has available). It runs fine. Highly recommend anyone with a spare laptop computer, simply use Virtual Box for this. Much easier and less expensive than a dedicated RPi for this particular task.

Xiaomi Aqara

The Aqara HomeKit Hub is among the newest hubs coming out of China that support the Xiaomi Mijia, Aqara and several other device brands available to the Chinese market. Most of these devices are nice in appearance, inexpensive, small, have great battery life, and are very reliable (when joined with a Xiaomi hub). There is one very specific Xiaomi hub that can be joined to Hubitat Elevation with the community provided MiConnector app, or to Home Assistant. But the effort and uncertainty of getting everything working with that isn't all that reassuring to me personally.

How it works

When HE devices are exposed via Hoobs and thus HomeKit, the Homebridge application beneath all that eye candy is only sharing them in a single direction. HE to Hoobs. You also cannot see official HomeKit devices in Hoobs. Genuine HomeKit capable devices added via an Apple device will only appear in the Apple Home app, and you cannot get their status from Hoobs or Homebridge directly back into HE.

Home Assistant has a similar capability to share devices to a HomeKit network, but they also have a very interesting capability called HomeKit Controller. No idea how they have not been sued by Apple for the name alone, but here's how it works. They too cannot "see" devices that are in an official Apple HomeKit environment, but they can emulate a HomeKit hub (sort of). They definitely cannot share devices in iCloud, as that would bring on the Apple lawyers in the blink of an eye. Therefore there's also no remote access through the Apple Home app with this integration. However, if you disconnect a HomeKit compatible device from any official Apple HomeKit environment and instead join it via the HomeKit Controller integration, the devices can be controlled and their state will update in Home Assistant. So why does that matter, we're trying to get HomeKit devices synced in HE right? Stay with me, almost there.

Completing the link

When you install the HomeKit Controller integration in Home Assistant, there's a dialogue that asks for the HomeKit PIN. This PIN is how accessories are normally added to HomeKIt. Any hub or HomeKit capable device that isn't exposed via Hoobs or Homebridge will have a PIN code. That means that Hoobs also has a PIN code that can be added to the HomeKit Controller integration on Home Assistant, and so too can the HomeKit compatible Xiaomi Mijia and Aqara hubs. When you do that, all their devices are also exposed to Home Assistant.

Still with me?

So we expose devices to Hoobs, and its devices, plus all the Aqara HomeKit Hub or Mijia Multimode Gateway devices are now showing up and displaying their current state in Home Assistant. Once you have the state of HomeKit capable devices and devices exposed to HomeKit via Hoobs, you can link the ON/OFF, OPEN/CLOSED, etc. device states to a virtual device in HE. When you share the virtual device from Hubitat Elevation via Hoobs, the HomeKit Controller integration in Home Assistant will bring it into Home Assistant. So you simply create a basic automation in Home Assistant for the two states of the HomeKit enabled Xiaomi devices. That allows them to be synced with the Hubitat Virtual device, and there you have it. Xiaomi Aqara devices (most of them anyway) with status and control (where applicable) in Hubitat Elevation. Then the really difficult automaitons can more easily be built in HE Rule Machine.

Beyond Xiaomi

It should be apparent that if you can expose Xiaomi HomeKit enabled devices to HE this way, you can also expose just about any real HomeKit device to HE. And because there are a ton of Homebridge integrations that are really easy to install in Hoobs, you can expose them to the HomeKit controller integration, and thus sync them back to HE. Obviously this can also be used to sync devices joined directly with Home Assistant back to HE , but that is beyond the scope of this post.

Setup

  1. Download and install Hoobs (I didn't test with Homebridge but it should be possible as there is a PIN code in the config.json file). Easiest to download and image a single SD card to run on a Raspberry Pi by itself, but I have Hoobs running on an old Mac together with Home Assistant. The performance is good and the virtual devices react instantly to the real devices.

[Edit]
For installation on the Mac (or any other computer), I really wish I had tried Virtual Box first, before going through all the struggle to install it through the Mac terminal by creating with a virtual volume and the adding all the dependencies. First, it doesn't support Hass.io so you don't have access to the Supervisor and the add-ons store, and second, it's SO MUCH more difficult to setup. I downloaded Oracle Virtual Box on a very old (2009 MacBook) and it installed in a minute, without requiring any additional downloads. I then followed the simple instructions for Virtual Box here, and the full Hass.io was ready in 5 minutes! :man_facepalming:

NOTE: If you want to install Hoobs on a Mac like I did, use these instructions.

  1. Search for the Hubitat plugin for HomeBridge with MakerAPI in the Hoobs plugin search and follow the instructions to setup MakerAPI on your HE hub for using it with Homebridge..

  2. Download and install Home Assistant. I installed on the same old Mac that is running under MacOS El Capitan with Hoobs installed. Installing Home Assistant on a Mac was frustrating. Getting it set to use the correct version of Python with all the dependencies was a massive test of my patience, but I eventually got it to work. If anyone else wants to go this route, I can offer up the links that helped get me through the ordeal. I would recommend the complete, ready to go image for a Raspberry Pi, or maybe installing on a Docker image as I read many others recommend as I was searching for answers to the numerous issues I was facing.

  3. Factory reset your Aqara HomeKit Hub or Mijia Multimode Gateway (HomeKit compatible). During the Aqara or Mijia configuration, the Aqara and Mi Home app will prompt you to join a HomeKit network if you have any iOS device on the network. Cancel that action or you will have to reset the device and start again.

  4. Add the HomeKit Controller Integration to Home Assistant. It will prompt you for the PIN code of your accessory. Add the PIN from your Xiaomi Aqara HomeKit Hub or Mijia Multimode HomeKit compatible Gateway.

  5. Add at least one device to your Xiaomi Aqara HomeKit Hub or Mijia Multimode HomeKit compatible Gateway to test. Restart Home Assistant.

  1. You should see the Xiaomi device in your Home Assistant device list. Test the device to ensure you see its state changing in Home Assistant.

  1. Create a virtual switch in HE and add it to the MakerAPI instance for Hoobs. Restart the Hoobs service.

Screen Shot 2021-01-08 at 11.19.42 PM

  1. You should see your HE virtual switch in the Hoobs Accessories under the category "Unassigned". Actuate the switch from Hoobs and ensure you see it turn ON/OFF in HE.

  1. Locate the Home PIN in Hoobs. This is found in the Hoobs configuration (the gear icon in the lower left corner).

Screen Shot 2021-01-08 at 10.45.14 PM

  1. In Home Assistant, add the HomeKit Controller integration again, but this time enter the PIN from Hoobs. The integration must find a HomeKit compatible accessory that isn't already bound to a HomeKit network.

  2. You should see both the Xiaomi hub and Hoobs added to the HomeKit Controller integration.

Screen Shot 2021-01-08 at 11.22.24 PM

  1. Restart Home Assistant again (if anyone knows how to make new devices appear without having to restart Home Assistant every time, please let me know so I can update the post).

  2. You should now also see the HE virtual switch in the Home Assistant device list. Create an automation so when the device is inactive, closed or OFF, it will turn OFF the HE virtual switch.

  1. Create a second automation so when the device is active, open or ON, it will turn ON the HE virtual switch.

Screen Shot 2021-01-08 at 11.26.31 PM

Screen Shot 2021-01-08 at 11.28.34 PM

  1. Actuate your Xiaomi device. You should see the virtual switch in Hubitat Elevation changing state with the change in state of the real device. If it's a HomeKit outlet or a light, you should be able to also turn it ON or OFF from HE by toggling the HE virtual switch.

You can now repeat these steps for the remainder of your Xiaomi devices and you will be able to use the HE virtual devices synced to the Xiaomi real devices in your HE Rule Machine 4 automations.

7 Likes

Nice writeup!

The best thing about this approach is that it will work with the latest version of the Xiaomi gateway (Mijia Multimode Gateway), which is Homekit-compatible, but doesn't support a direct LAN connection like the older Mijia Smart Gateway. Pertinently, Xiaomi's newer zigbee 3.0 sensors (Aqara T1) work with the Mijia Multimode Gateway.

Thanks. I think it was you that first told me about the HomeKit Controller Integration and I've been meaning to test it out for a very long time now.

I have heard that they will not, unfortunately. Even though it is also Zigbee 3.0. But I have that hub and it looks like from the app that there is a version 2 of the Mijia sensors coming. My assumption is that's a Mijia 3.0 version. I think (but am not certain) that Shenzhen Green Rice Lianchuang Technology Co Ltd. designs devices for Xioami to use in both lines. That's a primary reason there's a lot of crossover.

That's a shame.

Yep, but if there ends up being the same devices from both devisions, then it's probably not a big deal. If nothing else, the Mijia Mulimode Gateway is a steal for the price (around $21 USD on average), but you do have to keep it talking to China. I cut the internet off on mine and it stops updating the devices after a few days. The Aqara HomeKit Hub doesn't do that. I cut off it's internet access and it just keeps working.

1 Like

hi guys. So I have a samsung air conditioner which I connected to Hubitat via hubithings replica app. However when I tried integrating that AC into the Homekit with the homekit app, it shows up as an incompatible device. Is there a workaround for this?

No - because it makes use of community virtual drivers. Your best choice would be to use Homebridge (unless Samsung lets you directly expose the A/C to HomeKit).

Probably. What critical functions do you want to control?

You should be able to use virtual switches for on/off controls, and a Hubitat virtual thermostat with the Hubitat thermostat controller app for temperature control.

Here’s a rough idea of the setup for the Thermostat Controllers app. This post refers to a sensor, but the concept for controlling a real thermostat with a virtual one is similar. Just substitute “Google Home” for HomeKit.

2 Likes

That's a nice workaround - I like it!

1 Like

Thanks. But I guess I would need an apple home pod for this right?

Not if you have any other HomeKit compatible devices. If you don’t, then I’m a bit confused why you’re trying to use the HomeKit integration in the first place. :thinking:

2 Likes

:smiley: Thanks. I just have an iphone. And what I was confused about - if I still need an apple hub to use to take advantage of homebridge or this new homekit integration. I see I dont need it with this homekit integration, however as it doesnt allow to add my samsung devices, I may need to try your option or try a homebridge driver. But for homebridge I assume the hub is needed right?

on/off for AC would be good. However having an option to create a custom mode for that AC (such as set temp to 19C, turn off display lights, turn on ECO mode, etc...) when I activate that mode would be AMAZING

To create Apple Homekit Automations you need a Homekit Hub, yes. To manipulate your Homekit devices from outside your home, you need a Homekit Hub, yes.

A Homekit hub is either an Apple TV or an Apple HomePod, yes.

You can use the Hubitat Homekit Integration or Homebridge to add Hubitat devices to Homekit. You cannot add Homekit devices to Hubitat... except via Hubitat virtual devices that get sent to Homekit, then, using Automations, sync Homekit devices to Hubitat devices.

Whew... so yes, to do much in the home automation arena with Apple, you'll want an Apple hub. Either Apple device can be treated as a Hub, you don't have to use it for anything, just have either powered and configured.

For Homebridge, you need an always on computer, even as small as a Raspberry Pi 3. It's a NodeJS package and NodeJS runs on so many computer types. I happen to run two instances on a headless Mac Mini that exists as a media server... so tons of extra CPU to go around.

1 Like