Skip to content

Commit 5af948e

Browse files
genestealerfrenck
authored andcommitted
Converted HTML5 Push Notifications JSON examples to YAML (home-assistant#7460)
* Converted JSON to YAML * Update notify.html5.markdown
1 parent 128e148 commit 5af948e

File tree

1 file changed

+35
-55
lines changed

1 file changed

+35
-55
lines changed

source/_components/notify.html5.markdown

Lines changed: 35 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -109,32 +109,22 @@ Assuming the previous test completed successfully and your browser was registere
109109
The `html5` platform accepts a standard notify payload. However, there are also
110110
some special features built in which you can control in the payload.
111111

112-
Any JSON examples below can be [converted to YAML](https://www.json2yaml.com/)
113-
for automations.
114112

115113
#### {% linkable_title Actions %}
116114

117115
Chrome supports notification actions,
118116
which are configurable buttons that arrive with the notification and can cause
119117
actions on Home Assistant to happen when pressed. You can send up to 2 actions.
120118

121-
```json
122-
{
123-
"message": "Anne has arrived home",
124-
"data": {
125-
"actions": [
126-
{
127-
"action": "open",
128-
"icon": "/static/icons/favicon-192x192.png",
129-
"title": "Open Home Assistant"
130-
},
131-
{
132-
"action": "open_door",
133-
"title": "Open door"
134-
}
135-
]
136-
}
137-
}
119+
```yaml
120+
message: Anne has arrived home
121+
data:
122+
actions:
123+
- action: open
124+
icon: "/static/icons/favicon-192x192.png"
125+
title: Open Home Assistant
126+
- action: open_door
127+
title: Open door
138128
```
139129

140130
#### {% linkable_title Data %}
@@ -144,14 +134,11 @@ the HTML5 notification (`actions`, `badge`, `body`, `dir`, `icon`, `image`,
144134
`lang`, `renotify`, `requireInteraction`, `tag`, `timestamp`, `vibrate`) will be
145135
sent back to you in the [callback events](#automating-notification-events).
146136

147-
```json
148-
{
149-
"title": "Front door",
150-
"message": "The front door is open",
151-
"data": {
152-
"my-custom-parameter": "front-door-open"
153-
}
154-
}
137+
```yaml
138+
title: Front door
139+
message: The front door is open
140+
data:
141+
my-custom-parameter: front-door-open
155142
```
156143

157144
#### {% linkable_title Tag %}
@@ -162,14 +149,12 @@ a specific target. If you pass your own tag in the notify payload you can
162149
replace the notification by sending another notification with the same tag.
163150
You can provide a `tag` like so:
164151

165-
```json
166-
{
167-
"title": "Front door",
168-
"message": "The front door is open",
169-
"data": {
170-
"tag": "front-door-notification"
171-
}
172-
}
152+
```yaml
153+
title: Front door
154+
message: The front door is open
155+
data:
156+
tag: front-door-notification
157+
173158
```
174159

175160
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
195180
will be sent to all registered targets as listed in
196181
`html5_push_registrations.conf`. You can provide a `target` parameter like so:
197182

198-
```json
199-
{
200-
"title": "Front door",
201-
"message": "The front door is open",
202-
"target": "unnamed device"
203-
}
183+
```yaml
184+
title: Front door
185+
message: The front door is open
186+
target: unnamed device
204187
```
205188

206189
`target` can also be a string array of targets like so:
207190

208-
```json
209-
{
210-
"title": "Front door",
211-
"message": "The front door is open",
212-
"target": ["unnamed device", "unnamed device 2"]
213-
}
191+
```yaml
192+
title: Front door
193+
message: The front door is open
194+
target:
195+
- unnamed device
196+
- unnamed device 2
214197
```
215198

216199
#### {% linkable_title Overrides %}
@@ -226,14 +209,11 @@ maximum icon size for an action button is 128px by 128px.
226209
You can provide a URL to open when the notification is clicked by putting `url`
227210
in the data dictionary like so:
228211

229-
```json
230-
{
231-
"title": "Front door",
232-
"message": "The front door is open",
233-
"data": {
234-
"url": "https://google.com"
235-
}
236-
}
212+
```yaml
213+
title: Front door
214+
message: The front door is open
215+
data:
216+
url: https://google.com
237217
```
238218

239219
If no URL or actions are provided, interacting with a notification will open

0 commit comments

Comments
 (0)