From b1bb66b32dbc9011d2f3baceb988b7f596569784 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Mon, 27 May 2024 09:23:32 +0200 Subject: [PATCH] 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> --- source/_integrations/folder_watcher.markdown | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/_integrations/folder_watcher.markdown b/source/_integrations/folder_watcher.markdown index cf7ce0a5df5..fb87d0ea979 100644 --- a/source/_integrations/folder_watcher.markdown +++ b/source/_integrations/folder_watcher.markdown @@ -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 %}