Hi I want to use a Python_Script to recursively create an index.html file in (config/www/“whatever”/) the goal is to use the lovelace IFRAME card to display the contents. In my Case its my .mp4’s I recorded using camera.record from one of my camera streams.
I have tried placing the scripts “generate_directory_index.py” at my chosen directory ie… config/www/captures/ and running it but i get access denied. tried as sudo su… issue is im not on a pi. Ubuntu linux generic install. I used cli. I have not tried putty to run the script yet. Im also wandering if i could use this as a service. like is mentioned here.
/config/www/“whatever”/ would be the output dir for your script, assuming (again) that you are running hassio, and this is executed inside the homeassistant container.
Notice the / _before: config
I have two more directories inside of my “captures” folder. “videos” , and “snapshots”.
“Whatever” was a reference to what-ever you folder you may have created inside the www directory.
So Far the only way I’ve successfully managed to run the script was to ssh in via PUTTY to my server, using port 22. Thus far I have not succeed using when using developer ssh login methods ie… port 222 or 2222 to login directly to the hassio cli.
Once I ssh in via PUTTY I can then cd (Change Directory) to “” /usr/share/hassio/homeassistant/www/captures/ “” and then run my commands python generate_directory_index.py
I figured that name only was a placeholder. /usr/share/hassio/homeassistant/www/captures/ would be on the host os, that is not accessable by the HA container, and HA can therefore not execute the script, but maybe that was not your plan?
Yes precisely. To achieve this from the with-in the container all that is necessary is open a terminal and navigate to “” /config/www/captures/ “” folder.
( FYI for any others who happen to read this, to clarify. I created the directory “captures” and two other folders within it. That is where my camera snapshots and mp4’s are being saved to.)
Perhaps you or someone here might so kind as to help me write a simple “script” or “shell command” that could regularly update my index.html file with the updated folder contents ie… new videos and screenshots. I’m quite new to “Linux & Python” and don’t have a full grasp of consents and have not figured out how best to accomplish this task…
My setup has the ““generate_directory_index.py”” file inside the config/www/captures/ folder. I don’t immediately see why this should make any difference but who knows. I’m still learning.
PS. Thank you again. I’ll give this a try and report back with details.
Got it. And I believe I figured out why I wasn’t able to use the cli terminal to run the command. If I’m right I think it had to do with the fact that the ssh addon is not running within the same container as hassio. Because hassio is the container hosting the “homeassistant” folder that is mounted as the /config directory by other containers.
I do have a silly question though. How would one now call the shell command after creating it in the configuration.yaml like so.
# BlaBla
blabla: bla black
# Shell Commands
shell_command:
generate: "python /config/generate_directory_index.py"
When I run the Shell Command from within the hassio user interface (browser gui), My Hassio becomes unresponsive. I am not able to recover it from a browser session. However an ssh client, or even physical display with keyboard & mouse at the machine allows me to restart the containers or simply reboot the host machine.
After either method of restart, the system comes back online and loads as usual. I am then able to see the newly updated index.html files inside the respective directory structures using any method of my choice ie… any ssh client or any add-on like (Configurator / Samba / VScode / cloud 9 IDE)
However properly viewing the new versions of the index.html files in my browser requires me to manually clear the browser cache of any browser I’ve previously used to view that index.html. Opening any previously unused browser like firefox to see the updated html page, works just fine and can render the index.html file inside the iframe card just like you would expect.
I use “Google Chrome’s”"Install home assistant" method to access my hassio instance. Can anyone help to identify the cause of hassio freezing after executing the shell command?
Also, anybody know of a better (more direct / less tedious) way to clear chrome’s cache for only one specific page/site at a time.
Yes,. Well clicking the links drills down threw the directories to the files. Then clicking the files listed opens them in the pop-out player, just like clicking on the live stream withing hassio.