Converted HTML5 Push Notifications JSON examples to YAML (#7460)

* Converted JSON to YAML

* Update notify.html5.markdown
This commit is contained in:
R Huish 2018-12-05 07:49:27 +00:00 committed by Franck Nijhof
parent 128e14809e
commit 5af948ec5d

View File

@ -109,8 +109,6 @@ Assuming the previous test completed successfully and your browser was registere
The `html5` platform accepts a standard notify payload. However, there are also The `html5` platform accepts a standard notify payload. However, there are also
some special features built in which you can control in the payload. some special features built in which you can control in the payload.
Any JSON examples below can be [converted to YAML](https://www.json2yaml.com/)
for automations.
#### {% linkable_title Actions %} #### {% linkable_title Actions %}
@ -118,23 +116,15 @@ Chrome supports notification actions,
which are configurable buttons that arrive with the notification and can cause which are configurable buttons that arrive with the notification and can cause
actions on Home Assistant to happen when pressed. You can send up to 2 actions. actions on Home Assistant to happen when pressed. You can send up to 2 actions.
```json ```yaml
{ message: Anne has arrived home
"message": "Anne has arrived home", data:
"data": { actions:
"actions": [ - action: open
{ icon: "/static/icons/favicon-192x192.png"
"action": "open", title: Open Home Assistant
"icon": "/static/icons/favicon-192x192.png", - action: open_door
"title": "Open Home Assistant" title: Open door
},
{
"action": "open_door",
"title": "Open door"
}
]
}
}
``` ```
#### {% linkable_title Data %} #### {% linkable_title Data %}
@ -144,14 +134,11 @@ the HTML5 notification (`actions`, `badge`, `body`, `dir`, `icon`, `image`,
`lang`, `renotify`, `requireInteraction`, `tag`, `timestamp`, `vibrate`) will be `lang`, `renotify`, `requireInteraction`, `tag`, `timestamp`, `vibrate`) will be
sent back to you in the [callback events](#automating-notification-events). sent back to you in the [callback events](#automating-notification-events).
```json ```yaml
{ title: Front door
"title": "Front door", message: The front door is open
"message": "The front door is open", data:
"data": { my-custom-parameter: front-door-open
"my-custom-parameter": "front-door-open"
}
}
``` ```
#### {% linkable_title Tag %} #### {% linkable_title Tag %}
@ -162,14 +149,12 @@ a specific target. If you pass your own tag in the notify payload you can
replace the notification by sending another notification with the same tag. replace the notification by sending another notification with the same tag.
You can provide a `tag` like so: You can provide a `tag` like so:
```json ```yaml
{ title: Front door
"title": "Front door", message: The front door is open
"message": "The front door is open", data:
"data": { tag: front-door-notification
"tag": "front-door-notification"
}
}
``` ```
Example of adding a tag to your notification. This won't create new notification Example of adding a tag to your notification. This won't create new notification
@ -195,22 +180,20 @@ If you do not provide a `target` parameter in the notify payload a notification
will be sent to all registered targets as listed in will be sent to all registered targets as listed in
`html5_push_registrations.conf`. You can provide a `target` parameter like so: `html5_push_registrations.conf`. You can provide a `target` parameter like so:
```json ```yaml
{ title: Front door
"title": "Front door", message: The front door is open
"message": "The front door is open", target: unnamed device
"target": "unnamed device"
}
``` ```
`target` can also be a string array of targets like so: `target` can also be a string array of targets like so:
```json ```yaml
{ title: Front door
"title": "Front door", message: The front door is open
"message": "The front door is open", target:
"target": ["unnamed device", "unnamed device 2"] - unnamed device
} - unnamed device 2
``` ```
#### {% linkable_title Overrides %} #### {% linkable_title Overrides %}
@ -226,14 +209,11 @@ maximum icon size for an action button is 128px by 128px.
You can provide a URL to open when the notification is clicked by putting `url` You can provide a URL to open when the notification is clicked by putting `url`
in the data dictionary like so: in the data dictionary like so:
```json ```yaml
{ title: Front door
"title": "Front door", message: The front door is open
"message": "The front door is open", data:
"data": { url: https://google.com
"url": "https://google.com"
}
}
``` ```
If no URL or actions are provided, interacting with a notification will open If no URL or actions are provided, interacting with a notification will open