Need help properly configuring notify.html5 events & shell_command actions

I’m trying to set up html5 notifications to alert me whenever a new device accesses my network. With the notification I want to include a button “Block Device” that would give me the option to kick the device from my network. I’m not sure how to accomplish this since I’m using a shell_command to call a custom python script, which requires a mac address to block the device. I have access to the mac address in the initial event device_tracker_new_device, but I’m not sure how to access the mac address in the callback automation reacting to the event html5_notification.click. This is the event that calls the shell_command.

How can I access the trigger.event.data from the initial automation at the top of the event chain? Is it possible to pass this data from the second automation to the shell_command?

Below is what I currently have, I’m not sure if I’m doing it right.

- alias: Notify If New Device Accesses Network
  trigger:
    - platform: event
      event_type: device_tracker_new_device
  action:
    - service: notify.html5
      data_template:
        message: >
          A new device has accessed your network:
          {{trigger.event.data.host_name}}
          ({{trigger.event.data.entity_id}})
        title: New device
        actions:
        - action: block_device
          title: Block Device

- alias: Block New Device
  trigger:
    platform: event
    event_type: html5_notification.clicked
    event_data:
      action: block_device
  action:
    service: shell_command.block_device

#In configuration.yaml
shell_command:
  block_device: python /python_scripts/manage_devices.py {trigger.event.data.mac}

Ok, I think I figured it out with the help of this post to pass a variable to the shell_command and this post to access the calling automation’s data instead of the current automation’s data.

Can anyone tell me if this is the correct way to do this?

- alias: Notify If New Device Accesses Network
  trigger:
    - platform: event
      event_type: device_tracker_new_device
  action:
    - service: notify.html5
      data_template:
        message: >
          A new device has accessed your network:
          {{ trigger.event.data.host_name }}
          ({{ trigger.event.data.entity_id }})
        title: New device
        actions:
        - action: block_device
          title: Block Device

- alias: Block New Device
  trigger:
    platform: event
    event_type: html5_notification.clicked
    event_data:
      action: block_device
  action:
    service: shell_command.block_device
    data_template:
      value: >
        {{ trigger.event.data.data["mac"] }}

#In configuration.yaml
shell_command:
  block_device: 'python /python_scripts/manage_devices.py Block {{ value }}'