ttmetro
(Bernhard Boser)
May 2, 2022, 6:19pm
1
I’m trying to use a “shell_command” in an automation and am experimenting with the example from the home assistant documentation .
I’ve added the code to the blank automations.yaml
. VSC gives me errors for all keywords:
Missing property “action” for automation:
Property input_number is not allowed for input_number:
etc.
What am I missing? The ultimate goal is to run a shell command once a day.
Thanks!
SNoof85
(Sébastien)
May 2, 2022, 8:43pm
2
Hi, would be easier if you post your automation code.
ttmetro
(Bernhard Boser)
May 3, 2022, 1:55pm
3
In automation.yaml :
- alias: Backup
id: "1651514372914"
description: Backup configuration to GitHub (nightly)
trigger:
- platform: time
at: 02:00:00
condition: []
action:
- service: shell_command.github_backup
mode: single
In configuration.yaml :
shell_command:
github_backup: "bash /config/ha_gitpush.sh"
/config/ha_gitpush.sh is an executable that works fine when run from the command line. I would like it to be run each day at 2am, but it’s not.
I’ve also tried the following, same result (i.e. the script is not executed):
In automation.yaml :
- alias: Backup
id: "1651514372914"
description: Backup configuration to GitHub (nightly)
trigger:
- platform: time
at: 02:00:00
condition: []
action:
- service: hassio.addon_stdin
data:
addon: a0d7b954_ssh
input: /config/scripts/ha_gitpush.sh
mode: single
In short, I would like the shell script /config/scripts/ha_gitpush.sh
to run once a day at night.
SNoof85
(Sébastien)
May 6, 2022, 7:53am
4
Have you tried the service call alone ? To check if your script is running ? (service: shell_command.github_backup)
ttmetro
(Bernhard Boser)
May 6, 2022, 10:14pm
5
It’s now working. The shell_command was not in the correct location.
Thanks!
1 Like
Bschjoett
(Benny Schjoett)
December 5, 2022, 2:19pm
6
Hi Bernhard
what was correct location for the shell_command ??
jtauscher
(Jtauscher)
December 19, 2023, 2:00pm
8
Does anyone know what location works?
I am having the same issues. In ‘terminal’ the script works just fine. In the service command I get a ‘file not found’. Both cases I do a Cut/Paste of the command:
/config/script.sh
The terminal works as expected, the service command says “File not found”
Any ideas?
jtauscher
(Jtauscher)
March 8, 2024, 3:10pm
10
service: shell_command.restart_fritz
data: {}
Works for me, when file is located at homeassistant/fritzbox-restart.v1.sh
I had problems with log locations within the script, maybe you need to adapt paths within the script too.
Also try to chmod 777 the file.
doh!! was trying to create a os level cron job. way simpler with a HA time trigger.