Help: Syntax issue with Script

I am trying to create a script to notify a mobile phone when the alarm is triggered, this script takes a message variable from the calling automation and has two options 1. to disable the alarm and 2. to look at the cameras. Both of which lead to lovelace pages.

I am getting an error: “Actions: extra keys not allowed @ data[0][‘variables’]”

Can anyone spot the mistake and suggest corrections please? Thank you!

  mobile_new_notify:
    alias: Mobile Notify me
    description: announcements to my mobile
    sequence:
      variables:
        action_1: '{{ ''1_'' ~ context.id }}'
        action_2: '{{ ''2_'' ~ context.id }}'
      service: notify.mobile_app_x_phone
      data:
        message: '{{ message }}'
        data:
          actions:
            - action: '{{ action_1 }}'
              title: Disable Alarm
            - action: '{{ action_2 }}'
              title: View Cameras
      wait_for_trigger:
        - platform: event
          event_type: mobile_app_notification_action
          event_data:
            action: '{{ action_1 }}'
        - platform: event
          event_type: mobile_app_notification_action
          event_data:
            action: '{{ action_2 }}'
      choose:
        - conditions: '{{ wait.trigger.event.data.action == action_1 }}'
          sequence:
            - action: URI
              title: View More
              uri: /dashboard-sec/Security
        - conditions: '{{ wait.trigger.event.data.action == action_2 }}'
          sequence:
            - action: URI
              title: View More
              uri: /lovelace-test/cameras

The error is due to the fact all actions in your script lack a leading hyphen.

mobile_new_notify:
    alias: Mobile Notify me
    description: announcements to my mobile
    sequence:
      - variables:
          action_1: '{{ ''1_'' ~ context.id }}'
          action_2: '{{ ''2_'' ~ context.id }}'
      - service: notify.mobile_app_x_phone
        data:
          message: '{{ message }}'
          data:
            actions:
              - action: '{{ action_1 }}'
                title: Disable Alarm
              - action: '{{ action_2 }}'
                title: View Cameras
      - wait_for_trigger:
          - platform: event
            event_type: mobile_app_notification_action
            event_data:
              action: '{{ action_1 }}'
          - platform: event
            event_type: mobile_app_notification_action
            event_data:
              action: '{{ action_2 }}'
      - choose:
          - conditions: '{{ wait.trigger.event.data.action == action_1 }}'
            sequence:
              - action: URI
                title: View More
                uri: /dashboard-sec/Security
          - conditions: '{{ wait.trigger.event.data.action == action_2 }}'
            sequence:
              - action: URI
                title: View More
                uri: /lovelace-test/cameras

I knew it was something simple, thanks Taras… :sweat_smile:

You’re welcome!

However, you have marked your own post with the Solution tag. The custom of this community forum is to mark the post that contains the actual answer to the question.

For more information, refer to guideline 21 (Somebody’s answer solved it!) in the FAQ.

My bad, hopefully now fixed… thanks again

1 Like