I face some issue with my Home assistant, which is I can’t reach it from outside even if nothing special occurs. Or maybe it happened, but I’m unable to figure what it is.
Since i’m out of Home, I’m unable to restart manually the Raspberry or the Home assistant I can’t reach.
So I’m looking for a way to restart automatically the Home assistant server as soon as he is not reachable from the outside, so he will remains always reachable at all time.
I know the commande restart, but don’t know on which parameter to trigger it, what kind of test I need to ask the Home assistant to do ?
I took a different approach to the keeping HA ‘fresh.’ I set up a sensor in HACS garbage collection every other day. I then wrote an automation to have it reboot. The development is so fast (NOT COMPLAINING) that I find it essential.
- id: '1628610016959'
alias: Reboot HA Core
description: Reboot home assistant at 11:57:19 pm
trigger:
- platform: time
at: '23:57:19'
condition:
- condition: state
entity_id: sensor.boot_hacore # <-- the garbage collection sensor
state: '0'
action:
- service: homeassistant.restart
mode: single
Shelly has a nice interface for smartphones if you want to go @Stiltjack route.
I suppose it all depends on why HA is unreachable - and more particularly on whether it knows there’s a problem. If it doesn’t there aren’t many options.
Thank you very much for your help, but if you do have an idea to take a look on the log and see what happened when my HA become unreachable ?? I’m curious to see if I can fix the issue ?
The reboot solve it all the time, but let him unreachable till the reboot …
Thanks AllHailJ for your proposal, just wanted to understand what this code is ? what is the sensor.boot_hacore ?
So it reboot Home Assistant at 23:57:19 everyday if the condition is met, which is the state of sensor.boot_hacore to zero ?
The code is an automation built to boot the core every other day. The trigger is set at ~23:57 and the condition is created from a garbage collection sensor.
‘sensor.boot_hacore’ is created in the Garbage Collection Integration. See here for information.
garbage_collection:
- name: Boot HACore
frequency: "every-n-days"
first_date: '2021-08-08'
period: 2 #<-- Boot every other day
the state of sensor.boot_hacore will be 0 every other day. It will be 1 on the off days and if I had a longer interval it would be 2.
It will reboot HA core every other day at 23:57:19. It takes about two minutes to reboot the core. The 19 is just crap and I don’t remember why I chose it at 19 seconds probably because it is a prime number.
I would guess you need to diagnose more. Is it down because your home router is not connecting to the outside? Or just HA? You could use the reboot code above with a.ping sensor trigger like one to 8.8.8.8 but if your router is down that would mean nothing unless you put the same on the router.
Nothing has changed for me except upgrades and I still use all the same automations. It rebooted last night as it was supposed to. I have upgraded HA to this:
If you can’t reach if from outside your LAN then the easiest way I could think to do it is to use a google calendar entry to trigger the request.
Create a 1 minute entry like “HAReboot” about 5 mins in the future to give HA time to sync with the calendar.
Then have an automation monitor the calendar for that “HAReboot” entry, “Wait for Time to pass” for 2 minutes to prevent it from repeating after restart and then action the core restart.