Get confirmation before executing an iOS/watchOS action

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"
5 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.