Problem with folder_watcher

hassio ho reboot serve?

I restarted every possible way

I don’t use hassio so I don’t know how best to reboot it.

finally I did work, however with the folder / backup does not work. Any idea why?

As noted by @nickrout I’ve identified an issue with whitelists on Hassio. In general I often have to reboot the pi for changes to the config to take effect

I restarted, but only problem is in /backup folder. other folder is working.

I will move the backups to another folder using shell_command, but I wanted to understand this folder does not work

Please double check your logs for relevant warnings - pretty sure you get errors if whitelist/permissions is the problem

the error (in log) is above

OK I don’t see why /backup would be giving you a problem. I’m able to monitor /share which is at the same level. My advice is that after every edit of whitelist you reboot the pi

I also can not understand, / share works, / backup as you said this at the same level, and have the same permissions

I have a different problem.

Is there anyway to exclude by pattern?

I just set this up on my device to monitor the /home/homeassistant/.homeassistant folder (which I assume is the exact same as /config in hassio) for files created. The idea being that if I add a new component and it creates a config file (feedreader.pickle for example) I can be alerted and add it to my .gitignore file before committing the changes.

Unfortunately, when I restarted, my notification service got spammed over a hundred times in the first minute with “A new file .homeassistant_v2.db-wal was created” and “A new file .homeassistant_v2.db-shm was created”(which is presumably temp files that are created on database writes) and my CPU use shot up to 100% and the frontend froze.

I need to be able to exclude these files otherwise the component is unusable for me (and probably anyone else running normal homeassistant with a standard db).

Any ideas please?

Hi @anon43302295 with this component I didn’t anticipate that people would want to monitor the root directory, but rather sub-directories where components/addons would create files. Nevetheless I can see the use case for monitoring the root now.

So as per the docs you can use the pattern [!seq] to exclude seq, as I was able to do for a simple .db filename here. However I encountered a problem when trying to exclude the HA database with '[!home-assistant_v2.db]*' and the issue appears to be the use of - in the filename. I expect with a bit more investigation this can be resolved.

Thanks for the quick reply. :+1:

I’m not near the computer at the moment but would !*[v2.db]* work? Or maybe *[!v2.db]* ?

I did have a look at those docs last night and, I’ll be honest, they may as well be in Swahili (which is probably why I’m struggling so much with trying to learn python, but that’s another story).

1 Like

Is there anyway to have two folder watcher components looking at two separate folders?

Try:

folder_watcher:
  - folder: /folder1
  - folder: /folder2

Hi. Same problem here just like Marcos_Felipe. I can watch any folder except /backup.
Both /config and /share work fine, but when I add /backup I get:

2018-11-27 16:59:37 ERROR (MainThread) [homeassistant.config] Invalid config for [folder_watcher]: not a directory for dictionary value @ data['folder_watcher'][2]['folder']. Got '/backup'. (See /config/configuration.yaml, line 98). Please check the docs at https://home-assistant.io/components/folder_watcher/

Here’s my config:

homeassistant:
  whitelist_external_dirs:
    - /config
    - /share
    - /backup

folder_watcher:
  - folder: /config
  - folder: /share
  - folder: /backup

And I’ve done all kind of possible reboots, reloads and even shutdown. Running Hass.io in Raspberry Pi. If I add it to folder_watcher it also prevents homeassistant from starting up and I get:
2018-11-27 17:10:44 ERROR (MainThread) [homeassistant.config] Invalid config for [homeassistant]: not a directory @ data['whitelist_external_dirs'][2]. Got '/backup'. (See /config/configuration.yaml, line 2).

ls -la shows backup w/o problems, at same level as /config and /share. Even tried /root/backup to avoid the symlink, but no luck.

Any help would be appreciated. Thank you!!

Permissions? Ownership? What is the output of ls -la ?

I was browsing filesystem from SSH & Web Terminal Add-on, and this is what I got with ls -la:

