HomeGenie Forum

Automation Program Plugins and Wizard Scripting => Help => Topic started by: enterprised on June 18, 2016, 05:10:58 PM

Title: scripted restart and reboot
Post by: enterprised on June 18, 2016, 05:10:58 PM
Can anyone help me get started with some code to schedule, based on cron event, a reboot of an RPi and restart of HomeGenie.

I have a couple of headless RPi's around the house and garden which I like to reboot once every 4 weeks and restart HG every 2 weeks, and start up in the same state as prior to the reboot/restart. This as part of standard system maintenance I do with all my equipment. I have similar scripts running for my routers and server.

I played with cron and script in Raspbian to reboot the RPi, but then it starts with all X10 devices switched on every single time.

I guess there must be an option using C# to do this in a clean and controlled way.

Title: Re: scripted restart and reboot
Post by: jshan on June 20, 2016, 12:18:44 PM
Here's some code:
http://www.homegenie.it/forum/index.php?topic=1214.msg7616#msg7616 (http://www.homegenie.it/forum/index.php?topic=1214.msg7616#msg7616)

I use a script with:
Program Code: HomeAutomation.RPIREBOOT/1 .ControlOn
Trigger: HomeAutomation.HomeGenie/Automation .Scheduler.CronEvent equals @sevenAMEveryDay
Title: Re: scripted restart and reboot
Post by: bkenobi on June 20, 2016, 05:56:22 PM
There is a method for on startup and shutdown of HG but I don't believe I have ever used either.

SystemStarted:
http://genielabs.github.io/HomeGenie/api/ape/a00001.html#afcf0d379d8dd2da00c2adf1c3c9996f3 (http://genielabs.github.io/HomeGenie/api/ape/a00001.html#afcf0d379d8dd2da00c2adf1c3c9996f3)

SystemStopping:
http://genielabs.github.io/HomeGenie/api/ape/a00001.html#a780a1b0195ec1d112ac7e65831cf7856 (http://genielabs.github.io/HomeGenie/api/ape/a00001.html#a780a1b0195ec1d112ac7e65831cf7856)
Title: Re: scripted restart and reboot
Post by: [email protected] on June 24, 2016, 12:21:14 AM
I'm not being funny but scheduled restarts just sound plain wrong to me (I work in IT)

Unless you have a memory leak then It just seems wrong! I would also want a bit more intelligence to control when and where they could do it (IE flags set to prevent it rebooting if something is happening, IE lights on or something it controls) and probably also use MQTT to broadcast a message to other nodes and then take recovery actions automatically if the box doesn't return to the network as expected, Or even make other nodes take over its job whilst it reboots..

Depends how anal you are, but for me stuff shouldn't go down.. That's where you don't really want to rely on anything other than embedded style electronics but..

The esp8266 stuff I have done for controlling lights will all still work without HG, HG just takes part in what it does but isnt a key component :)
Title: Re: scripted restart and reboot
Post by: enterprised on June 24, 2016, 01:15:32 AM
I travel al lot, really a lot, international. Things always freeze  or something goes wrong when I'm not home. since I started with scheduled restarts I never have issues. So no panic calls from the wife when I'm in Kuala Lumpur or in Dubai. The equipment never fails when I'm home, but as soon as I leave weird things happen.

Title: Re: scripted restart and reboot
Post by: [email protected] on June 26, 2016, 10:55:56 PM
Fair point!
Title: Re: scripted restart and reboot
Post by: innovauta on July 31, 2016, 11:27:43 AM
Hi enterprised, I also travel a lot and I'm seraching for a scheduled restart.
I have seen other alternatives posted by bkenobi and jshan but not the solution you found.
Could you help me with some code to schedule?

Thank you!