Skip to content

Commit 58f6d50

Browse files
committed
Minor changes and fixes
1 parent 27d5d74 commit 58f6d50

File tree

1 file changed

+32
-66
lines changed

1 file changed

+32
-66
lines changed

source/_components/notify.html5.markdown

Lines changed: 32 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@ ha_category: Notifications
1212
ha_release: 0.27
1313
---
1414

15-
The `html5` notification platform enables you to receive push notifications to
16-
Chrome or Firefox, no matter where you are in the world. `html5` also supports
17-
Chrome and Firefox on Android, which enables native-app-like integrations
18-
without actually needing a native app.
15+
The `html5` notification platform enables you to receive push notifications to Chrome or Firefox, no matter where you are in the world. `html5` also supports Chrome and Firefox on Android, which enables native-app-like integrations without actually needing a native app.
1916

2017
<p class='note'>
2118
HTML5 push notifications **do not** work on iOS.
2219
</p>
2320

24-
To enable this platform,
25-
add the following lines to your `configuration.yaml` file:
21+
## {% linkable_title Configuration %}
22+
23+
To enable this platform, add the following lines to your `configuration.yaml` file:
2624

2725
```yaml
2826
# Example configuration.yaml entry
@@ -51,23 +49,23 @@ gcm_sender_id:
5149

5250
### {% linkable_title Getting ready for Chrome %}
5351

54-
1. Make sure you can access your Home Assistant installation from outside your network over https ([see docs](/docs/configuration/remote/)).
52+
1. Make sure you can access your Home Assistant installation from outside your network over HTTPS ([see docs](/docs/configuration/remote/)).
5553
2. Create a new project at [https://console.cloud.google.com/home/dashboard](https://console.cloud.google.com/home/dashboard).
5654
3. Go to [https://console.cloud.google.com/apis/credentials/domainverification](https://console.cloud.google.com/apis/credentials/domainverification) and verify your domain via Google Webmaster Central / Search Console - [instructions](#verify-your-domain).
57-
4. With the domain verified, go to [https://console.firebase.google.com](https://console.firebase.google.com), select import Google project, and select the project you created.
55+
4. With the domain verified, go to [https://console.firebase.google.com](https://console.firebase.google.com), select import Google project and select the project you created.
5856
5. Then, click the cogwheel on top left and select "Project settings".
5957
6. Select 'Cloud Messaging' tab, listed beneath Project Credentials will be your 152 character 'Server Key' and 12 digit ID 'Sender ID' you need for configuring this component.
6058

6159
#### {% linkable_title Verify your domain %}
6260

63-
Follow these steps to verify domain ownership with Google Webmaster Central / Search Console:
64-
1. Enter your domain and add **'/local'** at the end, ie. https://example.com:8123/local
61+
Follow these steps to verify domain ownership with Google Webmaster Central/Search Console:
62+
1. Enter your domain and add `/local` at the end, e.g., `https://example.com:8123/local`
6563
2. Select HTML file verification and download the google*.html file.
66-
2. Create a directory named "www" in your Home Assistant configuration directory (/config share from Samba add-on).
67-
3. Place the downloaded google*.html file in the "www" directory.
68-
4. RESTART Home Assistant - this is important!
69-
5. Verify the file can be accessed in the browser, ie. **https://example.com:8123/local/google123456789.html** (change filename) - you should see a plain text message saying "google-site-verification: ..." - if you see "404: Not Found" or something else, retry the above steps.
70-
6. Go back to Google Webmaster Central / Search Console and proceed with the verification.
64+
2. Create a directory named `www` in your Home Assistant configuration directory (`/config/` share from Samba add-on).
65+
3. Place the downloaded `google*.html` file in the `www` directory.
66+
4. RESTART Home Assistant. **This is important!**
67+
5. Verify the file can be accessed in the browser, e.g., **https://example.com:8123/local/google123456789.html** (change filename). You should see a plain text message saying "google-site-verification: ...". If you see "404: Not Found" or something else, retry the above steps.
68+
6. Go back to Google Webmaster Central/Search Console and proceed with the verification.
7169

7270
### {% linkable_title Requirements %}
7371

