HTML5 action automation

I’m trying to automate an HTML5 action but I’m not sure how to access my custom parameters inside of the data object parameter.

I’m assuming it’s something like “trigger.to_state.attributes.actions” but I haven’t been able to figure out the exact format.

Can anyone lend a hand?

Anyone know how I can get those parameters?

Additional context that might help…

Within the trigger I am accessing that information like so:

alias: HTML5 push notification action button clicked
trigger:
  platform: event
  event_type: html5_notification.clicked
  event_data:
    action: manual_action

But there are additional parameters within the event_data I would like to customize the action for this automation.

Seem to be getting closer.

  - alias: HTML5 push notification action button clicked
trigger:
  platform: event
  event_type: html5_notification.clicked
  event_data:
    action: manual_action
action:
  - service: notify.slacknotify
    data_template:
      message: >
        event: {{ trigger.event }}

This will spit out the event but it looks like:

<Event html5_notification.clicked[L]: data=secureAction=lock, entityName=lock.front_door, entityType=lock, tag=4c96a5bd-3e4b-4441-baf0-e8118256c5d0, type=clicked, target=unnamed device_2, action=manual_action>

so the common json templating doesn’t seem to work.

Thoughts?

I was able to figure this out.

trigger.event.data gave me:

{'data': {'secureAction': 'lock', 'entityName': 'lock.front_door', 'entityType': 'lock'}, 'tag': 'd276eaf5-1124-4363-9845-98d07e02b7db', 'type': 'clicked', 'target': 'unnamed device_2', 'action': 'manual_action'}

so trigger.event.data.data[“entityType”] etc was the trick.

so now my automation looks like:

  - alias: HTML5 push notification action button clicked
    trigger:
      platform: event
      event_type: html5_notification.clicked
      event_data:
        action: manual_action
    action:
      service_template: >
       {{ trigger.event.data.data["entityType"] }}.{{ trigger.event.data.data["secureAction"] }}
      data_template:
        entity_id: >
         {{ trigger.event.data.data["entityName"] }}

This is all tied to an appdaemon app that I’ve modified to send alerts when entities go into certain states (think door lock or garage door) – It’s been written to be generic so each instance of the app can be customized for different component/entity types.I then pass in the relevant data to create an HTML5 notification action that allows me to quickly secure the entity (lock the door or close the garage) from the notification on my phone or desktop.

Here is a desktop example (the “Secure” button at the bottom is the custom action):

6 Likes

You are my absolute, absolute life-saver! In fact, I signed up for an account on hassio so that I could post this comment. I was stuck at trigger.event for SO, SO, SOOOOO long. I saw my data there, but I didn’t know how to get the data out for usage. Thanks a bunch, bunch, bunch, for this finding! Cheers!

1 Like

Hi kylerw.

This looks awesome! But… My limited skills…

Im trying to do same as you, for my garage door. Would be fantastic to be able to close the garage door right from the notification. This is the only solid thing I can find on actionable HTML5 notifications.

Would it be possible for you to elaborate a bit on the steps for setting this up? Would be greatly appreciated.

Thank you!