Hi ,
im new in HA im sysadmin linux expert, i want to improve with container technology and microservices cause im a newbie with containers in general…
I explain my scenario (running HA 7.1 in VM in my home server) and what i’d like to do :
I make a simple script in my NAS running in VM: the script consists in select , and collect in a directory the last picture captured by my zm-server NVR(running also in VM) for every single camera, It is associated at the last motion detected for each camera …
I want to insert these picture(snapshot of ip camera) in a lovelace picture badge
I already mounted the NAS in my HA ,and i can see the files in my “media browser” of homeassitant,
I know that if i want to show files in a badge in the homepage front end , i need to put them in the directory /local/www that means a create in my config (cause a don’t want to collect to webserver and use reverse proxy and vpn for retrive the picture directly from the server).
I know that for sure there many mistakes in my code, but i can’t understand if im in the right way and what i need to do for a very simple task (automation for coping the files ever 10 minutes in my case is enough to solve the problem) problably the service with the shell command is not correct ?
As far as running a shell command every x minutes, yes, you are on the right track. You just need to define the shell commands using the Shell Command integration, and then create an automation to call the appropriate service, which it looks like you’ve done.
If you want the automation to run every x minutes, you’ll want to use something like '/15'. Your current trigger will trigger at fifteen minutes past every hour. Also, I am unsure what the delay is for.
Other than that, and assuming the white-spacing issues are just a part of your post and your actual YAML is proper, it looks like everything should behave as expected. If it is not, could you include any errors you are seeing?
All that being said, depending on how everything is setup, could you just serve the images from your NVR and use that URL as the cameras’ still image URLs? This is the “intended” way to do what you are trying to do.
Thx for the answer ,
yes there are some issues spaces in copy paste, that’s my code for automations:
i make it more clear without the delay options.
and these are the errors occurs for the automation and for the shell_command (cp -r)
Logger: homeassistant.config
Source: config.py:464
First occurred: 18:07:47 (1 occurrences)
Last logged: 18:07:47
Invalid config for [automation]: [automation] is an invalid option for [automation]. Check: automation->automation. (See /config/configuration.yaml, line 9).
Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/__init__.py:115
Integration: Shell Command (documentation, issues)
First occurred: 18:08:57 (1 occurrences)
Last logged: 18:08:57
Error running command: `cp -r /mnt/media/snapshot/* /local/www/`, return code: 1
NoneType: None
i also tried cp -r /media/snapshot/* /local/www but it dosent work.
I already use the still image URLs , for the streaming and preload of the cameras.
What should i do is different because the script in the NAS choose for every single camera the last snapshot of the motion detected, so every picture are collected every 10minutes in the snapshot folder.
In this way i only need to move the image in /local/www for creating badge cards with the last motion detected . (i don’t want to reverse proxy or download image from external endpoint , cause is a big problem when that’s happen via Internet…a want to avoid this situation)
I also add in the post the section about it in my configuration.yaml
The automation tag should not be included in automation.yaml, it is already in configuration.yaml. Lines 1 and 12 should be removed. Side note: Those keywords are specific and you cannot change them, automation 2 is invalid.
Your items should be a list, so every automation should have a - before the first option, alias for the two automations you have there.
Your alias on line 13 is malformed.
Line 21 is missing an indent.
After fixing those, that first error should be resolved.
For the second, did you test the shell command before creating the script? I highly recommend making sure all the pieces are correct before putting it together. I do notice one error: /local and /www are pointing at the same place, /www is the actual directory and /local is the URL path to /www. So, /local/www/ is not the directory you want. /www should be a directory in /config that contains all the media that you want served at http://homeassistant.local:8123/local/.
Thx for your answer ,
i understand so much better now the Syntax.
Now i’ve a clear yaml code as you can see :
and you can notice that i delete the tag condition cause this error Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->condition. (See /config/configuration.yaml, line 9).
The automations works fine but i still have problem with the shell_command
You ask me if i tested the command before , How can i test this command? in which enviroment? i tried in the terminal add-on but i can’t see nothing in this terminal because i know that is in a separate container…i don’t know how to test the command in the core HA OS einviroment
ok,
now im in the VM’s terminal … but still i can’t see where my NAS is mounted , and i can’t see where my link is created (refered to shell_command.mount_media that is working fine)
If all that you want to do is have a camera that is available in lovelace then all that you need to do is create a local file camera. Here is an example that I use:
That file_path could be pointing to your /mnt/media/snapshot folder you don’t need to be copying files to anywhere else. If finding the latest snapshot is difficult to do in the Home Assistant itself, then the other possibility is to have a push camera like this:
Ok, the configuration file_path is the right way to do this very simply task
now i made a grid with image cards and by click on the “camera icon” i can watch the live streaming.
The last thing i’d like to do for the full control of the camera by lovelace dashboard is a link to the local files record (the NAS is already mounted but i mean would be great also a link to homepage from files in local media browser) .
But now that i learned how to link to lovelace card some files and i can use that for a lot of things.
I know that the solution you suggested me is not what i thought to do initially (but im not sure cause i want to learn and improve myself in containers technology) so your solution i think that is the best way to do what initially i tried to do with shell command. Thank you so much