How can I reboot hub from a rule (remotely)

I want to be able to reboot my hub if I see that the free memory is getting low. I've used @thebearmay Hub Info Device to create a tile that displays the Free Memory so I can keep an eye on it on my SharpTools dashboard if I'm away on holiday. I've added a virtual switch that I will use on the dashboard to trigger the rule but I can't find what to set as the action?

I don't want to install any additional apps if possible - I just want to be able to send a command from rule machine that is triggered when the virtual switch is turned on (it is set to turn off after 1 second). I'm guessing it'll be a http command?

Edit: Would a virtual button be better or would I need to add a wait for elapsed time before the reboot command is sent? If a virtual switch is set to turn off automatically, would it manage to do so before the hub starts to reboot?

1 Like

Here’s how I do it. I have it wait until 3:45am as I would rather avoid rebooting it at the middle of the day, but this is just a personal preference.

The “reboot()” on C7 Hub Info is a “Run Custom Command” on the “C7 Hub Info” device.

3 Likes

It’s that last bit I can’t do and what I’m looking for. When I select run custom command, it demands a capability rather than just let me select a device.

1 Like

Select “Actuator” and it should show the Hub Info device. Here’s how it’s setup for me (it will likely look a bit different for you as I am on the next Beta version) :

5 Likes

Thanks I’ll take look when I get home. I’d have never guessed actuator

1 Like

Yea, most devices have that capability and hence it works most of the time.

2 Likes

Hmmm. Well I've set up my rule but it doesn't send the reboot command...Here is the rule:

The Hub Info device has the setting on to allow reboot & shutdown:

I press the button on the dash and the logs show the virtual switch works and triggers the rule, but nothing happens after the 10 second wait - no reboot. Any ideas?


Are you sure that’s 10 seconds and not 10 minutes? Also make sure that you’ve set the Allow Hub to Reboot Preference on (it’s a safety check).

4 Likes

:joy: :laughing:

Well spotted - what a schoolboy error. I'll amend that to 10 seconds.

4 Likes

I'm hoping that amending from 10 minutes to 10 seconds will initialise the rule and cancel the two previous wait events generated or the Hub is going going to be up and down a few times. I'm away on holiday later and wanted to ensure everything would work if I needed it while away.

2 Likes

Sorted, all working now - thanks to the eagle eye of @thebearmay I'll do another rule to automate the reboot as @Sebastien has done.

3 Likes

Restarting the rule usually resets the timer, but you can look at Logs | Scheduled Jobs to make sure.

1 Like

Yeah I've just done that before I pressed the button again and there was nothing pending so all good. I'm still wondering how rapidly the free memory should fall, though I don't want to obsess over it too much. At reboot it was around 548,000KB and within 10 mins it's at 484,500KB.

I restarted it when prompted 4 days ago and in those 4 days it went from 548,000 to 312,000. I thought I hadn't added anything recently (as I mentioned in another post), but then remembered I recently added another instance of maker.api for locative. I'm not sure whether that would have had any impact.

MakerAPI can put a strain on the hub if the automation on the other end does a lot of querying. That aside, it is normal for there to be a drop in memory shortly after a reboot, and it is normal to see a gradual drop over time. 80-85K is the normally accepted minimum, so I’d set your reboot value a wee bit north of there - maybe 90-100K depending on your comfort level.

Thanks. For now I've not automated the reboot fully (but will do at some point). I've set up the previous rule allowing me to reboot from a dashboard on my phone (I PIN protected the tile to avoid accidents). I've now set up a second rule to send a notification to my phone if memory goes and stays below 100000 for more than 2 hours.

An alternate way it an http post in a rule

Ie

3 Likes

bringing this back. has recent updates removed that option?
im looking at having a reboot and shutdown button on the dashboard.

thanks

never mind. found it.
need to add this driver [RELEASE] Hub Information Driver v3
then create a virtual device using this driver

2 Likes

crazy how we can be lazy in life.
I have a customer that setup is working great for over a year now. one day, nothing works.
now customers will have a reboot and shutdown button in the dashboard.

of course not to use every week, but I feel if they need it once every 12-18 months, not bad!

2 Likes

Wanted to say thanks for this info, helped me setup a recurring reboot. Very helpful!