Shell_command doesn't work?

Added to my configuration.yaml:

  shell_command:
    test: ls /media/snapshots

When running the command in Developer Tools - Actions, I get a response of:

  stdout: ""
  stderr: ""
  returncode: 0

I would expect to see my snapshots in there. From the terminal tool:

  [core-ssh config]$ ls /media/snapshots
    back-gate-person.jpg   doorbell-visitor.jpg   driveway-overhead.jpg  garage-gear.jpg        hvac-room.jpg
    back-gate.jpg          doorbell.jpg           driveway-track.jpg     garage-overhead.jpg    side-gate.jpg

Manyvget confused by the container setup used in HA.
HA is based on Docker containers and each container have its own environment with files and paths and so on.
Your terminal is running in one container and HA is running in another.
Some folders might be shar d among containers, but the path to the share might differ from container to container.

Start your test with just ls / to be sure to get an output with some text.

I just tried this now, and I still get the same response:

configuration.yaml:

shell_command:
  test: ls /

Response in Developer Tools - Actions:

stdout: ""
stderr: ""
returncode: 0

Did you read the documentation?

Especially the note sections

Looks like I needed fully restart Home Assistant, and not just reload the YAML config, which is very confusing

Hi Brian, good that it is solved!

Also: please take the time to mark the post that holds the solution.
You do that by selecting the three dots under the post:

image

Then select the check box:

image
By doing so:

  • this thread can be useful to other users as well (this thread comes up as solution when starting a thread which is similar to yours).
  • this prevents that someone else steps in trying to help

Thanks for giving back to the community! :+1:

No post solved it, I ended up just figuring it out. Will do though!

1 Like