Blog Post: Using ANY iOS 18 + iOS 26 Focus Mode to trigger HA automations

If you are an Apple user and would love to trigger Home Assistant automations based on focus mode changes, this post is for you. While in iOS 18 Apple made this fairly easy for most focus modes, “Sleep” was special for some reason. It was missing the focus mode “on” and “off” triggers that every other focus mode had.

For iOS 18, I have a fresh blog post that uses a simple third party utility to FULLY automate ANY focus mode change on your iPhone. I now have fully automated bedtime scenes that turn on when sleep focus mode is enabled, and a morning scene that is triggered when sleep focus mode is turned off.

In iOS 26 developer beta 1, Apple has removed the sleep focus mode limitations and now all focus modes have the same “on” and “off” triggers. This means no third party tool is needed on iOS 26 to trigger HA automations for ALL focus modes.

Check out my full how-to guide here for iOS 18 and iOS 26:

1 Like

Hi! Very well written tutorial, easy to follow. But I ran into one problem, the “When” in the shortcuts app doesn’t have the “Is Turned On” or “Is Turned Off”, the options I have are “Wind Down Begins”, “Bedtime Begins” and “Waking Up”. I chose “Bedtime Begins” for turning on Sleep Focus Mode, which works well, but for turning off Sleep Focus Mode neither of the other two options work.

I’m on an iPhone 14 Pro running iOS 18.5.

I solved this issue by an automation that triggers when the state of ‘binary_sensor.(your iPhone name)_focus’ changes to turned off. This sensor is an entity from the Mobile App integration. This seems to work well, but something that maybe could be a problem for someone is that it triggers the automation the even if you turn off one of your other focus modes on your phone, but to be honest I can’t see how that could cause a problem.

Same here. Doesn’t have those options on IOS 26, IPhone 15 Pro.

Same here. I don’t have this option on iOS 36, but I do have it on iPad.

I also don’t have a Turn off or on. Maybe something changed between the beta and release.

Did the “Waking Up” work if you let the scheduled time for wake up pass, and just not for manually turning off Sleep Focus? Or for neither?

Update: Just did a quick test and set my wake up time and it did actually run the automation and toggle off the input_boolean in HASS after the wake up time and clearing the alarm.

So the wakeup just doesn’t seem to work only when manually toggling off Sleep Focus.

Anyone, found a way to do it the opposite way - set the “Focus” mode based on actions in Home Assistant ?

Is bedtime begins not the trigger for this, just different wording?

On another note, why the json instead of the home assistant shortcut item for toggle the sensor? seems to be built in natively.

I got this to work on my ipad after updating my iphone, ipad, and mac to Developer Beta 26.3, but for me it only works on the iPad. As mentioned by other users, “Wind down begins” is still the option instead of “Is turned on” as the automation trigger on my iphone. I’ve tried forcing icloud sync, deleting the Shortcuts app turning off and on whatever settings I could think. It must be buggy. I imagine when my ipad is asleep for too long it will break. While it did give the new options on my mac, Home Assistant isn’t an app on the mac so, there’s no ability to create the automation there. There is a descent workaround still for this that’s not difficult but, only if sleep is the only focus you use (fine for me). Settings > Focus > Share Across Devices > Yes. Then below that, Focus Status > Share Focus Status > Yes. Then below that disable all the focuses but sleep. NOW, you can setup the rest in home assistant. (The Mobile App integration may need to be turned on, I can’t remember, but it is in Core) Create a new automation with a device trigger, pick the Mobile App with your phone name. Pick the trigger called “iPhone Focus is Turned On” or “Off” respectively

Unfortunately on my iPhone (iOS 26.2) Focus entity turn to True only when I turning on “Do not disturb” focus mode on my iPhone, but do nothing when I use other focus modes :frowning:

Yes, but it’s really awful and hacky (although it works reliably):

  • Have your icloud.com email account enabled on your phone.
  • Set up an smtp notifier in your Home Assistant configuration to email your iCloud email account:
    notify:
    - name: icloud
      platform: smtp
      sender: some@address-for-home-assistant-outgoing-emails
      sender_name: Home Assistant
      recipient: [email protected]
      server: your-smtp-server.com
      username: your-smtp-username
      password: your-smtp-password
    
  • When you want to activate a particular focus mode (in my case, Sleep Focus), trigger this action:
    action: notify.icloud
    data:
      title: Start Sleep Focus
      message: .
    
  • Set up an iOS personal automation shortcut as follows:
    • When: When I Get an Email Subject Contains ‘Start Sleep Focus’
    • Do: Set Focus: Turn Sleep On until Turned Off
  • Do similar for turning focus off.

Limitations:

  • Phone needs to be on and connected to the internet.
  • Home Assistant’s outgoing internet needs to be OK.
  • There’s a delay of about 10 seconds or so, in my experience.

I applaud the work Derek has put into his article on this matter, but it probably can’t be denied that if this information were somehow available through HA itself, that would be preferable to setting up iOS shortcuts.

Please consider upvoting my feature request for a mechanism to differentiate active focus modes using a new sensor (or a new attribute on the existing binary sensor) if you would like the ability to know which focus mode is active.