Correct errors in folder_watcher doc (#5168)

* Correct errors

Corrects errors identified by @dale3h in https://github.com/home-assistant/home-assistant.github.io/pull/4885

* Adds event_type info

* Add info on recursive monitoring
This commit is contained in:
Robin 2018-04-14 08:52:36 +01:00 committed by Franck Nijhof
parent d6b1ac2262
commit 3f43547c0e

View File

@ -13,16 +13,23 @@ ha_iot_class: "Local Polling"
ha_release: 0.67 ha_release: 0.67
--- ---
This component adds [Watchdog](https://pythonhosted.org/watchdog/) file system monitoring, publishing events on the Home-Assistant bus on the creation/deletion/modification of files. This component adds [Watchdog](https://pythonhosted.org/watchdog/) file system monitoring, publishing events on the Home Assistant bus on the creation/deletion/modification of files. The monitored `event_type` are:
* `created`
* `deleted`
* `modified`
* `moved`
To configure the `folder_watcher` component add to you `configuration.yaml` file: Note that by default folder monitoring is recursive, meaning that the contents of sub-folders are also monitored.
To enable the Folder Watcher component in your installation, add the following to your `configuration.yaml` file:
```yaml
{% raw %} {% raw %}
```yaml
folder_watcher: folder_watcher:
- folder: /config watchers:
{% endraw %} - folder: /config
``` ```
{% endraw %}
{% configuration %} {% configuration %}
folder: folder:
@ -40,28 +47,29 @@ patterns:
Pattern matching using [fnmatch](https://docs.python.org/3.6/library/fnmatch.html) can be used to limit filesystem monitoring to only files which match the configured patterns. The following example shows the configuration required to only monitor filetypes `.yaml` and `.txt`. Pattern matching using [fnmatch](https://docs.python.org/3.6/library/fnmatch.html) can be used to limit filesystem monitoring to only files which match the configured patterns. The following example shows the configuration required to only monitor filetypes `.yaml` and `.txt`.
{% raw %}
```yaml ```yaml
{% raw %}
folder_watcher: folder_watcher:
- folder: /config watchers:
patterns: - folder: /config
- '*.yaml' patterns:
- '*.txt' - '*.yaml'
{% raw %} - '*.txt'
``` ```
{% endraw %}
## Automations ## Automations
Automations can be triggered on filesystem event data using a data_template. The following automation will send a notification with the name and folder of new files added to that folder: Automations can be triggered on filesystem event data using a `data_template`. The following automation will send a notification with the name and folder of new files added to that folder:
```yaml
{% raw %} {% raw %}
```yaml
- action: - action:
- data_template: - data_template:
message: 'Created {{trigger.event.data.file}} in {{trigger.event.data.folder}}' message: 'Created {{ trigger.event.data.file }} in {{ trigger.event.data.folder }}'
title: New image captured! title: New image captured!
data: data:
file: "{{trigger.event.data.path}}" file: " {{ trigger.event.data.path }} "
service: notify.pushbullet service: notify.pushbullet
alias: New file alert alias: New file alert
condition: [] condition: []
@ -70,6 +78,5 @@ Automations can be triggered on filesystem event data using a data_template. The
- event_data: {"event_type":"created"} - event_data: {"event_type":"created"}
event_type: folder_watcher event_type: folder_watcher
platform: event platform: event
{% endraw %}
``` ```
{% endraw %}