mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
Add event entities to Folder watcher (#32611)
* Add entities to Folder watcher * Address comments * tiny tweaks --------- Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
parent
f2ffeb1d66
commit
b1bb66b32d
@ -7,11 +7,15 @@ ha_iot_class: Local Polling
|
||||
ha_config_flow: true
|
||||
ha_release: 0.67
|
||||
ha_quality_scale: internal
|
||||
ha_platforms:
|
||||
- event
|
||||
ha_domain: folder_watcher
|
||||
ha_integration_type: integration
|
||||
---
|
||||
|
||||
The **Folder watcher** {% term integration %} adds [Watchdog](https://pythonhosted.org/watchdog/) file system monitoring, publishing events on the Home Assistant bus on the creation/deletion/modification of files within configured folders. The monitored `event_type` are:
|
||||
The **Folder watcher** {% term integration %} adds [Watchdog](https://pythonhosted.org/watchdog/) file system monitoring.
|
||||
|
||||
It creates event entities for these monitored event types:
|
||||
|
||||
- `closed`
|
||||
- `created`
|
||||
@ -30,7 +34,7 @@ As example to monitor specific file, as example YAML and text-files add `*.yaml`
|
||||
|
||||
## Automations
|
||||
|
||||
The elements the events contain are:
|
||||
The attributes the event entities contain are:
|
||||
- `event_type`: matching the `event_type` of the filter (one of `created`, `moved`, `modified`, `deleted`, `closed`)
|
||||
- `path`: The full path to the file (e.g. "/hello/world.txt")
|
||||
- `file`: The name of the file (e.g. "world.txt")
|
||||
@ -41,7 +45,7 @@ When the `event_type` is `moved`, the file details are for the source file and d
|
||||
- `dest_file`: The name of the moved file (e.g. "world.txt")
|
||||
- `dest_folder`: The folder moved path (e.g. "/hello")
|
||||
|
||||
Automations can be triggered on filesystem event data using a 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 file system events data using a template. The following automation will send a notification with the name and folder of new files added to that folder:
|
||||
|
||||
{% raw %}
|
||||
|
||||
@ -50,17 +54,15 @@ Automations can be triggered on filesystem event data using a template. The foll
|
||||
automation:
|
||||
alias: "New file alert"
|
||||
trigger:
|
||||
platform: event
|
||||
event_type: folder_watcher
|
||||
event_data:
|
||||
event_type: created
|
||||
platform: state
|
||||
entity_id: event.created
|
||||
action:
|
||||
service: notify.notify
|
||||
data:
|
||||
title: New image captured!
|
||||
message: "Created {{ trigger.event.data.file }} in {{ trigger.event.data.folder }}"
|
||||
message: "Created {{ trigger.to_state.attributes.file }} in {{ trigger.to_state.attributes.folder }}"
|
||||
data:
|
||||
file: "{{ trigger.event.data.path }}"
|
||||
file: "{{ trigger.to_state.attributes.file }}"
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user