Actionable iOS notifications that return a text entry

I am trying to implement an actionable iOS notification that is triggered by an automation to arm my alarm when we leave. In this example, my alarm requires a pin to be entered to arm it.

I have the iOS Push notification setup as follows and this works correctly.

ios:
  push:
    categories:
      - name:  Arm House Alarm
        identifier: 'arm_alarm'
        actions:
          - identifier: 'CONFIRM_ARMING'
            title: 'Activate Alarm'
            activationMode: 'background'
            authenticationRequired: yes
            destructive: yes
            behavior: 'textInput'
            textInputButtonTitle: 'Enter Code:'
            textInputPlaceholder: ''
          - identifier: 'IGNORE_ARMING'
            title: 'Ignore Alarm Activation'
            activationMode: 'background'
            authenticationRequired: no
            destructive: no
            behavior: 'default'

I then have the following request automation configured:

- id: ACTIONABLE_REQ-001 
  alias:  Actionable Request - Request alarm to be enabled as nobody is home.
  trigger:
  - entity_id: binary_sensor.people_home
    platform: state
    to: 'off'
    for:
      minutes: 5
  action:
    service: notify.ios_user1_iphone
    data:
      message: "Nobody is home. Would you like to turn on the alarm?"
      data:
        push:
          category: "arm_alarm"

Now this is where I get confused. I am assuming I need a separate automation to listen for the iOS push notification response (that contains the pin code that was entered into the push notification request) to then use to arm the alarm. So, with that concept in mind, I then have this separate automation waiting for a response:

- id: ACTIONABLE_RESP-001
  alias: Actionable Response - Receive arm request with pin and activate accordingly
  trigger:
    platform: event
    event_type: ios.notification_action_fired
    event_data:
      actionName: arm_alarm
  action:
  - alias: Turn on Alarm
    service: alarm_control_panel.alarm_arm_home
    data:
      entity_id: alarm_control_panel.nx584
      code: '{{ ios.notification_action_fired.action_data }}'

This however does not do what I expect it to do and the alarm does not arm.

Am I going about this the right way? I cannot find any examples of actionable iOS notifications that request a text entry (e.g. a pin code), that can then be used by an action in the automation.

Thanks!

Got this sorted myself. The key is this bit which grabs the pin code entered into the textInput field in the push notification and uses it in the disarm sequence:

  action:
  - alias: Turn off Alarm
    data_template:
      code: '{{ trigger.event.data["textInput"] }}'
      entity_id: alarm_control_panel.nx584
    service: alarm_control_panel.alarm_disarm

Hope it helps someone as this is not something I could find documented anywhere.

For anyone else that has the Networx NX/Hills Reliance series alarm panel and is looking to integrate this into HA…then I’ve done the hard work for you by running it through it’s paces. See doco here: https://github.com/kk7ds/pynx584/wiki

3 Likes

I tried using your solution, but it did not work for my automation. The only difference may be, I am using automation editor, but shouldn’t matter I believe.
Can you confirm if this [quote=“Pre10der, post:2, topic:36318”]
trigger.event.data[“textInput”]
[/quote] still works or Home assistant has changed since you implemented this?

figured out that I was not using data_template :crazy_face:
Thank you for your post this helped me solve my issues. I am adding this documentation link that might help someone else https://www.home-assistant.io/docs/automation/templating/.

1 Like