Integrating Home Assistant and Apple HomeKit

With iOS 16.2, Apple released the new architecture for HomeKit which many hoped would resolve issues with non-responsive devices, automations not triggering as expected, and some other performance enhancements. However, while some users were able to upgrade without issue, others continue to have the same issues, have their HomeKit Homes completely broken, or lost connection with household members requiring a lot of troubleshooting to get things back to normal. As a result, I have noticed more and more posts on social media asking how to migrate to Home Assistant and what that means for HomeKit accessories.

What are the benefits of moving to Home Assistant?

Home Assistant is an open-source platform that provides advanced functionality to your smart home. While HomeKit is great, especially for a primarily Apple based household, it lacks functionality that is critical to building and maintaining an actual “smart” home. For example, without the use of third-party apps, there is no way to back up your HomeKit Home configuration in case of corruption or failure. Some apps like Controller for HomeKit add backups and some advanced automation support, but has a fee associated with it for some of these features. With Home Assistant, you gain the ability to:

  • Back up and restore your Home Assistant configuration, including Add-Ons
  • Create advanced automations with conditions, if/then actions, schedules, etc
  • Integrate non-Apple HomeKit devices, much like HomeBridge
  • Natively create custom dashboards for use on mobile devices or a wall mounted tablet
  • Integrate cloud services using HACS (Home Assistant Community Store) such as Xbox Live, Discord, Coinbase, calendars, etc

I have invested in HomePods, Apple TVs, and other native HomeKit Accessories. What happens to them?

To me, this is the best part about integrating Home Assistant and HomeKit. In my setup, I have all devices configured in Home Assistant, including all automations, then send those devices over to HomeKit so I can continue using Siri, HomePods, Apple TVs, Personal Automations, etc where it makes sense. HomeKit is great for integrating your Apple devices, and there are some fairly unique things you can do with the platform that just isn’t available with other platforms. I’ll give a great example of this later. HomeKit accessories can be configured inside of Home Assistant just as you would with HomeKit. I have seen a few exceptions where the device is added, but no entities are presented, and there may be a few devices (HomeKit Secure Video cameras, for example) where it makes sense to add them directly to HomeKit instead.

What do I need to get started?

There are multiple ways to get Home Assistant installed. You can run HA as a virtual machine if you have existing hardware, install on bare metal using a Raspberry Pi or (almost) any x86 hardware like an Intel NUC, in a Docker container, or even some NAS devices include the ability to install Home Assistant. You can find the full list on the Hass.io website that details installation types and instructions.

I ran Home Assistant as a virtual machine using Microsoft Hyper-V, but recently decided to move to bare metal to save on energy as my host was a full blown server. I picked up this Intel NUC for about $250, but you can easily run off of a Raspberry Pi.

If you plan to add Zigbee or ZWave devices to your Home Assistant instance, you’ll also want something like this Sonoff Zigbee 3.0 USB stick (this is what I use) which allowed me to ditch my Aqara and Philips Hue hubs and build one big mesh network instead of two. Home Assistant Sky Connect is another option available at this time for pre-order which includes a Thread radio as well.

I would also highly recommend installing the Home Assistant iOS app. This will give us access to Shortcuts, and you can manage your Home Assistant instance from your phone or tablet.

There are plenty of guides on YouTube and the HA forums explaining how to install Home Assistant and get the basic setup done, so I will leave it to them.

Adding HomeKit Devices to Home Assistant

Pairing your native HomeKit devices with Home Assistant is a bit of an odd process, but only takes a few minutes.

First, you will need to factory reset the device. The process depends on the type of device, but for my example iHome Smart Plug, I pressed and held the on button for 15 seconds or so to completely reset the plug. Once reset, add the device to HomeKit just as you normally would by scanning the code or entering it manually and add it to any room.

Once your device is added, locate it in the Home App, then Remove Accessory. What we’re doing here is connecting the device to WiFi, then removing the device from HomeKit so it can be added to Home Assistant.

Once the device is removed, open the Home Assistant interface and navigate to Settings > Integrations. The device should be auto discovered and ready to set up. Click Configure to add the device.

Enter the pairing code on the device using the correct format, then click Submit.

Select an area for the device and click Finish.

You will now see the device listed in the HomeKit Controller integration. You can click the name of the device to rename it and manage the entities found.

Adding Devices Back to HomeKit

Now that we have devices in Home Assistant, we need to add them back to HomeKit. We will be creating a bridge in Home Assistant, which then needs to be connected to HomeKit like any other bridge. This bridge will sync the selected domains and entities during the setup process.

In Home Assistant, navigate to Settings > Integrations then click the Add Integration button. Search for HomeKit, then select the domains to configure. Domains are the types of devices that we want to sync to HomeKit. For example, lights, switches, fans, etc. Once you’ve selected your domains, click Submit.

Now we need to pair the bridge with HomeKit. Click the notifications in the bottom left of your Home Assistant window, then add the bridge to the HomeKit App.

Your devices should now show up in HomeKit and you can assign them to rooms, add to Shortcuts, use Siri to control them, etc just as you normally would.

By default, adding the domain includes all devices of that domain, and you may want to narrow it down to specific devices. Locate your HomeKit integration in Home Assistant and select the bridge, then click Configure. Change the Inclusion Mode to Include and hit Submit.

Now you can select the device you want to include in the bridge, meaning only the selected devices will be synced over the bridge to HomeKit. Select your device, then click Submit.

So I’m back where I started. What’s the point of all this?

Now is when the fun begins. I am going to use my Bedtime Shortcut as an example to show you how I am using HA and HK together.

If you’re following along, you will need the Home Assistant iOS app installed on your device to be able to add them to Shortcuts.

In Home Assistant, I’ve created an Automation with no trigger as I trigger it manually. The automation sits idle until called upon by running a Shortcut either through Siri or clicking the Shortcut button on the home screen of my phone. This automation runs many actions, but mainly shuts down the house by turning off any lights, TV’s, or active Amazon Echo devices, turns on my robot vacuum to clean the downstairs and sets a preset on my Ecobee thermostat.

In Shortcuts, I have created a Shortcut called It’s Bedtime that allows me to select one of 3 options: Me, my wife, or everyone. Each runs a different automation, but we’ll focus on my bedtime and its actions.

The Shortcut will prompt me to set an alarm and pick which one I would like to use, uses the automation.trigger action to run the automation.my_bedtime automation in Home Assistant, turns on Sleep Focus on my iPhone, then sets the brightness of my device to 1% for the night.

Conclusion

To me, this is the real benefit of using both platforms together; you get the ability to lean on each platforms strengths to make very useful automations that couldn’t be done in either platform independently. This is just one example, and some of these actions could be performed natively in HomeKit, but you could easily add conditions to this to only run when I am home, or anything else you can come up with, something you couldn’t do natively with HomeKit.

Based on comments and downvotes in the HomeKit subreddit, it seems that HomeKit users look at the two platforms as exclusive and that they can’t coexist. I love the capabilities of HomeKit, but also recognize its limits. Using Home Assistant with HomeKit (and in my case Amazon Alexa..) has given me the flexibility to create and configure my smart home the way I think it should work. I hope this article helps raise awareness for the platform and helps you build your smart home the way you think it should work.

If you have any questions or comments, please leave them below. I’d love to write more content about HomeKit and Home Assistant, so I am always looking for ideas on where people may need help or would find interesting.

Interested in what products I am using in my Home Assistant and HomeKit setup? Check out recommended products here: https://technogecko.net/products/