Home Assistant: Trigger on ANY iOS 18 + iOS 26 Focus Mode

If you are a Home Assistant user and would like to take nearly any Home Assistant action when ANY Apple iOS Focus Mode (even Sleep) is turned on or off, this post is for you. In iOS 18 and earlier all focus modes except Sleep can use built-in personal automations to trigger Home Assistant actions. However, for some reason Apple neutered the Sleep focus mode in iOS 18 and earlier, so creative workarounds are needed.

Thankfully iOS 26 beta has remedied this situation, and Sleep mode can now trigger distinct on and off actions. This article will cover both the iOS 18 method, as well as the iOS 26 method. I also assume you have the Home Assistant companion app installed on your iPhone. 

Home Assistant Helper Entity

I recommend creating a Home Assistant helper entity (input_boolean) that will track the state of the sleep focus mode (or any focus mode). Then within Home Assistant you can use this boolean helper to trigger automations, for example. On the iPhone we will then use a creative means (iOS 18 and earlier), to toggle this boolean helper to track the sleep focus mode state. It’s more straightforward in iOS 26.

  1. In Home Assistant go to Settings -> Devices & Services -> Helpers. Select CREATE HELPER.
  2. Type Toggle in the search box. Click on the Toggle item. Give the Toggle a name (e.g. Sleep Focus Mode) and pick an icon. Click CREATE.
Home Assistant Boolean Helper

If you want to trigger automations based on more than one focus mode, just create a unique helper for each focus mode you want to track. You can then setup separate Shortcuts to use the different Home Assistant helper entities to track multiple focus modes.

iPhone iOS 18 Procedure (Sleep Focus Mode)

On iOS 18 and earlier there’s no direct method to tell when the sleep focus mode is turned on or off. They only allow sleep triggers of “Wind down Begins”, “Bedtime Begins” and “Waking Up”. These do not exactly track the binary state of the sleep focus mode. For all other focus modes Apple does give you explicit “When Turning On” and “When Turning Off” triggers. If you don’t care about Sleep focus mode, skip down to my iOS 26 section and follow those steps, as they work on iOS 18 for all focus modes EXCEPT sleep. 

For iOS 18 I created a single Shortcut which uses time-based logic to toggle the Home Assistant sleep mode helper entity. The time conditions correspond to the hours I might go to sleep (6PM to 2AM). If the Shortcut is run during this timeframe, I make a Home Assistant service call to turn on the sleep focus mode boolean helper. If the shortcut is run any time outside of these hours, it turns the sleep focus mode boolean helper off. This logic is NOT needed in iOS 26 and allows the triggers to run 24/7 without restrictions.

You can directly download this shortcut via My iCloud Link. I suggest you use the link, as there some nuances to the Get numbers from step that just grab the two digit hour (24-hour clock). Basically you use a custom date format of just HH. Before you proceed, make sure the Shortcut is working. In case you are building the Shortcut from scratch, you can copy the JSON below and modify as needed for the name of your boolean helper.

				
					{
  "entity_id": "input_boolean.sleep_focus_mode"
}
				
			

The Magic of Pushcut

In order to work around Apple’s neutering of the Sleep focus mode configuration options in iOS 18, we must revert to a third party tool. Pushcut for iOS integrates with the iOS Focus Filters, which is the secret sauce for making all of this work. You can download Pushcut from here. I’ve had the paid version for a while, but I think for the sole purpose of this tutorial the free version will suffice. 

  1. Download and install Pushcut on your iPhone.
  2. Once it installs, open Pushcut. In the upper left hand tap on the circle with the three dots. Tap on Shortcuts and follow the procedure to import all of your Shortcuts into the app. This involves installing a new shortcut that populates the Pushcut UI with all of your shortcuts.
  3. On your iPhone go to Settings -> Focus -> Sleep. 
  4. Go all the way down to the bottom and under Focus Filters tap Add Filter.
  5. Tap the Pushcut icon. 
  6. On the Shortcuts line tap Choose. 
  7. Find the Shortcut that you created above and tap on the name. Tap on Done.
  8. Leave everything else alone on the configuration screen and tap Add in the upper right.
  9. Verify that the Focus Filter has been added. 
  10. Manually turn on and off the the sleep focus mode and validate the Home Assistant helper toggle changes as expected.

Now that you’ve done all of the configuration work, the Home Assistant boolean helper will always follow the sleep focus mode state of your iPhone. 

iPhone iOS 26 Procedure (All Focus Modes)

