According to the source code it seems that the command did not run successfully; but we do not know why
So I just saw some lines above in that python file that someone has added stdout and stderr to debug output from a shell_command. This means that if you enable debug mode for this component in the logger section in the configuration file we could have more detailed info of what the error is.
Since this addition was made 11 days ago, it is very likely that it is not implemented in your HA installation yet, so if I were you (beware that I’m a total noob), I would add the lines concerning to the debug output in the shell_command.py in your HA installation and would include a logger section to something like:
# Example configuration.yaml entry
logger:
default: warning
logs:
homeassistant.components.shell_command: debug
and check the log when you trigger the shell command to see if we get more information.
Good luck!
I tried to install the component but with no luck. After executing the script and opening the verification link from the output, I have to enter the displayed verification code from google - but where?
@Brett_C@taddeuz I can share how i set gsheet. First of all thanks @timseebeck for inspiration I’m using gspread library because it seems that it’s easier to use. Follow everything from this tutorial to set API for drive and sheets and client_secret.json. Once you set everything test it in venv.
copy client_secret.json to hatosheets folder. Create gsheets.py file and paste this code in it.
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import datetime
import sys
# use creds to create a client to interact with the Google Drive API
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
fmt = '%Y-%m-%d %H:%M:%S'
d = datetime.datetime.now()
d_string = d.strftime(fmt)
val1 = sys.argv[1]
val2 = sys.argv[2]
sheet = client.open("CHANGE_TO_YOUR_SHEET_NAME").sheet1
row = [d_string,val1,val2]
index = 1
sheet.insert_row(row, index, value_input_option='USER_ENTERED')
Run it with python3 gsheets.py 10 20
If everything is ok just install gspread and oauth2client in hass venv and copy gsheets.py there.
For those return code: 1 errors in shell_command i was getting those also. My hass is installed in venv and if i run this script with this shell_command it wont work.
I think there is something wrong with my path to client_secret.json and gsheets.py. But I have no idea - I tried several options, but no success…running hassio on a tinker board.
When I execute the command via console (i‘m using the configurator addon of Hass.io), there are no errors and the value is pushed to the sheet.
So I think I am using the wrong path in the shell_command.
I already tried that, with the same error.
Which path to the gsheets.py (in configuration.yaml) and which path to the client_secret.json( in gsheets.py) should I use? The full path?
Very annoying, becaue it’s working when I execute it via console, but not in the shell_command…