Folder Watcher


This component adds 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

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:

folder_watcher:
  - folder: /config

Configuration Variables

folder

(string)(Required)The folder path

patterns

(string)(Optional)Pattern matching to apply

Default value: *

Patterns

Pattern matching using fnmatch 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.

folder_watcher:
  - folder: /config
    patterns:
      - '*.yaml'
      - '*.txt'

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:

- action:
  - data_template:
      message: 'Created {{ trigger.event.data.file }} in {{ trigger.event.data.folder }}'
      title: New image captured!
      data:
        file: " {{ trigger.event.data.path }} "
    service: notify.pushbullet
  alias: New file alert
  condition: []
  id: '1520092824697'
  trigger:
  - event_data: {"event_type":"created"}
    event_type: folder_watcher
    platform: event