Restarting HA when not at home

I am running HA via Hassio on a pi4 and there were times when I was outside the home and the UI stopped working and HA needed to be restarted (the host was fine).
At home I would simply use putty and hassio homeassistant restart but remote I am not sure how to do that, I am using Nabu for my remote connection.
Any suggestions (other than smart plug for the pi that I can toggle remotely)

If the UI is not working at that point in time I don’t believe there is a way around this (other than forwarding ports and doing a remote SSH connection). For this exact reason I have a smart plug which has not been added to Home Assistant but is linked to my Google Home config so I can use the Google Home app and remotely switch the plug off /on to hard reboot my HA server. It’s not a nice way to attempt to fix a crash but gets me out of trouble when away from the house for many days at a time.

1 Like

That’s exactly what I have setup already but yeah my concern is the same : the hard shutdown which is not great.

hi, do you often have HA crashed? For me it’s the second time now. First time I assume it was my fault because I choose to be in beta program, but 2 days ago it was just after migrating to 103.0,in the night it crashed. No web interface available, but HASSIO still visible via my Fing tool. So my question is, could something like a watchdog program or script be triggered on root when HA is down? Sorry I’m not a programmer…

Not that often but still happens randomly and yes I was also thinking about having some alert somehow sent to my phone when the UI is down but unless I spin up another HA instance that monitors the other no idea :rofl:

I’d only use a smart plug reboot as a last resort but yes I have remote SSH access so I can use the CLi to restart as well. Yes it means opening/forwarding another port.

Would I be able to use my Nabu ip along with the port forwarding?

I don’t think that is possible.

Edit: even though the Web Terminal addon uses ingress I suspect that that won’t be working if the frontend isn’t working. I should also say I DON’T forward port 22 but I have set a non standard port for ssh and I also only have my exposed as an IPv6 host so I’m limiting my accack surface in every possible way. Also I use a private key.

I would try and fix what is making it crash, check RAM usage, PSU, etc. otherwise it will only happen again.

Agree… when my Pi was doing this it turned out to be a shitty SD-Card and replacing that made that issue disappear.

is it possible to see the log after the crash? For me the log starts when HA starts, but maybe you can give me the file name I have to look for?

how to detect that HA is down, ping command? Is it possible to do that within a script like:
ping HA
HA not responding
hassio homeassistant restart

Is it possible that it’s just your remote access becoming unavailable?
I’ve had a couple of instances of that so put the following automation into my setup:

# attempt auto-heal of remote connection if unavailable
- id: remoteaccess_repair
  alias: 'Attempt remoteaccess repair if unavailable'
  hide_entity: true
    - platform: state
      entity_id: binary_sensor.remote_ui
      to: 'unavailable'
        minutes: 30
    - platform: state
      entity_id: binary_sensor.remote_ui
      to: 'unavailable'
        hours: 2
    - platform: state
      entity_id: binary_sensor.remote_ui
      to: 'unavailable'
        hours: 12
    - platform: state
      entity_id: binary_sensor.remote_ui
      to: 'unavailable'
        days: 1
  condition: []
    - service: cloud.remote_disconnect
    - delay: '00:01:00'
    - service: cloud.remote_connect

NB: This is a simplified version - I added some conditions in to only perform the disconnect / reconnect where my internet connection was not down.

1 Like

Actually today it was Nabu that did not respond but it also came back when I went to the Nabu options and it came back so the above automation would have probably fixed it too.
Worth adding it anyway, thx :slight_smile:

thanks I will try this! btw, do you recommend restarting HA each 2 days or once a week in order to clean everything?

Another option would be to set up one of the two-way notification systems like telegram, and then have an automation that restarts homeassistant when it receives a certain command via that.

1 Like

I’ve never found an HA restart necessary - unless I’ve screwed up the configuration of course.

For maintenance, I have recorder set to a daily purge with repack, keeping 7 days and run my HA in a python venv within Ubuntu 18.04 server on a low-end NUC.

Typically I’ll go at least a couple of weeks in-between working on HA but I’ve run for well over a month at a time without any restarts as I do a change freeze well before going away on holiday. It mostly takes care of itself as it is backed up nightly, on UPS and configured to handle internet outages by switching from push notifications to sms as required. I’ve also built a ‘holiday mode’ to provide different handling of notifications when away from home. In terms of building out the system I’ve pretty much included all the elements we currently have or need.

My system configuration is now fairly static and I’m concentrating mainly on keeping pace with updates (moving legacy configuration items into the integrations section as they become available) and some fine-tuning of automations and front-end user elements as I think of them. Last major adjustment was adding some hardware to interface HA with my legacy house alarm.
My main aim now is to replace the myriad of smart home apps my wife uses with the Android app once it’s a little further along (although she already uses the system through Google Assistant).


I’m sure it’s possible however I don’t run hassio anymore so I don’t know where the log file is.

thanks for this info. I think first, as I’m running on Rpi 3, will use a msata drive instead of SD card, which I’ve read it could be a point of failure, second option install HA on an old QNAP.

Happened today again, no errors in the log, the log keeps on uhm logging stuff, just need to reboot HA or the host to fix.
Could be the SD, I just wish I could boot from an SSD on a pi4 :frowning: