Folder watcher (Watchdog) component

cannot watch external locations, although you could install home assistant on the external location and use it

1 Like

Thats an idea of course. Thanks!!
I did find this software https://directorymonitor.com/ so I will try that first :slight_smile:

Sounded interesting until I saw $159 USD for 1 machine license :money_mouth_face:

They can for sure keep track of directories (even in the free version) but I have a need to keep track of a COPY being ready and that they cant do. Only create and the other things, but not Copy. :frowning:

@robmarkcole Looks like a cool component, but I’m getting errors when setting this up. The config comes up clean when I check config via Server Controls.

Here are the log errors and my configs:

Logs:

2020-09-08 10:09:09 ERROR (SyncWorker_2) [homeassistant.components.folder_watcher] folder /share is not valid or allowed
2020-09-08 10:09:10 INFO (MainThread) [homeassistant.setup] Setup of domain folder_watcher took 0.6 seconds
2020-09-08 10:09:10 ERROR (MainThread) [homeassistant.setup] Setup failed for folder_watcher: Integration failed to initialize.

"/share" directory added to [allowlist_external_dirs:

homeassistant:
  name: Home
  latitude: ##.######
  longitude: -##.######
  elevation: 72
  unit_system: imperial
  time_zone: America/New York
  external_url: "https://########################.ui.nabu.casa/lovelace/home"
  internal_url: "http://###.###.#.###:8123"
  allowlist_external_dirs:
    - /share

Basic config:

folder_watcher:
  - folder: /share

Ah docker… The error is folder /share is not valid or allowed
Recommend some experimentation

@robmarkcole ok - so this folder is located at //192.168.1.237/share (my HA IP), along with my /config folder and a few others I can’t recall - /add ons I think?. I have swapped out /share with /config and get the same results - no dice. What sort of experimentation would you recommend?

I think the issue is that /share is not accessible to the home assistant user. Better to create a subdirectory in /config and watch that as per the docs example. So you will have config like:

folder_watcher:
  - folder: /config/my_watched_dir

@robmarkcole Unfortunately, no dice :thinking:

I updated the config, restarted HA from the UI, and for good measure, I also restarted the VM to make sure the allowlist_external_dirs gets updated, and I still get the same error in the logs:

2020-09-09 15:21:33 ERROR (SyncWorker_38) [homeassistant.components.folder_watcher] folder /config/folder_watcher is not valid or allowed
2020-09-09 15:21:34 INFO (MainThread) [homeassistant.setup] Setup of domain folder_watcher took 0.1 seconds
2020-09-09 15:21:34 ERROR (MainThread) [homeassistant.setup] Setup failed for folder_watcher: Integration failed to initialize.

Must be a permissions thing. Best bet is to login as the home assistant user and check what can be accessed, and update permissions accordingly

This is probably almost certainly me being dense - but log in where as the HA user? I am always logged into HA via the UI and can access all these folders via a Samba share (from a separate windows machine).

Are you saying inspect the permissions via this separate windows machine via the Samba share? Stick with me, I’ll get there! :slight_smile:

You are running in docker right? see here

As I understand it, it’s technically docker, but I am running HassIO - so the CLI is limited to HassIO commands apparently - so I don’t think I can SSH into the container. I don’t do it often, since I manage my config via the Samba share + VSC on another Windows machine, but I do have the SSH & Web terminal addon, and I can ls there and see my folders. But still can’t run docker commands from there. :frowning:

Suggest asking on the discord HassIO channel how to do this.
All I can say is that I previously used folder watcher on hassio, and on the share folder for that matter, see here

ok will do - thanks for the assistance.

1 Like

I can’t setup folder_watcher but I really can’t understand what I am doing wrong.
In configuration.yaml appended:

device_tracker:
  - platform: ping
    hosts:
      pping_m20: 192.168.1.119
      pping_s10: 192.168.1.121

display:
  - platform: fully_kiosk
    name: Kitchen Tablet
    host: 192.168.1.58
    password: 123456789

mobile_app:

tts:
  - platform: google_translate
    base_url: http://192.168.1.6:8123
    service_name: google_say

folder_watcher:
  - folder: /home/homeassistant/.homeassistant/cml
    patterns:
      - 'cml.gif'

The same way as I include other integrations (tts, mobile_app, display).
But the “folder_watcher” one seems to be ignored.

In the boot log I can’t find any reference to folder_watcher.
In the “event” page, I can’t subscribe to folder_watcher event (I can’t find one).
I obviously can’t create an automation, since it won’t be validated as the trigger part is invalid.

My HA runs in a python virtual enviroment.
Version 0.118.2

What am I missing?

Have you checked your logs?

Have you done this?

Configured folders must be added to allowlist_external_dirs. Note that by default folder monitoring is recursive, meaning that the contents of sub-folders are also monitored.

allowlist_external_dirs is correctly configured (as I am able to send a gif on this folder via telegram in an HA automation).

Logs? Absolutely nothing relevant. No mention to “folder_watcher”. It seems silly, I understand. But I already double checked that configuration.yaml is correct. (e.g. if I use a wrong intendation, the file is not valid for HA).

Since I am in a virtual env, am I suppose to install anything else with pip?

Have you tried enabling any debug logs?

Maybe also check permissions. If there are any children directories with problematic permissions then the integration will fail (it recurses by default).

I ran into this as an issue trying to watch /tmp/. But, if that’s the case you should see an error. For my case, there is no solution if I wanted to use this integration and monitor /tmp/ so I went for a combination of the folder integration (built-in) and creating an automation to trigger if the number of files has changed. There’s also a 3rd party files integration you can install via HACS. Just posing these as alternatives.

It shouldn’t be necessary to install anything else via pip and running in a venv should work fine (my HA runs in a venv).

Hi everyone, I’m running HomeAssistantCore in Docker on the same RPi 4 that i’m using to run an OpenMediaVault NAS. I would like to trigger an automation whenever a specific folder gets modified. I tried to include this component using the path of the folder I chose (/srv/dev-disk-by-label-Nas4TB/Shared), but if I check my configuration I get
Not a directory @ data['allowlist_external_dirs'][0] Invalid config for [folder_watcher]: not a directory for dictionary value @ data['folder_watcher'][0]['folder']. Got '/srv/dev-disk-by-label-Nas4TB/Comune/'. (See /config/configuration.yaml, line 29).
I think this is because I’m working in docker. How can I set my config to work as I would like?
Thank you.