Restart Home Assistant, with a URL (POST?) command, it it possible?

Sometimes my HASS get stuck (I know should go into the cause of it, but for now haven’t solved yet) and I need to restart it.
Currently I solve the issue by accessing with my Android phone with SSH into HASSIO host and do the command “sudo docker restart homeassistant”.

I wish to achieve the above command more easily, like pressing a button on my phone (when its stuck, the browser does not show the frontend), like with HTTP SHORTCUT, which sends a URL POST command for restarting the docker,

is it possible, which would be the URL?? Or other ways?

Thanks

Do automations and stuff still run? Or is everything locked up?

You could install the portainer aaddon if it’s hass.io and access that to restart the container

I restart Ha with Telegram, he execute a Script with a service.homeassistant_restart

I’m doing this through webhooks.

- alias: 'Webhook: Restart HA'
  initial_state: true
  hide_entity: false
  trigger:
    platform: webhook
    webhook_id: ha_restart
  action:
    - service: homeassistant.restart
      
- alias: 'Webhook: Restart HA server'
  initial_state: true
  hide_entity: false
  trigger:
    platform: webhook
    webhook_id: ha_restart_server
  action:
    - service: hassio.host_reboot

Using Nabu Casa webhooks. But with that said, if your HA really hangs this won’t work, then the automations won’t run anyway.

Sometimes things run sometimes not.

I need a fast solution for my phone, (with a simple press of a button) so accessing portainer is not a good option for me, I have a solution already (accessing with SSH)

May I see you code? Thanks

for the moment I found that works with a POST URL as


https://xxx.duckdns.org/api/services/homeassistant/restart?api_password=xxx

like this it restart homeassistant, but not the docker (?), anyone knows what that means in different behaviour (do not understand much about docker)

1 Like

Actually no, just now it got stuck, I did the restart as per the POST URL, and did not work (it worked before), so I had to do a sudo docker restart homeassistant, and it worked

So I need a way to give easily the
sudo docker restart homeassistant

or equivalent

So this is a docker question. Does it have a rest api?

This should give you some docker features exposed to Home Assistant to do things like restarting a docker container. I haven’t used it, but, I’ve seen it mentioned quite a few times in these forums.

1 Like

Yep that should do, thanks a lot.

I installed it, it is running, as per instruction I did


http://192.168.1.10:8126/container/home-assistant

and the result is


container not found

When I use PORTAINER HASSIO addon I see two containers
ha-dockermon
and
hassio_dns

Can anyone guide me a bit, since I am not good in docker and linux in general

when I do docker ps I receive


io@ubuntu:~$ sudo docker ps
[sudo] password for io:
CONTAINER ID        IMAGE                                           COMMAND                                                                                                                               CREATED             STATUS              PORTS                                                                                                                                                                             NAMES
5c80634084dc        hassioaddons/portainer-amd64:0.7.4              "/init"                                                                                                                               21 minutes ago      Up 21 minutes                                                                                                                                                                                         addon_a0d7b954_portainer
e669b418dd18        esphome/esphome-hassio-amd64:1.13.6             "/init"                                                                                                                               13 hours ago        Up 13 hours                                                                                                                                                                                           addon_15ef4d2f_esphome
ff14c8ae157f        hassioaddons/appdaemon3-amd64:4.0.2             "/init"                                                                                                                               13 hours ago        Up 13 hours         0.0.0.0:5000->5000/tcp, 0.0                                                                                                             .0.0:5665->5050/tcp                       addon_a0d7b954_appdaemon3
2961c30ac74b        hassioaddons/nginxproxymanager-amd64:0.2.1      "/init"                                                                                                                               13 hours ago        Up 13 hours         0.0.0.0:80-81->80-81/tcp, 0                                                                                                             .0.0.0:443->443/tcp                       addon_a0d7b954_nginxproxymanager
cd4fe155b635        homeassistant/qemux86-64-homeassistant:0.97.2   "/bin/entry.                                                                                                             sh pytho…"   13 hours ago        Up 13 hours                                                                                                                                                                                           homeassistant
c7e306723daa        homeassistant/amd64-addon-samba:8.1             "/run.sh"                                                                                                                             13 hours ago        Up 13 hours                                                                                                                                                                                           addon_core_samba
4c795adf8e12        homeassistant/amd64-addon-ssh:6.3               "/run.sh"                                                                                                                             13 hours ago        Up 13 hours         0.0.0.0:23->22/tcp                                                                                                                                                                addon_core_ssh
1852a7ebe1fa        homeassistant/amd64-addon-duckdns:1.9           "/run.sh"                                                                                                                             13 hours ago        Up 13 hours                                                                                                                                                                                           addon_core_duckdns
8a708f9ec5e9        samccauley/amd64-googlebackup:1.6.2             "/run.sh"                                                                                                                             13 hours ago        Up 13 hours         0.0.0.0:8055->8000/tcp                                                                                                                                                            addon_3833edd4_googlebackup
4efe7f1beed9        hassioaddons/tor-amd64:2.0.0                    "/init"                                                                                                                               13 hours ago        Up 13 hours         0.0.0.0:9050->9050/tcp                                                                                                                                                            addon_a0d7b954_tor
4a37f98cf0d5        hassioaddons/vscode-amd64:0.6.4                 "/init"                                                                                                                               13 hours ago        Up 13 hours                                                                                                                                                                                           addon_a0d7b954_vscode
2a6be897d354        hassioaddons/zerotier-amd64:0.4.1               "/init"                                                                                                                               13 hours ago        Up 13 hours                                                                                                                                                                                           addon_a0d7b954_zerotier
8d2eb90b614d        homeassistant/amd64-addon-rpc_shutdown:1.0      "/run.sh"                                                                                                                             13 hours ago        Up 13 hours                                                                                                                                                                                           addon_core_rpc_shutdown
15c35087471f        89275b70/amd64-addon-dss_voip:1.1.0             "/init /run.                                                                                                             sh"          13 hours ago        Up 13 hours                                                                                                                                                                                           addon_89275b70_dss_voip
3866c46e9233        hassioaddons/traccar-amd64:0.5.2                "/init"                                                                                                                               13 hours ago        Up 13 hours                                                                                                                                                                                           addon_a0d7b954_traccar
921dbb3847bb        hassioaddons/glances-amd64:0.5.3                "/init"                                                                                                                               13 hours ago        Up 13 hours                                                                                                                                                                                           addon_a0d7b954_glances
9e19927fcdd3        hassioaddons/sonweb-amd64:0.8.1                 "/init"                                                                                                                               13 hours ago        Up 13 hours         0.0.0.0:9541->9541/tcp                                                                                                                                                            addon_a0d7b954_sonweb
0018b64cedc1        homeassistant/amd64-addon-mosquitto:5.0         "/run.sh"                                                                                                                             13 hours ago        Up 13 hours         0.0.0.0:1883-1884->1883-188                                                                                                             4/tcp, 0.0.0.0:8883-8884->8883-8884/tcp   addon_core_mosquitto
136ca6ac0a72        hassioaddons/chrony-amd64:1.0.3                 "/init"                                                                                                                               13 hours ago        Up 13 hours         0.0.0.0:123->123/udp                                                                                                                                                              addon_a0d7b954_chrony
1ffe48eb2887        hassioaddons/pi-hole-amd64:3.0.2                "/init"                                                                                                                               13 hours ago        Up 13 hours                                                                                                                                                                                           addon_a0d7b954_pi-hole
6bf2b82cee80        homeassistant/amd64-addon-dhcp_server:1.2       "/run.sh"                                                                                                                             13 hours ago        Up 13 hours                                                                                                                                                                                           addon_core_dhcp_server
e4641759712b        bestlibre/amd64-syncthing:1.1.0                 "/run.sh"                                                                                                                             13 hours ago        Up 13 hours         0.0.0.0:8384->8384/tcp, 0.0                                                                                                             .0.0:21027->21027/udp                     addon_53caca22_syncthing
dcf73cae249c        homeassistant/amd64-hassio-dns:1                "coredns -co                                                                                                             nf /conf…"   13 hours ago        Up 13 hours                                                                                                                                                                                           hassio_dns
ee8da7615eff        homeassistant/amd64-hassio-supervisor           "/bin/entry.                                                                                                             sh pytho…"   16 hours ago        Up 13 hours                                                                                                                                                                                           hassio_supervisor
5081766211e7        philhawthorne/ha-dockermon                      "/bin/sh -c                                                                                                              'npm sta…"   3 months ago        Up 13 hours         0.0.0.0:8126->8126/tcp                                                                                                                                                            ha-dockermon

Correct name is

http://192.168.1.10:8126/container/homeassistant

Sorry for the late answer, I am currently very busy at work

AUTOMATION:

- id: Telegram - Antworten
  alias: 'Telegram Inline Keyboard'
  initial_state: 'on'
  hide_entity: false
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/start'
  action:
  - service: notify.telegram_homeassistant
    data:
      message: 'Verfügbare Informationen von Home-Assistant Server'
      data:
        keyboard: 
          - '/Temperaturen, /Drucker'
          - '/Heizung, /Steuerung'
          - '/Kamera, /Snapshots, /Videos'
- id: Telegram - Inline Keyboard
  alias: 'Telegram Control Pannel Command'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: telegram_command
    event_data:
      command: '/Steuerung'
  action:
  - service: notify.telegram_homeassistant
    data:
      message: >
       {{ [
       "Home Assistant Status",
       "Control Panel",
       "Yes Sir!",
       "Home Assistant Control Panel",
       ] | random }}       
      data:
        inline_keyboard:
          - 'System:/system'
          - 'And more:/more'
- alias: 'Telegram - System Aktionen'
  initial_state: 'on'
  hide_entity: true
  trigger:
    platform: event
    event_type: telegram_callback
    event_data:
      data: '/system'
  action:
    - service: telegram_bot.answer_callback_query
      data_template:
        callback_query_id: '{{ trigger.event.data.id }}'
        message: 'Was willst du Ausführen in Home-Assistant?'  
    - service: telegram_bot.send_message
      data_template:
        title: 'Home-Assistant System Aktionen'
        target: <chat_ID>
        message: 'Anscheinend möchtest du etwas auf deinen Home-Assistant Server unternehmen! Was willst du tun?'
        inline_keyboard:
          - "Home-Assistant Neustart:/restart"
          - 'And more:/more'

SCRIPT:

restart_ha:
  alias: Restart HomeAssistant
  sequence:
  - data: {}
    service: homeassistant.restart

Have fun! I have a proper menu structure, so several automations are necessary for me.
Regards

2 Likes

Is your HA is exposed using opening a port or Nabu Casa?
If using Nabu Casa what is setup required in HA+Nabu Casa please?
Thanks