Automation Action for Apple Watch IOS

i have created an action named OS lights on’ on my app so i can see it in the apple watch.
i have then added the config below to my configuration to turn on lights (in this test only one light)

automation:

  • alias: ‘IOS Lights on’
    initial_state: ‘false’
    trigger:
    • platform: event
      event_type: ios.action_fired
      event_data:
      actionName: ‘IOS lights on’
    • action:
      service: light.turn_on
      entity_id: light.sonos_lamp_zetel_living

but there is some error, but i’m not seeing the error.
when saving the configuration i get the following error:
Invalid config for [automation]: required key not provided @ data[‘action’]. Got None
required key not provided @ data[‘trigger’][1][‘platform’]. Got None. (See /config/configuration.yaml, line 45). Please check the docs at https://home-assistant.io/integrations/automation/

anyone that sees what is wrong? when i remove my automation part, the problem is solved.

nevermind. i managed to solve it in Node-Red using the all events trigger on ios.action_fired and then checking with a switch for the value of payload.event.actionName to see which action was triggered. so solved in Node-red instead of the configuration-file.

If you want to use it in YAML, you need to put the action under automation not under trigger, like this:

automation:
  alias: 'IOS Lights on'
  initial_state: false
  trigger:
    platform: event
    event_type: ios.action_fired
    event_data:
      actionName: 'IOS lights on'
  action:
    service: light.turn_on
    entity_id: light.sonos_lamp_zetel_living
1 Like

super, thanks

Sorry to butt in, but I tried your example (with the name of the light changed to match mine) and received no errors; however, the action does not fire. Here is my config:

automation
  - alias: IOS Lights on
    initial_state: false
    trigger:
      - platform: event
        event_type: ios.action_fired
        event_data:
          actionName: IOS lights on
    action:
      service: light.turn_on
      entity_id: light.notification

I don’t think I made a format error, but it is possible. (note: I tried it with the single quotes you had, tried it with double quotes, and with no quotes as pictured here) I can run the action in Home Assistant through the Developer page, but I only get beeps when I try it on my watch. Any advice how I can get it to work from my watch?

My first guess is either the event_type or actionName. I personally use ios.notification_action_fired in my automations and a string which looks like a constant, but isn’t, as the actionName (as can be seen below in my example).

The automation you posted is only a part of the entire flow, so maybe there’s something wrong in another part.

I made an actionable notification for when my alarm is armed (it shows up on my Apple Watch or other iOS device).

This is the service which is called when my alarm is armed:

service: notify.ios
data:
  title: Alarm armed
  message: The alarm has been activated!
  data:
    push:
      category: alarm_armed
      thread-id: notification-alarm-armed
      badge: 0

The category which belongs to this notification (which gives the ability on your Apple Watch to select ‘Disarm alarm’):

ios:
  push:
    categories:
      - name: Alarm armed
        identifier: alarm_armed
        actions:
          - identifier: ALARM_DISARM
            title: Disarm alarm
            authenticationRequired: true

And the automation which is triggered when ‘Disarm alarm’ has been selected on the Apple Watch (or any other iOS device like an iPhone):

alias: turn_alarm_off
trigger:
  platform: event
  event_type: ios.notification_action_fired
  event_data:
    actionName: ALARM_DISARM
action:
  # whatever you want to do in this action.

Thank you! I appreciate the guidance. I will take this and push forward.

Hi everyone!! Can anybody tell if iOS actions can be shared with other users too?

Nobody? is it at least possible to export the actions somehow?

thanks

I’m not at home for the moment, so I can’t export or give much details.

But for my iOS actions, I manually created the action in the app configuration of both me and my wife.

And then I use node red to capture the iOS action event and launch the correct actions

1 Like

@Tom_Rubbens thanks for your detailed answer. I think I failed to convey my message. Sorry about that.

I too have managed to configure my iOS devices, and I’m able to trigger actions already from my iPhone and Apple Watch. And I love it.

My question is: my wife too needs to switch on the lights etc but I feel I need to configure the actions on her iOS devices from scratch, unless I’m able to take that configuration into the yaml (so that it is available for any user) or at least export my current actions and easily import them into my wife’s devices.

I did configure the actions from scratch on each iOS device using it. So, I’m afraid I don’t have a solution for you…
Interested if somebody has a solution. Because it can help me too.

Wow no answers here but didnt realize these actions also show up as Home screen ‘quick actions’ which is at least something else I learned today.