Update downloader.markdown (#4916)

* Update downloader.markdown

Add description for new events that are emitted when download is requested.

* ✏️ Small fixes
This commit is contained in:
engrbm87 2018-03-15 01:04:01 +02:00 committed by Paulus Schoutsen
parent 3ddfa61ad5
commit 25148ef299

View File

@ -42,3 +42,29 @@ This will download the file from the given URL.
| `subdir` | yes | Download into subdirectory of **download_dir** |
| `filename` | yes | Determine the filename. |
| `overwrite` | yes | Whether to overwrite the file or not, defaults to `false`. |
### {% linkable_title Download Status Events %}
When a download finished successfully, Home Assistant will emit a 'downloader_download_completed' event to the event bus which you can use to write automations against.
In case download failed another event 'downloader_download_failed' is emitted to indicate that the download did not complete successfully.
Along with the event the following payload parameters are available:
| Parameter | Description |
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `url` | The `url` that was requested.|
| `filename` | The `name` of the file that was being downloaded.|
#### Example Automation:
```yaml
- alias: Download Failed Notification
trigger:
platform: event
event_type: downloader_download_failed
action:
service: persistent_notification.create
data_template:
message: "{{trigger.event.data.filename}} download failed"
title: "Download Failed"
```