For those of you who are passionate about Apple devices, I completely understand. I made the transition to Apple well over a decade ago and never looked back.
Apple Home like most things Apple provides a slick and relatively minimalistic interface for controlling smart home products. It has seamless integration with Siri, making it attractive to Home Assistant users in order to leverage Siri for controlling Home Assistant.
- Does Apple “lock” you in to premium products?
- Hey Siri! How do I setup HomeKit in Home Assistant?
- Filter your devices
Does Apple “lock” you in to premium products?
Apple has a reputation of “locking” users into their ecosphere, giving users no choice but to invest heavily in the services they provide, albeit very good services.
In the case of Apple Home, one might assume that you must purchase HomeKit ready devices at a premium price in order to use it. It seems like the masses mostly believe this and buy in to the Apple premium offering because it just works, it is slick, minimalistic and a joy to use.
However for the more tech-savvy user it becomes evident that Apple tend to leave open a few “back doors” without ever really advertising it. They want to maintain their clean cut brand image, therefore it is up to you to discover the hidden easter eggs.
Apple have quietly allowed third party developers to add non-certified devices to Apple Home. Of course there is a scary warning to Joe public when the Home app is presented with a non-certified product, but those of us in the know are aware that this is just smoke and mirrors, designed to “protect the common end user.”
So aside from my personal thoughts about Apple, what does it actually mean? It means that we can use Home Assistant with HomeKit! This is achieved by making Home Assistant appear as a 3rd party bridge to HomeKit.
So why would we want to do this? There are already some superb apps available for Home Assistant!
Siri of course!
Hey Siri! How do I setup HomeKit in Home Assistant?
If you just read my ramblings about Apple, I talked about HomeKit being able to support 3rd party devices. Developers can integrate their smart device offerings with HomeKit without being forced to get certification.
Add Home Assistant bridge
The clever folks at Home Assistant have integrated a piece of software that appears to HomeKit as a bridge. This software translates messages between HomeKit and Home Assistant.
Once you have Home Assistant setup, you will be given a code to enter into HomeKit, just like adding any other device.
First of all let’s get our Home Assistant and HomeKit connected. We will need to open up our configuration.yaml file and simply add the following line.
Once you have added this line of code, save and restart Home Assistant. After the reboot you should see a notification in the bottom left-hand corner of the screen.
Grab you HomeKit pin
When you click on this notification you will be presented with an 8 digit code. We will use this code to add a bridge in the Apple Home app.
Add Home Assistant bridge to the Home app
Open up the Apple Home app and tap the add accessory button. Then tap the button I don’t have a code or cannot scan. This will allow us to enter our code instead.
Tip: The Apple Home app is also available for desktop OSX via the app store, if you would prefer to use your laptop.
You will notice that HomeKit automatically detected the Home Assistant bridge, however selecting it still requires us to enter a code.
Once you have entered the code, the Home app will warn you that the device is uncertified. Just go ahead and click add anyway to add the Home Assistant bridge.
The Home app will then cycle through each of your Home Assistant entities, allowing you to add them.
Congratulations! You have successfully connected Home Assistant with Apple Home.
Filter your devices
You may find that there are a whole load of devices added to HomeKit. The Home Assistant integration allows you to filter these devices so that you can choose which ones appear in the Home app.
In my configuration I filter out the devices so that only those that I wish to control with Siri appear in the Home app.
In order to add a filter, we simply add another line of code to our configuration.yaml file. This will allow us to choose which devices we share with the Home app.
Under the filter section we can choose to add either an individual entity or all of the entities within a particular domain.
The term ‘entity’ in Home Assistant is used to describe an object within your Home Assistant configuration. All of the devices you have connected such as lights, sensors and switches are entities.
Entities are grouped by type, for example ‘light‘ is the entity group for all lights. For example a lamp would be named light.MyLamp
In order to add single entities, we can use the statement include_entities followed by a list of the entities we wish to include.
For now we will add a single lamp, which is called treelamp in my Home Assistant configuration. You should of course choose a lamp from your own configuration. As this is a light entity, we will write light.<entity_id> where entity_id is the name of the entity.
homekit: filter: include_entities: - light.treelamp
Take extra care that you write the code with the correct tabs/spacing in order to avoid syntax errors as YAML is very sensitive to the formatting.
In most cases where it does not work as expected, it will be because the formatting is incorrect, so check several times if you have a problem.
Now we will save the configuration.yaml file and restart Home Assistant. Once it has restarted we will see only the entity treelamp in our Home app.
Add device configurations
Next we can add a configuration for our entities. A full list of options for the various configuration variables for different entities can be found on the Home Assistant HomeKit page.
In the case of our lamp, it is a light entity so we only have the option to change the name. Lets go ahead and give it the more interesting name “cool tree lamp.” Make sure that entity_config has the same tab/spacing as filter.
homekit: filter: include_entities: - light.treelamp entity_config: light.treelamp: name: Cool Tree Lamp
Note that if you have already configured the HomeKit integration in Home Assistant, the names will cache during the initial installation and the name will not update.
To fix this you can either delete the Home Assistant bridge in the Home app and add it again as we did earlier in this tutorial, or follow this information from the Home Assistant website that explains how to reset the device.
Add an entity domain
If you would like to add all entities from a particular group, you can use the include_domains statement. The following will add all of the entities in the light group.
homekit: filter: include_domains: - light
It is still possible to configure individual entities using the entity_config statement as before.
homekit: filter: include_entities: entity_config: light.treelamp: name: Cool Tree Lamp
As we have seen in this tutorial it is very simply to add HomeKit support to Home Assistant. Once your devices show in the Home app you can use Siri to control them as you would with any Apple Home device, very cool!
I hope you found this tutorial useful, don’t forget to check out some of my other cool tutorials!