bbro44
June 22, 2023, 4:50am
1
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
shell_command:
config_backup: bash /home/config/ha_gitpush.sh
And this in my automations.yaml
action:
- 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
trigger:
- platform: time
at: 00:00:00
action:
- service: shell_command.config_backup
data: {}
And get this error
Error running command: `/config/ha_gitpush.sh`, return code: 128
NoneType: None
bbro44
June 22, 2023, 3:37pm
3
I’m able to run it from the terminal, and I ran chmod 755 /config/ha_gitpush.sh
with the same issues
nickrout
(Nick Rout)
June 22, 2023, 8:16pm
4
Hold the bus - why do you have /home in the path to the command?
bbro44
June 22, 2023, 9:59pm
5
To be honest, just something someone recommended on a different forum post.
nickrout
(Nick Rout)
June 22, 2023, 10:15pm
6
Try just /config/ha_gitpush.sh
bbro44
June 23, 2023, 3:23am
7
Error running command: `/config/ha_gitpush.sh`, return code: 128
NoneType: None
nickrout
(Nick Rout)
June 23, 2023, 8:15am
9
like the docs say, enter the HA container and try the command.
bbro44
June 23, 2023, 3:51pm
10
cd /config
git add .
git commit -m "config files on `date +'%m-%d-%Y %H:%M:%S'`"
git push -u orgin master
bbro44
June 23, 2023, 3:54pm
11
Works fine from both inside the docker container, and running it thru a terminal addon, just not thru automations.
Tinkerer
(aka DubhAd on GitHub)
June 23, 2023, 7:23pm
12
I suspect that git
isn’t available in the HA container.
bbro44
June 23, 2023, 9:37pm
13
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.
nickrout
(Nick Rout)
June 23, 2023, 9:56pm
15
Set your log level to debug.
hey, same problem for me, im using shell_command for turning off windows PCs
shell_command:
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?
bbro44
June 29, 2023, 9:35pm
17
@nickrout Still just
Error running command: `bash /config/ha_gitpush.sh`, return code: 128
NoneType: None
seems like the issue fixed for me with 2023.7.0 HASS update