Now that the iOS 27 and iPadOS 27 betas are out, I’ve been digging a bit into the Shortcuts enhancements for tracking focus mode changes. With previous versions of iOS and iPadOS it was quite difficult to track all the focus mode states and call Shortcut actions based on the focus mode state. However, with iOS 27 and iPadOS 27 it is possible to track all the focus mode states.
What changed in iOS 27 and iPadOS 27 that makes it easier to track focus mode changes? A few things:
- Global variables are now supported via “Store Content”, “Get Stored Content” and “Delete Stored Content“. No third party apps are needed.
- Sleep focus mode is now supported as a selectable focus mode automation trigger (see bug note below)
- Shortcuts can have multiple automation triggers
- Apple added “Otherwise if” logic to make If logic statements easier to follow
- iCloud Shortcut links can now include the automation triggers
Combining all of this together makes it possible to create a Shortcut to accurately track all focus mode state changes in real time. You can call Shortcut actions based on turn on, turn off of any focus mode. In this example I just use a place holder action (Show alert) to show you the state changes of the focus mode as they happen. Replace the Show alert action with whatever actions you want to trigger.
Beta Bug Note: As of iOS 27 developer beta 3 (public beta 1) you are not able to select the Sleep focus mode in the Shortcuts app as an automation trigger. However you can on iPadOS 27. Surprisingly, the Sleep focus trigger works on iOS 27. So I just disable all of the Shortcut automation triggers on my iPad and enable them on my iPhone. I’ve filed a bug with Apple (FB23691328).Â
If you import this Shortcut from iCloud (link below), it should preserve the Sleep focus mode on iOS 27. You just can’t create a new Shortcut trigger that uses the Sleep focus mode.
Why Track Focus Mode Changes?
Tracking which focus mode your iPhone is in can be very useful. For example, if you have a Home Assistant setup you can use the Shortcut to always keep Home Assistant up to date with the current focus mode of your iPhone. You can then trigger automations or do almost anything you want in Home Assistant. You can check out this post: Home Assistant: iOS Focus Mode Automations (2027 Edition)
Shortcut Architecture
This shortcut monitors five iOS focus modes: Personal, Driving, Sleep, Work, and Do Not Disturb. It fires a distinct action when each is turned on or off. It uses the iOS 27 global stored content actions to persist state across automation runs, allowing it to compare the current focus mode against the previously active one and correctly detect both what just turned on and what just turned off, including during direct switches between focus modes.
Key behaviors:
- A direct switch from one focus to another (e.g. Work → Personal) fires both an ON action for the new focus and an OFF action for the old one in the same run
- Redundant re-triggers of the same focus state produce no output
- Back-to-back toggles of the same focus mode (on/off/on) fire correctly every time
- Cold starts and stale re-triggers are handled safely with no false alerts
── TRIGGERS ──
When Sleep Is Turned On or Off
When Personal Is Turned On or Off
When Work Is Turned On or Off
When Driving Is Turned On or Off
When Do Not Disturb Is Turned On or Off
── READ CURRENT STATE ──
1. Get Current Focus
2. Set Variable CurrentFocus = Name (of Current Focus)
(empty when no focus active)
── READ PREVIOUS STATE ──
3. Get Stored Content PreviousFocus [Global Value: ON]
4. Set Variable PreviousName = PreviousFocus
(empty when nothing stored)
── ON DETECTION ── (guard once, then route by current name)
5. If All are true:
CurrentFocus has any value
CurrentFocus is not PreviousName
6. If CurrentFocus is "Personal"
7. ▸ SLOT 1 — Show alert: "Personal on"
8. Otherwise If CurrentFocus is "Driving"
9. ▸ SLOT 2 — Show alert: "Driving on"
10. Otherwise If CurrentFocus is "Sleep"
11. ▸ SLOT 3 — Show alert: "Sleep on"
12. Otherwise If CurrentFocus is "Work"
13. ▸ SLOT 4 — Show alert: "Work on"
14. Otherwise If CurrentFocus is "Do Not Disturb"
15. ▸ SLOT 5 — Show alert: "DND on"
16. End If
17. End If
── OFF DETECTION ── (guard once, then route by previous name)
18. If All are true:
PreviousName has any value
PreviousName is not CurrentFocus
19. If PreviousName is "Personal"
20. ▸ SLOT 1 — Show alert: "Personal off"
21. Otherwise If PreviousName is "Driving"
22. ▸ SLOT 2 — Show alert: "Driving off"
23. Otherwise If PreviousName is "Sleep"
24. ▸ SLOT 3 — Show alert: "Sleep off"
25. Otherwise If PreviousName is "Work"
26. ▸ SLOT 4 — Show alert: "Work off"
27. Otherwise If PreviousName is "Do Not Disturb"
28. ▸ SLOT 5 — Show alert: "DND off"
29. End If
30. End If
── PERSIST FOR NEXT RUN ──
31. If CurrentFocus has any value
32. Store Content CurrentFocus as PreviousFocus [Global Value: ON]
33. Otherwise
34. Delete Stored Content PreviousFocus [Global Value: ON]
35. End If
The screenshots below show the full Shortcuts automation. If you want to download the shortcut from iCloud, click here. Please note that you will need iOS 27 or iPadOS 27 to use this shortcut.
Personal Automations
When you import this Shortcut from iCloud it will create five new personal automation triggers, one for each focus mode. If you want you can disable the focus mode automation triggers that you don’t want to use. To avoid confusion, make sure the automations are only enabled on one device.
Summary
Apple has made significant improvements to Shortcuts in iOS 27 and iPadOS 27. Combing several of the new features you can now have perfect focus mode tracking. This can be used for a number of things, but one popular use case is to trigger Home Assistant automations based on focus mode changes.



