SOLVED! Focus Automations in Home Assistant

How to create smart home automations in Home Assistant based on the Focus mode of your iPhone.

SOLVED! Focus Automations in Home Assistant

Introduction

Have you ever thought about using Focus modes with your iPhone to trigger smart home automations in Home Assistant?

For example, you could have your garage door open automatically the moment your car pulls into the driveway based on a Driving Focus. Or, you could have your home’s alarm system arm itself automatically when you actually go to bed based on a Sleep Focus.

If you’re unfamiliar with Focus, it’s a feature on iPhone and Mac that allows you to control the notifications you see. When Sleep focus is activated, for example, it automatically puts your phone into a ‘do not disturb mode.’ You could have another Focus for Work, so only work-related or messages from your family come through. There are lots of possibilities.

Using the Shortcuts app in iOS, you can create automations built around the current Focus. But if you use Home Assistant like I do for your smart home control, I finally figured out how create automations using Focus.

I’ll show you how I did it, and then share a couple examples of how I’m using this.

🍿
Don't feel like reading? Watch it on YouTube.

Main Points

To create these automations, I’m using the following services:

  1. Home Assistant (as my smart home platform)
  2. Apple HomeKit
  3. Shortcuts (iOS app to dictate what happens during the Focus mode)
  4. HomeKit Bridge (integration in Home Assistant to connect Home Assistant with Apple HomeKit)

Before I go through each step, I’ll give you the big picture: We’re going to create a virtual switch in Home Assistant, called an input boolean, and then make that switch function in Apple HomeKit. Then, we’ll create a Shortcuts automation to turn the input boolean on if a certain Focus mode is on, and turn it off when that Focus mode is off. The main automation will live in Home Assistant, and use a condition to only run when that input boolean is turned on.

Focus modes on Apple devices

Let’s start with Home Assistant. Here, we’ll first create an input boolean. Remember, this is the virtual switch we’ll use to tell our home automation if it should run or not.

Go to Settings > Devices & Services > Helpers > Create Helper. Choose a Toggle Helper, and then give it a name. For this example, I created a helper to automatically open my garage door when I pull in the driveway, so I called this Garage Open. Then click Create.

Now, we need to get this input boolean to appear in Apple HomeKit. To do this, we are going to bring our Home Assistant devices into Apple HomeKit using a Home Assistant integration called HomeKit Bridge.

Go to Settings > Devices & Services > Add Integration > Search Apple, and then click to see HomeKit Bridge, and select it. Then, select the domains from Home Assistant that you want to appear in Apple HomeKit. Select the domain Input Boolean. The click Submit. It’s going to ask about Device Triggers, and you can ignore that for now and just click Submit. Then click Finish.

Now, open the Home app on your iPhone, and you should see the input boolean that you just created in Home Assistant now magically appearing in your Home app. Next, open up the Shortcuts app on your iPhone, and click Automation and then the Plus sign in the upper right. For the garage door opening automation, search for Focus and then select Driving. Choose “when turning on” and “run immediately.” I don’t want Shortcuts notifying me when it runs — I use Home Assistant so all my smart home notifications are in one place.

Click Next, and then click on New Blank Automation. Search for “Control My Home” and click it. Tap “Scenes and Accessories,” and then select the input boolean that we brought from Home Assistant into HomeKit. Then turn it on, and click Done. What this does is switch on the input boolean when your iPhone turns on Driving Focus, which for me happens whenever I connect my iPhone to Apple CarPlay in my car.

Now, we need to create one more automation in Shortcuts that turns off the input boolean when your iPhone is no longer in Driving Focus. We’re going to repeat the same steps. In the Shortcuts app, click Automation and then the Plus sign in the upper right. For the garage door opening automation, search for Focus and then select Driving. Choose “when turning off” and “run immediately.”

Click Next, and then click on New Blank Automation. Search for “Control My Home” and click it. Tap “Scenes and Accessories,” and then select the input boolean that we brought from Home Assistant into HomeKit. This time, makes sure it’s off, and click Done. What this does is switch off the input boolean when your iPhone turns off Driving Focus, which for me happens when I disconnect my iPhone from Apple CarPlay in my car.

Finally, we need to create an automation in Home Assistant using the state of this input boolean. In Home Assistant, click Settings > Automations & scenes > Create automation. The automation triggers when I enter my home geofence zone. Your home zone is something you typically create when you first install Home Assistant. Then, it checks to see if the input boolean is switched on. Remember, it will switch on automatically whenever my iPhone is in Driving Focus, and switch off when it is not. Then, it waits for 5 minutes to see if my driveway camera detects a vehicle. This is how my smart home knows when my vehicle is on my property. Then, it opens my garage door, and sends an image of my driveway in a notification to my phone at the time this occurred. I like to have notifications whenever a door is opened or unlocked automatically for peace of mind.

Home Assistant automation to open the garage door when Driving Focus is on and a vehicle is detected in the driveway

So, to recap, we created a virtual switch in Home Assistant, called an input boolean, and then made that switch appear in Apple HomeKit. Then, we created Shortcuts automations on iPhone to turn the input boolean on if Driving Focus mode is on, and turn it off when that Focus mode is off. We built the main automation in Home Assistant, and used a condition to only run when that input boolean is turned on, meaning Driving Focus is on.

But having your garage door open using Driving Focus is just one example. Another way that I’m currently using a Focus automation is at bedtime. When my iPhone goes into Sleep Focus, it automatically puts our Ring Alarm into Home and Armed mode, so we don’t forget to do it. Another idea is to prepare your home office by turning on lights and more when your phone enters Work Focus. And much, much, more.

Watch on YouTube

Tech I Use
Below is all the tech I use everyday, from smart home gadgets, to productivity desk setups, to mobile devices, and more. 🌬️ CEILING FANS Bond Bridge: https://amzn.to/4aiX0pt Zooz ZEN32 Scene Controller: https://amzn.to/3WFRpGF 💻 COMPUTERS & HUBS Home Assistant Beelink S12 Pro Mini PC: https://amzn.to/465DwUP