@@ -76,11 +74,10 @@ The `html5` platform can only function if all of the following requirements are
7674
* You are using Chrome and/or Firefox on any desktop platform, ChromeOS or Android.
7775
* Your Home Assistant instance is exposed to the world.
7876
* If using a proxy, HTTP basic authentication must be off for registering or unregistering for push notifications. It can be re-enabled afterwards.
79-
* If you don't run Hass.io: `pywebpush` must be installed. `libffi-dev`, `libpython-dev`, and `libssl-dev` must be installed prior to `pywebpush` (i.e. `pywebpush` probably won't automatically install).
80-
* You have configured SSL for your Home Assistant. It doesn't need to be configured in Home Assistant though, i.e. you can be running [NGINX](/ecosystem/nginx/) in front of Home Assistant and this will still work. The certificate must be trustworthy (i.e. not self signed).
77+
* If you don't run Hass.io: `pywebpush` must be installed. `libffi-dev`, `libpython-dev` and `libssl-dev` must be installed prior to `pywebpush` (i.e. `pywebpush` probably won't automatically install).
78+
* You have configured SSL/TLS for your Home Assistant. It doesn't need to be configured in Home Assistant though, e.g., you can be running [NGINX](/ecosystem/nginx/) in front of Home Assistant and this will still work. The certificate must be trustworthy (i.e. not self signed).
8179
* You are willing to accept the notification permission in your browser.
8280

83-
8481
### {% linkable_title Setting up %}
8582

8683
Assuming you have already added the platform to your configuration:
@@ -92,7 +89,6 @@ Assuming you have already added the platform to your configuration:
9289
5. Assuming you accept, that's all there is to it!
9390
6. (Optional, but highly recommended!) Open the `html5_push_registrations.conf` file in your configuration directory. You will see a new entry for the browser you just added. Rename it from `unnamed device` to a name of your choice, which will make it easier to identify later. _Do not change anything else in this file!_ You need to restart Home Assistant after making any changes to the file.
9491

95-
9692
### {% linkable_title Testing %}
9793

9894
Assuming the previous test completed successfully and your browser was registered, you can test the notification as follows:
@@ -103,18 +99,14 @@ Assuming the previous test completed successfully and your browser was registere
10399
4. In the Service Data text box enter: {"message":"hello world"}, then press the CALL SERVICE button.
104100
5. If everything worked you should see a popup notification.
105101

106-
107102
### {% linkable_title Usage %}
108103

109-
The `html5` platform accepts a standard notify payload. However, there are also
110-
some special features built in which you can control in the payload.
104+
The `html5` platform accepts a standard notify payload. However, there are also some special features built in which you can control in the payload.
111105

112106

113107
#### {% linkable_title Actions %}
114108

115-
Chrome supports notification actions,
116-
which are configurable buttons that arrive with the notification and can cause
117-
actions on Home Assistant to happen when pressed. You can send up to 2 actions.
109+
Chrome supports notification actions, 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.
118110

119111
```yaml
120112
message: Anne has arrived home
@@ -129,10 +121,7 @@ data:
129121

130122
#### {% linkable_title Data %}
131123

132-
Any parameters that you pass in the notify payload that aren't valid for use in
133-
the HTML5 notification (`actions`, `badge`, `body`, `dir`, `icon`, `image`,
134-
`lang`, `renotify`, `requireInteraction`, `tag`, `timestamp`, `vibrate`) will be
135-
sent back to you in the [callback events](#automating-notification-events).
124+
Any parameters that you pass in the notify payload that aren't valid for use in the HTML5 notification (`actions`, `badge`, `body`, `dir`, `icon`, `image`, `lang`, `renotify`, `requireInteraction`, `tag`, `timestamp`, `vibrate`) will be sent back to you in the [callback events](#automating-notification-events).
136125

137126
```yaml
138127
title: Front door
@@ -143,23 +132,18 @@ data:
143132

144133
#### {% linkable_title Tag %}
145134

146-
By default, every notification sent has a randomly generated UUID (v4) set as
147-
its _tag_ or unique identifier. The tag is unique to the notification, _not_ to
148-
a specific target. If you pass your own tag in the notify payload you can
149-
replace the notification by sending another notification with the same tag.
150-
You can provide a `tag` like so:
135+
By default, every notification sent has a randomly generated UUID (v4) set as its _tag_ or unique identifier. The tag is unique to the notification, _not_ to 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. You can provide a `tag` like so:
151136

152137
```yaml
153138
title: Front door
154139
message: The front door is open
155140
data:
156141
tag: front-door-notification
157-
158142
```
159143

160-
Example of adding a tag to your notification. This won't create new notification
161-
if there already exists one with the same tag.
144+
Example of adding a tag to your notification. This won't create new notification if there already exists one with the same tag.
162145

146+
{% raw %}
163147
```yaml
164148
- alias: Push/update notification of sensor state with tag
165149
trigger:
@@ -168,11 +152,12 @@ if there already exists one with the same tag.
168152
action:
169153
service: notify.html5
170154
data_template:
171-
message: "Last known sensor state is {% raw %}{{ states('sensor.sensor') }}{% endraw %}."
155+
message: "Last known sensor state is {{ states('sensor.sensor') }}."
172156
data:
173157
data:
174158
tag: 'notification-about-sensor'
175159
```
160+
{% endraw %}
176161

