Shell Command problem

Hi!
So Im having some trouble working with shell commands… this is my config:

shell_command:
  push_config_github: /bin/bash push.sh
  push_backups_github: /bin/bash push_backups.sh

So my push.sh is this:

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

So this one works perfect and pushes to github without problem…
The other push_backups.sh

cd ~/backup
git add .
git commit -m "Backup file on `date +'%d-%m-%Y %H:%M:%S'`"
git push -u origin backups

So, I get this error on the logs with this one:

Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/__init__.py:115
Integration: Shell Command (documentation, issues)
First occurred: 13:09:05 (1 occurrences)
Last logged: 13:09:05

Error running command: `/bin/bash push_backups.sh`, return code: 1
NoneType: None

The thing is, If i execute /bin/bash push_backups.sh on the terminal (Terminal & SSH add-on) it works perfect and pushes to github… :confused:

I tried to change it to cd /backup and same

Are you trying this in the homeassistant container? Test it in hte home assistant docker.

# docker exec -it homeassistant bash
bash-5.1#
bash-5.1# cd ~/backup
bash: cd: /root/backup: No such file or directory
bash-5.1# cd /backup
bash: cd: /backup: No such file or directory
bash-5.1# cd /config
bash-5.1# 

Hi! Thanks for the response :slight_smile:

I am not using docker, I installed it on my Raspberry Pi and the HA OS

If you installed HAOS it’s using dockers

Ohh ok, sorry for that!
So Im confused, I’m new on HA, how can I do this? :sweat_smile:

You can use “ssh & web terminal” addon (I dont think the “Terminal & SSH” add-on you have does this). You’ll need to disable the ‘protection mode’. That is on the addon page. Once you connect to to the terminal, you can then connect to the homeassistant docker and test your script.

docker exec -it homeassistant bash

I will tell you that the reason it is working for config and not backups is because config is exposed in the homeassistant docker while ‘backups’ is not. That is exposed in the supervisor docker which you can’t access directly with a shell_command.

1 Like

Ohh ok, makes sense, well, Ill just backup my configs to github, thanks! :slight_smile: