I run this automation last night, now this morning i noticed that my Home-Assistant had not come back up again.
In the log i see that at 02:00 the service stopped, and then it did not come back up again.
I edited your script to run every day.
- alias: Restart HA
trigger:
platform: time
at: "02:00:00"
condition:
condition: time
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
action:
- service: homeassistant.restart
I am running the latest hassbian and have hassctl to, maybe there is a way to add a hassctl restart to crontab, but im not shure how its supose to be written…
I know, the issue that I have, is with the WiFi Signal. It not as strong as it should be, which causes two other problems. First, the WiFi signal is so weak, that I can not use the Sonoff Basic switch,unless it is less then 5 feet from the WiFi router. And the Main Issue(that is causing all the errors), is one of my 4 Amcrest Cameras, is about 25 feet from the Router. And with the Weak Signal, it keeps dropping off the network, which causes the Errors in the Log.
I already did a warranty replacement of the Linksys router, and still get the same issue. I need to find someone, that can do an RF analyse of my house. To find out, what is causing the RF Noise, that is stepping on my WiFi Signal. Once I fix this issue, I should be able to run the Sonoff Basic switch and Camera without any issues.
One question, about the above Automation, after creating it, I get a “Restart HA” switch in the Main screen. Am I correct, in assuming, if I turning the switch to OFF, the automation will stop running???
To answer your last question: yes, you can turn off the automation that way. It should be in the same list as all your other automations. You can even trigger it from there if you like.
I’m afraid I can’t give you any tips on the wifi issues your describing. When I mentioned checking the log I was referring to your comment that HA wasn’t coming back up after a restart. Do you still have that problem?
So, are you saying that if I cycle the switch Off, then On, it will trigger the automation?
As for the WiFi signal, I know what I need to do, find someone that has a RF Noise analyzer.
And when Home Assistant, doesn’t boot up, it is usually because I type in something wrong in the Configuration file. Like putting a capital letter, where it don’t belong.
@Grebhoven — that code is an automation. It needs to go into your automations.yaml, although if you use the UI as well, it may get overwritten. See here:
<soapbox>
If you’re having to reboot periodically, something is wrong with your setup. If you know that, and are happy to use this as a workaround, perhaps because you’re reliant on some flaky bit of IoT hardware that can’t be fixed, then fine.
But please don’t be “infected” by the “old Windows” mindset that a regular reboot is necessarily a good thing — HA, like any properly-designed system, can easily have weeks or months of uptime without needing to be “refreshed”.
I’d be against a feature to easily allow scheduled rebooting.
Hi @grebhoven , @troon has already pointed you in the right direction - the code is an automation and needs to be put in that section.
I do agree with his ‘soapbox’ point though - I posted this four years ago when HA was a lot less stable, I haven’t needed it for a long time by now as HA has improved considerably and is much more stable. Try to figure out what bit of your setup causes instability and fix that, instead of forcing reboots.
Also agreed. As everyone know, a restart once in a while is good for every computer. My RPi is no different @DDK.
As for the time @Troon - This was a ‘test’ set up to see if the reboot actually happens. I will set it somewhere at night. And as for your comment the HA is not a project to copy/paste code: Everyone started somewhere
my 2 cents…
i was able to get this in with no configuration errors by using the webGUI instead of configuring YAML directly.
go to Configuration > Automations > “ADD AUTOMATION” >
give it a name
default mode i think is ok
trigger type = time, fixed time radio button
set your time, i used 2am like the example.
you can add conditions if you want to do the day of the week thing…
go to actions
action type = call service
service = hassio.host_reboot (or .restart if you just want to restart the service, i prefer a full reboot)
and that should be it i think. i triggered the action to test it and it SEEMED to work. well see what happens tomorrow morning at 2am.