177162
#### {% linkable_title Targets %}
178163

@@ -198,16 +183,11 @@ target:
198183

199184
#### {% linkable_title Overrides %}
200185

201-
You can pass any of the parameters listed
202-
[here](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification#Parameters)
203-
in the `data` dictionary. Please note, Chrome specifies that the maximum size
204-
for an icon is 320px by 320px, the maximum `badge` size is 96px by 96px and the
205-
maximum icon size for an action button is 128px by 128px.
186+
You can pass any of the parameters listed [here](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification#Parameters) in the `data` dictionary. Please note, Chrome specifies that the maximum size for an icon is 320px by 320px, the maximum `badge` size is 96px by 96px and the maximum icon size for an action button is 128px by 128px.
206187

207188
#### {% linkable_title URL %}
208189

209-
You can provide a URL to open when the notification is clicked by putting `url`
210-
in the data dictionary like so:
190+
You can provide a URL to open when the notification is clicked by putting `url` in the data dictionary like so:
211191

212192
```yaml
213193
title: Front door
@@ -216,15 +196,11 @@ data:
216196
url: https://google.com
217197
```
218198

219-
If no URL or actions are provided, interacting with a notification will open
220-
your Home Assistant in the browser. You can use relative URLs to refer to Home
221-
Assistant, i.e. `/map` would turn into `https://192.168.1.2:8123/map`.
199+
If no URL or actions are provided, interacting with a notification will open your Home Assistant in the browser. You can use relative URLs to refer to Home Assistant, i.e. `/map` would turn into `https://192.168.1.2:8123/map`.
222200

223201
### {% linkable_title Automating notification events %}
224202

225-
During the lifespan of a single push notification,
226-
Home Assistant will emit a few different events to the event bus which you can
227-
use to write automations against.
203+
During the lifespan of a single push notification, Home Assistant will emit a few different events to the event bus which you can use to write automations against.
228204

229205
Common event payload parameters are:
230206

@@ -236,10 +212,7 @@ Common event payload parameters are:
236212
| `target` | The target that this notification callback describes. |
237213
| `type` | The type of event callback received. Can be `received`, `clicked` or `closed`. |
238214

239-
You can use the `target` parameter to write automations against a single
240-
`target`. For more granularity,
241-
use `action` and `target` together to write automations which will do specific
242-
things based on what target clicked an action.
215+
You can use the `target` parameter to write automations against a single `target`. For more granularity, use `action` and `target` together to write automations which will do specific things based on what target clicked an action.
243216

244217
#### {% linkable_title received event %}
245218

@@ -255,9 +228,7 @@ notification is received on the device.
255228

256229
#### {% linkable_title clicked event %}
257230

258-
You will receive an event named `html5_notification.clicked` when the
259-
notification or a notification action button is clicked.
260-
The action button clicked is available as `action` in the `event_data`.
231+
You will receive an event named `html5_notification.clicked` when the notification or a notification action button is clicked. The action button clicked is available as `action` in the `event_data`.
261232

262233
```yaml
263234
- alias: HTML5 push notification clicked
@@ -279,8 +250,7 @@ or
279250

280251
#### {% linkable_title closed event %}
281252

282-
You will receive an event named `html5_notification.closed` when the
283-
notification is closed.
253+
You will receive an event named `html5_notification.closed` when the notification is closed.
284254

285255
```yaml
286256
- alias: HTML5 push notification clicked
@@ -291,10 +261,7 @@ notification is closed.
291261

292262
### {% linkable_title Making notifications work with NGINX proxy %}
293263

294-
If you use [NGINX](/ecosystem/nginx/) as a proxy with authentication in front of
295-
your Home Assistant instance,
296-
you may have trouble with receiving events back to Home Assistant.
297-
It's because of authentication token that cannot be passed through the proxy.
264+
If you use [NGINX](/ecosystem/nginx/) as a proxy with authentication in front of your Home Assistant instance, you may have trouble with receiving events back to Home Assistant. It's because of authentication token that cannot be passed through the proxy.
298265

299266
To solve the issue put additional location into your nginx site's configuration:
300267

@@ -308,8 +275,7 @@ location /api/notify.html5/callback {
308275
}
309276
```
310277

311-
This rule check if request have `Authorization` HTTP header and bypass the
312-
htpasswd (if you use one).
278+
This rule check if request have `Authorization` HTTP header and bypass the htpasswd (if you use one).
313279

314280
If you still have the problem, even with mentioned rule, try to add this code:
315281

0 commit comments

Comments
 (0)