drwxrwxrwx    1 root     root          4096 Nov 28 09:49 .
drwxr-xr-x    1 root     root          4096 Nov 28 09:46 ..
drwxr-xr-x   11 root     root          4096 Nov  4 11:15 .oh-my-zsh
lrwxrwxrwx    1 root     root            10 Nov 28 09:47 .ssh -> /data/.ssh
-rw-rw-rw-    1 root     root          1003 Sep 29 13:24 .tmux.conf
-rw-r--r--    1 root     root         30740 Nov 28 09:49 .zcompdump-a0d7b954-ssh-5.5.1
-rw-rw-rw-    1 root     root            65 Jul 30 11:35 .zprofile
lrwxrwxrwx    1 root     root            18 Nov 28 09:47 .zsh_history -> /data/.zsh_history
-rw-r--r--    1 root     root            87 Nov 28 09:47 .zshenv
-rwxrwxrwx    1 root     root          3101 Jul 21 21:34 .zshrc
lrwxrwxrwx    1 root     root             7 Nov 28 09:47 addons -> /addons
lrwxrwxrwx    1 root     root             7 Nov 28 09:47 backup -> /backup
lrwxrwxrwx    1 root     root             7 Nov 28 09:47 config -> /config
lrwxrwxrwx    1 root     root             6 Nov 28 09:47 share -> /share
lrwxrwxrwx    1 root     root             4 Nov 28 09:47 ssl -> /ssl

BUT if I enter the container from Raspbian: sudo docker exec -it homeassistant /bin/bash
I get this:

drwxr-xr-x    1 root     root          4096 Nov 27 18:18 .
drwxr-xr-x    1 root     root          4096 Nov 27 18:18 ..
-rwxr-xr-x    1 root     root             0 Nov 27 18:18 .dockerenv
drwxr-xr-x    1 root     root          4096 Nov 15 00:14 bin
drwxr-xr-x    7 root     root          4096 Nov 28 09:39 config
drwxr-xr-x   15 root     root          3340 Nov 27 18:18 dev
drwxr-xr-x    1 root     root          4096 Nov 27 18:18 etc
drwxr-xr-x    2 root     root          4096 Sep 11 16:04 home
drwxr-xr-x    1 root     root          4096 Nov 16 09:43 lib
drwxr-xr-x    5 root     root          4096 Sep 11 16:04 media
drwxr-xr-x    2 root     root          4096 Sep 11 16:04 mnt
drwxr-xr-x    1 root     root          4096 Nov 16 09:41 opt
dr-xr-xr-x  179 root     root             0 Nov 27 18:18 proc
drwx------    1 root     root          4096 Nov 28 09:30 root
drwxr-xr-x    1 root     root          4096 Nov 27 18:18 run
drwxr-xr-x    1 root     root          4096 Nov 14 23:36 sbin
drwxr-xr-x    3 root     root          4096 Nov 27 16:45 share
drwxr-xr-x    2 root     root          4096 Sep 11 16:04 srv
drwxr-xr-x    2 root     root          4096 Nov 19 12:47 ssl
dr-xr-xr-x   12 root     root             0 Jan  1  1970 sys
drwxrwxrwt    1 root     root          4096 Nov 16 09:44 tmp
drwxr-xr-x    1 root     root          4096 Nov 16 09:44 usr
drwxr-xr-x    1 root     root          4096 Nov 16 09:44 var

/config and /share are there, but no traces of /backup. Also using find / -iname 'backup' or whatever file I know is inside reports no results. That clarifies why /backup is not considered a folder.
I’m a docker newbie, so I don’t know how works the logic that allows homeassistant container to ‘see’ and interact with the /backup folder.
I also have Samba Add-on installed, and entering the container I can see and browse /backup:

-rwxr-xr-x    1 root     root             0 Nov 27 18:11 .dockerenv
drwxr-xr-x    2 root     root          4096 Nov 19 10:46 addons
drwxr-xr-x    2 root     root          4096 Nov 27 18:14 backup
drwxr-xr-x    1 root     root          4096 Sep 28 11:44 bin
drwxr-xr-x    7 root     root          4096 Nov 28 09:55 config
...

I suspect some mapping is missing. Any clues?

I’m afraid my docker-fu isn’t up to it either. I guess backup may be in a different container?

Dockered if I know!

So I found every add-on that can access /backup folder has a mapping for "backup:rw" in its docker config. For instance: Samba share and SSH & Web Terminal

Also found that “real” backup folder in raspbian is /usr/share/hassio/backup, but the installation method I used doesn’t bind /backup, therefore homeassistant container -and core components- cannot access it.

I opened an issue to ask: https://github.com/home-assistant/hassio-build/issues/129

I also just realized that the folder mentioned in whitelist_external_dir is representing folder structures inside your homeassisstant container… so you need to double check using ‘docker exec -it homeassistant bash’ command to look inside your container, and make sure your whitelisted folder is there. It has something to do with how the docker maps folder inside container to your host system. For example, default installation will map volume like this :

/usr/share/hassio/homeassistant in your host system is mapped to /config folder in the container… So if you want to whitelist a new folder called ‘snap’ for example in /usr/share/hassio/homeassistant/snap (host system folder structure), then you need to use /config/snap entry in the configuration.yaml whitelist_external_dirs