@@ -109,32 +109,22 @@ Assuming the previous test completed successfully and your browser was registere
109
109
The `html5` platform accepts a standard notify payload. However, there are also
110
110
some special features built in which you can control in the payload.
111
111
112
- Any JSON examples below can be [converted to YAML](https://www.json2yaml.com/)
113
- for automations.
114
112
115
113
# ### {% linkable_title Actions %}
116
114
117
115
Chrome supports notification actions,
118
116
which are configurable buttons that arrive with the notification and can cause
119
117
actions on Home Assistant to happen when pressed. You can send up to 2 actions.
120
118
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
138
128
` ` `
139
129
140
130
# ### {% linkable_title Data %}
@@ -144,14 +134,11 @@ the HTML5 notification (`actions`, `badge`, `body`, `dir`, `icon`, `image`,
144
134
` lang` , `renotify`, `requireInteraction`, `tag`, `timestamp`, `vibrate`) will be
145
135
sent back to you in the [callback events](#automating-notification-events).
146
136
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
155
142
` ` `
156
143
157
144
# ### {% linkable_title Tag %}
@@ -162,14 +149,12 @@ a specific target. If you pass your own tag in the notify payload you can
162
149
replace the notification by sending another notification with the same tag.
163
150
You can provide a `tag` like so :
164
151
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
+
173
158
` ` `
174
159
175
160
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
195
180
will be sent to all registered targets as listed in
196
181
`html5_push_registrations.conf`. You can provide a `target` parameter like so :
197
182
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
204
187
` ` `
205
188
206
189
`target` can also be a string array of targets like so :
207
190
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
214
197
` ` `
215
198
216
199
# ### {% linkable_title Overrides %}
@@ -226,14 +209,11 @@ maximum icon size for an action button is 128px by 128px.
226
209
You can provide a URL to open when the notification is clicked by putting `url`
227
210
in the data dictionary like so :
228
211
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
237
217
` ` `
238
218
239
219
If no URL or actions are provided, interacting with a notification will open
0 commit comments