Folder watcher (Watchdog) component

Quite a lot of applications create temporary files during normal operation, this could be causing all the triggers. You could us the patterns variable to try limit the number of triggers

How d’you mean? isn’t the trigger caused by the file referred to as “”? If so, surely any temporary file would be the one that is sent, not the one I copied?

I tried to add a shell command straight after in the automation to delete the file. This resulted in multiple copies of half a file coming through on Telegram (bottom half of image blank) and then an error in the logs saying it couldn’t send because the file didn’t exist.

Oh I think I got your issue confused with another on this thread. You can disable automations temporarily (there is a thread on the forums somehwere), but my experience is that getting the timing just right is quite tricky

Should imagine it is. It still doesn’t explain why I get the same image multiple times though; the fact is that the jpg folder watcher is looking for gets created once, so why should I get repeated triggers?!

Something not right.

Just tried the ‘Modified’ event type and if I rename a file that’s already in there I get one message, so expected behaviour. If I leave it set to modified and upload a file though the same problem occurs.

Tried Samba, FTP connection from PC and from camera and still getting multiple triggers. Strange thing is there’s no pattern to how many triggers I get. Sometime 4-5, others a few hundred.

I had similar problem due to “temp” file triggering before complete file was generated.
I just added delay of couple of seconds to my automation.

Got it working! Turns out it’s very funny about the way the YAML is laid out.


  - event_data:
        event_type: created
    event_type: folder_watcher
    platform: event


    platform: event
    event_type: folder_watcher
      event_type: created

Did the trick. It turns out that if you don’t specify an event type to trigger on it fires on ANY event. Whilst I specified a type originally, my YAML wasn’t quite right so the event type I’d specified was ignored and default behaviour prevailed.

Where did you get the first version from? The second is in the docs

I know. I copied from the docs in the first place but dipped in with the GUI to make a couple of quick changes to the action. The GUI rearranged it all as it does which broke it. I didn’t think it would matter but it obviously does!

1 Like

I’d like to check something regarding the documentation that isn’t quite clear to me: Is the folder option relative to the HA installation’s path, or is it an absolute path? As an example, if I set - folder: /tmp/ and /tmp/ is world readable, should/would it work?

And for me relevant close to this is if it’s possible to watch a folder outside HA, like on a usb disk on a PC or NAS via Samba and smb: function?

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 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:


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:

  name: Home
  latitude: ##.######
  longitude: -##.######
  elevation: 72
  unit_system: imperial
  time_zone: America/New York
  external_url: ""
  internal_url: "http://###.###.#.###:8123"
    - /share

Basic config:

  - 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 // (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: /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.