helgeerbe / picframe

Picture frame viewer for raspi, controlled via mqtt and automatticly integrated as mqtt device in homeassistant.
MIT License
92 stars 27 forks source link

for integration with Home Assistant, ignore "hidden" subdirectories of root image folder #88

Closed jeffalperin closed 3 years ago

jeffalperin commented 3 years ago

I'm using SyncThing to synchronize image folders to my picture frame. SyncThing creates an empty subfolder named .stfolder in the root image folder used by picframe. This subfolder is shown in Home Assistant's drop-down list of possible image directories. Is it possible to exclude this (and any other hidden directories)?

sapnho commented 3 years ago

Hi Jeff, that's interesting. I am also using SyncThing but no .stfolder is being shown in my Home Assistant dropdown list, only the folders under /Pictures. Anything different from the default settings that you may have done?

jeffalperin commented 3 years ago

@sapnho, I have a different root photos directory /home/pi/4kpix, but I wouldn't think that cause this behavior. I manually deleted the .stfolder from the dropdown list (from the Helpers section of Home Assistant) and then manually re-executed the picframe_directory_get automation and .stfolder was once again added to the drop-down list.

If you do an ls -all inside /Pictures, do you have an .stfolder?

sapnho commented 3 years ago

If you do an ls -all inside /Pictures, do you have an .stfolder?

No, I don't.

jeffalperin commented 3 years ago

Hmmm. From: SyncThing FAQ at https://docs.syncthing.net/users/faq.html

How do I serve a folder from a read only filesystem?

Syncthing requires a “folder marker” to indicate that the folder is present and healthy. By default this is a directory called .stfolder that is created by Syncthing when the folder is added. If this folder can’t be created (you are serving files from a CD or something) you can instead set the advanced config Marker Name to the name of some file or folder that you know will always exist in the folder. I really hate the .stfolder directory, can I remove it?

See the previous question.

sapnho commented 3 years ago

I really hate the .stfolder directory, can I remove it?

I think you can't.

However: My structure is that I have a folder below /Pictures which is called Photos. Inside Photos is the .stfolder.

I guess that's why it doesn't show in Home Assistant.

sapnho commented 3 years ago

And to add, my synchronization is on /Pictures/Photos.

helgeerbe commented 3 years ago

Hi, actual all folders are used. To be honest, haven't thought about hidden folders. But it should be easy to exclude them. Don't know what best how to deal with subfolders. Actual only first level subfolders are send do homeassistant (But all images below this subfolder structure are displayed). But there might be user who have a deep nested folder structure. Although I don't know how to handle that in a selection list.

E. G.

At the end this could result in a selection like this:

Could become long and nasty for huge structures.

helgeerbe commented 3 years ago

@sapnho Only first level subfolders are displayed in home assisstant.

jgodfrey commented 3 years ago

It looks like the folder collection you're working with is coming from model.get_directory_list(). There, it's using the standard os.walk() method to build up the list. While there's no option to skip hidden files/folders in os.walk(), it be trivial to not include them at that stage.

@paddywwoof / @helgeerbe - is there any legitimate reason we'd ever want to include hidden folders here (I assume not), or can we simply eliminate them in get_directory_list()?

helgeerbe commented 3 years ago

@jgodfrey no, we should delete them

paddywwoof commented 3 years ago

We already filter any hidden image files or ones with .AppleDouble in the path so maybe we can generalise it to any file or folder starting with .

helgeerbe commented 3 years ago

I removed hidden folders from the directory list 5adca41 as a workaround. In the moment I don't have a good idea how to display a complex folder structure in home assistant. So at the moment I would stay with the first level below root.