Hass.io: running "hassio homeassistant *" cli commands as shell commands

Hello,

I’m trying to do script which first takes snapshot, uploads it to Google Drive and then updates Hass.io.
First tow parts I have solved (thanks to community), but I’m not able to get hassio cli commands to work from Home assistant configuration.

This would be simple thing, though it does not work:

shell_command:
  update_hassio: hassio homeassistant update

I’ve not been able to get other hassio commands to work either as shell commands, such as

shell_command:
  restart_hassio: 'hassio homeassistant restart'
  info_to_file2: hassio homeassistant info > test.txt

But when opening ssh to host (using SSH & Web terminal add-on)
those commands do work.
Other hassio commands exist as services, apart from update.

Any suggestions how I could solve this?

… and there is something in the log:
Edit: there is error in log:
Error running command: hassio homeassistant update, return code: 127
10:43 AM /usr/src/homeassistant/homeassistant/components/shell_command/init.py (ERROR)
NoneType: None

As google tells,code 127 tells that such command does not exist. Should I do some magic to run command in Home assistant container, or something like that?

Did you ever get this to work?

Unfortunately no. By fast googling I found this: Protip: How to get shell in actual homeassistant (or addon) container when using Hassio

… which I did not find earlier, shame on my googling.
But at the moment I don’t want to hassle with this, my use was just to get backup and update in one button operation, which would be neat, but not necessary. I want to keep my HassOS as untouched as possible, to maintain easier restore scenarios.

any luck, i also have 127 error
running from ssh works, not from hassio shell command

These are all available as services to call. They can be found on the developer tools > services page dropdown.

Also a service call to reboot a docker container (an add-on) ?

service hassio.restart_addon

Ok, will try it with my container, that I created in portainer’… So it’s not really as add-on, I hope it works

ok, it works for example the deconz addon

addon: core_deconz

bit how to find the slug name, for a container that i created myself in portainer addon ? :slight_smile:

I am using Phil Hawthornes hadockermon and a depreciated custom_component (@ludeeus) hadocker switch… inexplicably depreciated as it is far superior to his suggested replacement (which doesn’t work with hassio… I just think he doesn’t want to maintain it anymore) but it works perfectly and I can start/stop/restart any docker container i want.

yeah, i checkec those too, allthough those components do not work with HassOS :frowning:

They should work with hassos If you add hadockermon with Portainer addon

hmm, need to look again, then

i tried this custome one, but never figured out what i need to enter for the URL action
since below doesnt work offcourse

  url: tcp://127.0.0.1:2376

with this one https://github.com/Sanderhuisman/home-assistant-custom-components#docker_monitor

my goal, was just to restart a container, so it was perfect if i just could use the integrated service hassio.restart_addon :slight_smile:

Yeah but it’s not an addon and that sanderhuisman repo won’t work with hassio anyway. Use Portainer to run Phil Hawthorne hadockermon and then the depreciated switch component will work… I don’t need to run it via Portainer as I use debian+ HA-Supervised but you should be able to make Phils repo work with Portainer.

yes, indeed, that senderhuisman would be ideal for me, a small custom component, just what i wanted, too badd it doesnt work on hassio :slight_smile:

ok, only approach left is indeed the hadockermon addon, … again another addon to restart another one :slight_smile:

Well to be fair, you aren’t trying to restart a HA addon!

i know :slight_smile:

1 Like

Those hassio -services do work well, for things they exists.
My original dream was to update hassio by button in GUI, chaining backup, its upload to Google Drive, and then running backup.
For that was not possible with shell command, I tried few things:

  1. Doing shell command which opens ssh from HA to HA, and runs command. Go wonder, this does not work at all
  2. Doing shell command, which open SSH to another linux, and runs shell script, which opens SSH to HA, and runs “hassio homeassistant update”
    Talk about useless complexity…
    I was able to run test commands, such as “touch /root/config/test.txt”, by which I got file created on HA. But hassio -commands result “Unexpected server response”. I suppose that hassio commands are restricted to be run only locally, or something like that.

But anyhow, I think I’ll be waiting for doing my wonder button once there is service displayed next to rest of hassio services.