Running .sh from an automation

Hey y’all, I need some help getting HA to run a .sh file from an automation. I currently have this in my configuration.yaml

  config_backup: bash /home/config/

And this in my automations.yaml

    - device_id: 4ad5ea3996c1d479a603a7a4b7d71550
      domain: mobile_app
      type: notify
      message: "It’s raining at soaringstoneridge "
      title: Rain
  mode: single
- id: l1k3
  alias: Backup HA configuration to GitHub repo
    - platform: time
      at: 00:00:00
    - service: shell_command.config_backup
      data: {}

And get this error

Error running command: `/config/`, return code: 128
NoneType: None

is that executable?

I’m able to run it from the terminal, and I ran chmod 755 /config/ with the same issues

Hold the bus - why do you have /home in the path to the command?

To be honest, just something someone recommended on a different forum post.

Try just /config/

Error running command: `/config/`, return code: 128
NoneType: None

What’s in the script?

like the docs say, enter the HA container and try the command.

cd /config
git add .
git commit -m "config files on `date +'%m-%d-%Y %H:%M:%S'`"
git push -u orgin master

Works fine from both inside the docker container, and running it thru a terminal addon, just not thru automations.

I suspect that git isn’t available in the HA container.

Alright. How would I go about fixing it? I just don’t get why I can run it from within the HA container, and thru the terminal, but not the automations.

It is in mine.

1 Like

Set your log level to debug.

hey, same problem for me, im using shell_command for turning off windows PCs

     turn_off_pc: "net rpc shutdown -f -t 2 -C 'Turned off from HASS' -U <winlogin>%<winpass> -I <winIP>"

im getting the same error as TS when trying to execute that from HASS (automation/switch)

Error running command: `net rpc shutdown -f -t 2 -C 'Turned off from HASS' -U <winlogin>%<winpass> -I <winIP>`, return code: 127

NoneType: None

that command works fine when executing manually from Advanced SSH & Web Terminal addon

seems like this started to happen after last Home Assistant updates
@bbro44 have you found a solution to the problem?

@nickrout Still just

Error running command: `bash /config/`, return code: 128
NoneType: None

@lemeshovich No

seems like the issue fixed for me with 2023.7.0 HASS update