In the iOS 26 developer beta 1 they made changes to the Sleep focus mode configuration. Finally! Apple now treats Sleep focus mode the same as all other focus modes. This means the sleep focus mode now has explicit “Is Turned On” and “Is Turned Off” automation triggers. This will enable us to natively run different Shortcuts based on Sleep mode being turned on or off. This is perfect for setting the Home Assistant boolean helper state. This procedure will also work on iOS 18 for all Focus modes EXCEPT Sleep.

Home Assistant Shortcuts

For this exercise we will create two separate Shortcuts that use the Home Assistant companion app. One Shortcut will turn the boolean helper “on” and the other will turn it “off”. If you want to download my prebuilt Shortcut click here.

  1. On your iPhone open the Shortcuts app.
  2. In the upper right corner tap the + button.
  3. In the Search Actions box type call service.
  4. Tap on the Home Assistant Service and type bool. Tap on input_boolean.turn_on.
  5. Tap on the arrow next to data.
  6. Tap on Choose and tap on your HA server name.
  7. In the Service Data paste in the JSON below, and modify as needed for your entity name.
				
					{
  "entity_id": "input_boolean.sleep_focus_mode"
}
				
			

8. Disable Show When Run.
9. At the top of the window tap on Call Service, then Rename. Pick a suitable name (e.g. Turn on Sleep Focus Mode).
9. Tap on Done to save the Shortcut.
10. Duplicate the Shortcut and modify the call to use input_boolean.turn_off and name the Shortcut accordingly.
11. After the Shortcuts are built tap on each Shortcut and verify in Home Assistant that the boolean helper state changes.

Focus Mode Configuration

Now that we have our two Shortcuts setup we can configure the focus mode of our choice to run the appropriate Shortcut.

  1. Open the Shortcuts app on your iPhone.
  2. At the bottom of the screen tap on Automation.
  3. In the upper right corner tap on +.
  4. Scroll down towards the bottom and tap on Sleep (or the Focus mode of your choice).
  5. Leave the check box on under Is Turned On. Tap Run Immediately. Tap Next.
  6. Search for the Shortcut which turns on your HA boolean helper and tap on it.
  7. You should see a new Automation called When Sleep is turned on.

8. Repeat the process but select Is Turned Off for the “When” and select your “off” Shortcut.
9. You should now have two Shorcuts listed under Personal Automations.

10. Manually turn the Sleep focus mode on and off to verify the Home Assistant helper entity changes state. 

Home Assistant Automations

Now that all of the configuration has been done on your iPhone, we can now turn to Home Assistant. The sky is the limit here, so I’m just showing you one example of what you can do. I’ve included the YAML, which can be fully edited in the visual editor. Just create a new automation, switch to YAML view and paste the code. Switch back to the Visual mode and change the entities as needed. 

In my example automation I have an automation called “Master Bedroom – Good Night” which is triggered by the sleep focus mode boolean entity turning on. It also checks that I’m actually home, by making sure my iPhone is in the “Home” zone. It then turns on a goodnight scene. This scene closes my blinds and turns off all the lights.

				
					alias: Master Bedroom - Good Night
description: ""
triggers:
  - trigger: state
    entity_id:
      - input_boolean.sleep_focus_mode
    from: null
    to: "on"
conditions:
  - condition: zone
    entity_id: device_tracker.dereks_iphone_16_pro
    zone: zone.home
actions:
  - data: {}
    target:
      entity_id: scene.mb_goodnight
    action: scene.turn_on
mode: single

				
			

I have a separate automation that does the reverse for my morning scene. 

Home Assistant Feature Request

The current version of the Home Assistant Apple companion app does NOT support App Focus filters. If it did then it would bypass the need for making Shortcuts to toggle the boolean toggle entities. I opened a HA Github feature request for adding Focus App Filters support:

Feature Request: Add Focus Filters App Filters Support #3652

Apple restricts apps from knowing the focus mode name and state. Apps CAN be notified of the focus mode name and state by using the App Focus filters function. I presume one reason for this is privacy. This seems like a pretty easy API to support, so I home the Home Assistant team can add support. Feel free to add a comment or vote of support on Github.

Summary

In iOS 18 Apple makes it very difficult to trigger the running of Shortcuts for the Sleep focus mode. For this reason I used the third-party app called Pushcuts to provide a workaround. For iOS 26 Apple finally made the sleep focus mode on parity with the other focus modes, so no third party tools are needed. Thank you Apple!

Related Posts

Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments