Get confirmation before executing an iOS/watchOS action

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.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

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"
6 Likes

thank you so much for this beautiful blueprint is very useful for the apple watch work perfect

1 Like

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.

Is there anyway to fix this?

Thanks!

Actually it is a really easy fix. The blueprint just needs this line:

    - service: notify.mobile_app_{{ trigger.event.data.sourceDeviceID }}

changed to

    - service: notify.mobile_app_{{ trigger.event.data.sourceDeviceName }}

Yep, that’s right, thank you. I edited the original post.

I get the following error in trace:

Error: Template rendered invalid service: notify.mobile_app_Redacted’s iPhone

I suppose this is because my notify service is called notify.redacteds_iphone but the sourceDeviceName is “Redacted’s iPhone”

I got it manually working by hardcoding in my proper notify name, but wondering what I am doing wrong.

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.

Oh, I somehow skipped the post about this. Now I feel like an idiot😁

Thanks man!

This is super useful! I’m using your blueprint to confirm garage door activation

1 Like

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

What if you hold on the iPhone banner notification rather than tap it? I am able to hit “Confirm” when I do that.

It worked this way. Thank you

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

I’m not sure if you can separate the watch and iPhone! You might want to ask in the iOS channel in the HA Discord.

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 .

I guess something must have changed?

@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):

event_type: ios.action_fired
data:
  actionID: actuate garage door
  actionName: actuate garage door
  sourceDeviceID: apple_watch
  sourceDeviceName: Apple Watch
  sourceDevicePermanentID: ...
  triggerSource: watch
origin: REMOTE
time_fired: "2024-06-06T16:02:10.223811+00:00"
context:
  id: ...
  parent_id: null
  user_id: ...

Here’s the same event fired from the phone (Home Assistant app > Settings > Companion App > Actions):

event_type: ios.action_fired
data:
  actionID: actuate garage door
  actionName: actuate garage door
  sourceDeviceID: n6ham
  sourceDeviceName: N6HAM
  sourceDevicePermanentID: ...
  triggerSource: preview
origin: REMOTE
time_fired: "2024-06-06T16:06:11.921124+00:00"
context:
  id: ...
  parent_id: null
  user_id: ...

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