I have a shell command set up in my included shell_commands.yaml as follows:
copy_background: "cp -f /config/www/images/backgrounds/{{ jpegname }} /config/www/images/backgrounds/current/background.jpg"
The simple idea is that this will copy an image file to another folder where it will overwrite a file called background.jpg that is used for dashboard backgrounds.
I have an automation that calls this. The code is as follows:
actions:
- action: shell_command.copy_background
data:
jpegname: '{{ (states(''input_text.background_full_filename'')) }}'
As a result of testing, I know that the shell command is being called as, when my automation ran, I had incorrectly setup the “jpegname” variable and the logbook showed the failed “cp” shell command with the “{{ jpegname }}” text unchanged in the copy statement.
So, once I fixed the automation to pass the details correctly, this logbook error disappeared. However, no file was copied.
I ran the expected cp statement in Terminal and that worked.
Example that worked in terminal is:
cp -f /config/www/images/backgrounds/housedawndusklightning.jpg /config/www/images/backgrounds/current/background.jpg
I don’t know how to debug this as I cannot see whether the cp statement does appear as I expect it to appear (i.e. with the correct filename in jpegname) or whether there is some other failure when the copy command is actually run (eg permissions from HA automation to folders on the pi4 I use).