September 2024 update: This blueprint is now unnecessary because the new version of the Apple Watch app triggers scripts instead of iOS Actions. (The app warns that iOS Actions will soon not be supported.) And, thankfully, devs have added a “Require confirmation” option for watch items, meaning that a workaround like this is no longer required!
This blueprint listens for iOS Companion App action events. When it sees one with a matching actionName, it will send a notification back to the triggering device, requesting confirmation. This is useful, for instance, if you find yourself (like me) accidentally triggering actions from your Apple Watch.
The idea is that you would use this blueprint for all of your automations that listen for iOS action events. When actions are triggered by a watch, Home Assistant will request confirmation. (The blueprint also has the option to request confirmation for all actions, regardless of what kind of device triggers them.)
You can select how long the automation will wait for your confirmation, and you can also select whether the action is “destructive,” which will cause the “Confirm” text to be printed in red.
blueprint:
name: Confirm iOS Action
description: "Get confirmation before executing an iOS action"
domain: automation
input:
actionName:
name: iOS Action Name
description: actionName on iOS companion app (must match exactly)
selector:
text:
action:
name: Home Assistant action
description: Home Assistant action(s) to take after confirmation
selector:
action:
destructive:
name: Destructive
description: When selected, the "confirm" button is highlighted in red to indicate a more serious action
default: false
selector:
boolean:
timeout:
name: Timeout
description: Amount of time to wait for confirmation before the automation gives up
default: 30
selector:
number:
min: 0
max: 120
step: 1
unit_of_measurement: seconds
mode: slider
only_confirm_watch_actions:
name: Only confirm actions triggered by a watch
description: When selected, confirmation will be requested only for watch-triggered actions, and all other actions will be carried out without confirmation. When not selected, confirmation will be requested whether triggered by watch, phone, or computer.
default: true
selector:
boolean:
mode: restart
trigger:
- platform: event
event_type: ios.action_fired
event_data:
actionName: !input "actionName"
action:
- variables:
confirm: "{{ 'CONFIRM_' ~ context.id }}"
- choose:
- conditions:
- condition: not
conditions:
- condition: and
conditions:
- condition: template
value_template: !input "only_confirm_watch_actions"
- condition: template
value_template: "{{ trigger.event.data.triggerSource != 'watch' }}"
sequence:
- service: notify.mobile_app_{{ trigger.event.data.sourceDeviceName }}
data:
message: "Do you really want to {{ trigger.event.data.actionName }}?"
data:
actions:
- action: "{{ confirm }}"
title: Confirm
destructive: !input "destructive"
push:
interruption-level: time-sensitive
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ confirm }}"
timeout: !input "timeout"
continue_on_timeout: false
- choose:
default: !input "action"
default: !input "action"
This worked great however with some changes with notifications on iOS 16, this is sort of broken. The issue is that prior to iOS 16, the home assistant would sent notifications to notify.mobile_app_. With iOS 16 they don’t allow the home assistant to see the name of the iPhone so by default it changes the name to notify.mobile_app_iphone.
This broke all my automations however the app allows you to manually change the ‘Device Name’ to get it back to the name it was. This blueprint doesn’t seem to pick that up though and sends the confirmation to ‘notify.mobile_app_iphone’ which doesn’t exist.
You could just change the device name in the app settings to redacteds_iphone—perhaps that’s what you mean when you say you hardcoded it.
Another solution might be to have the Jinja template lower-case the device name, remove punctuation, and replace spaces with underscores. But I’m not sure what all the rules are, or how consistently that would work.
Does this still work for you on iOS17/WatchOS10? I didn’t have the previos versions as I am new in Apple ecosystem, but the blueprint is sending notification to watch via notify mobile app, but the watch are not integrated via mobile app. I have the HA companion app installed.
It still works. As above, just make sure that your device name in the companion app matches the part after mobile_app_. So, if you go to Developer tools > Services, and try to find your phone’s notify service, like notify.mobile_app_jiris_iphone, then change your phone’s device name in the companion app settings to jiris_iphone.
I found one issue - when an iPhone is unlocked - the notification pops up on the phone instead of the watch. Moreover, if I tap on that notification on the phone - nothing happens - there’s no Confirm/Dismiss popup.
As far as I can tell - sourceDeviceName in the Companion app action is the same as my phone’s device name. So it kind’a makes sense that phone gets that notification first when unlocked.
The biggest issue here is that I can’t confirm the action when notification intercepted by the phone
Is there a theoretical possibility to assign a unique device name to a watch, to use it as sourceDeviceName in the event, but to also be able to dispatch a notification to it?
I can probably edit an action in the Companion app settings. But it only makes sense if notify.mobile_app_{{ watch-device-name}} would work
Hi!
Great blueprint!
I’m using it confirm opening a door lock, but the lock opens before the elapsed time and before the confirmation, if I confirm it opens again.
Some help please
Thanks
Hey @wtadler I really like this blueprint and I use it for a all my Watch Action however, it seems the latest update has broken the blueprint.
I get the following error “Error while excucing autiomation “action”: Template rendered invalid service: notifty.mobile_app_Apple Watch”
It seems like sourcedevicename is coming back as “Apple Watch” but this is very strange as the watch isn’t listed as a device anywhere in HA that I can find.
Is anyone else having this issue with the latest update?
Still works for me after updating HA core and my iOS app. See the above discussion about device names. I think you might also just have a typo in your code (I see “notifty” in your error)
Hi @wtadler I too am getting this error as @harold_boom did. After the last update I’m getting this error:
The automation “Åben/luk Garageport 1” (automation.aben_luk_garageport_1 ) has an action that calls an unknown service: notify.mobile_app_apple_watch .
@harold_boom , @Nick_V I started to have the same issue recently. Error: Template rendered invalid service: notify.mobile_app_Apple Watch
Seems like when an event is fired from Apple Watch, its sourceDeviceID and sourceDeviceName are always apple_watch and Apple Watch respectively and are independent of actual apple watch name set via iPhone’s Watch app.
Here’s the event fired from the watch (I removed UUIDs):
Weirdly enough, when event is triggered from my wife’s watch - it comes with her iPhone device name and ID. Our iPhones and Apple Watches are updated to the same latest versions: 17.5.1 iOS, 10.5 Apple Watch
Update: turned out that my wife is running iOS Home Assistant app of v2024.5.1, while I haven’t updated to that version
Apparently 2024.5.1 version fixes this issue, according to the change log. I confirmed that the issue is gone after the update