Hi, first let me tell you that I’m a very beginner in hassio and python, so be patient.
The background
In the same LAN network, I have hassio installed on a Raspi, I have myPC (windows 10) and I have another storagePC (windows 10).
I want to count the number of files inside a specific storagePC folder (and subfolders) and use that number into a if cycle and trigger some automations on hassio.
What I did
First I write a simple python script and I have tested it on a python environment on myPC, and it works.
Basically to get the file count I use this line: file_count = sum(len(files) for _, _, files in os.walk(r'\\storagePC\shared\targetDirAndSubDir\))
Porting on Appdaemon
I have Appdaemon already up&running on my hassio for other stuff, but until now I used only pre-tested-working script found around the web; this is the first time I try to do everything by myself.
The problem
I created a new app but sadly I cannot get it to work. The app starts correctly and I have no errors on Appdaemon log, but monitoring file_count variable I noticed that its value is always 0.
So I think there’s something wrong with os.walk , maybe hassio can’t reach/browse the folder with that path.
Wrong syntax (slash backslash mess)? Permission problems (on windows the folder has fullcontrol access for everyone in the LAN without password)?
Is it a network folder shared on your PC or is it a local folder that you can access from within hassio? If it is shared folder, you can mount it to /mnt/pc_folder and then use os.walk(/"mnt/pc_folder/"). I am not using hassio so I don’t know if it will be easy for you to write a bash script to mount the folder on boot. You can also mount the folder from your python script in the initialize function.
If Hass.io is installed on a Linux OS with the folder mounted, definitely.
If you mean Hass.io on the stripped down HassOs, that is a question for their developers. They conflate the two by calling the HassOS version a Hass.io image.
I have Hass.io installed on a Raspberry Pi 3 and the folder I want to access is on another PC (Win10) in the same LAN.
I never mounted a folder on linux environment, so I have to find a solution within my reach.
I don’t want to go off-topic, but any suggestion is welcome.
If you installed the Hass.io image straight to the card, you have the slimmed down HassOs which may not have the software needed to mount a Windows share.
This now becomes a HassOs question. Likely the developers would need to answer this.