Power Management Setup - Auto Shutdown

Howdy,

It’s been a few years since I’ve been around dietpi but I’m working on rebuilding my little MinIO server. With that I’m always looking at new features I want on my own stuff. My main use is as a backup server and while I could just leave the device all the time I prefer not to – partially for eletrical waste (rather than $ waste), part to lessen wear on drives, and a lot b/c I like the challenge.

As a MinIO backup server I really only need it on while backups are running. Ideally, it would wake on lan and shut down when backups are done. Startup for me is likely going to be RTC related but for x86 or boards that support WOL that would be rad. That brings up to what I am working on and was wondering if a) I am reinventing the wheel and b) if there was any interst in my contrinuting code to roll it into DietPi proper.

It is actually rather simple:

It is a script that checks MQTT retained messages and if certain states are true it waits confirms that state and then sends the board into standby state or shuts it off. I know different boards have different abilities so that may be a challenge here.

For example - I’m running backups. So each backup has its own MQTT status:

backups\1
backups\2
backups\3
backups\4
backups\5

Using the retain flag each one of those containts either “Started” or “Stopped”

The script just readys backups# and if it finds the word “Started” does nothing. And if it finds “Stopped” it waits the same amount of time as the cron job (right now 15 minutes) and checks again. If the second check also doesn’t find a 'Started" flag it shutsdown/sleep.

Then the RTC / WOL would wake the board at the right time.

Bonus Logic: For my use I’m also looking at integrating a clear of the states so the server would wait for at least one state to be present before considering shutting down. This would make sure the backup server is one for the next backup run in case something got out of sync between them b/c I can’t use WOL.

That is my case but for DietPi we could just check all “dietpi/#” status. Have an option to set the interval and maybe the command (provide a default?) in a gui menu in dietpi. Change the flags to something more generic like “Sleep” and “KeepAlive”. So folks could write any status they want to the “dietpi” node and once it sees all “Sleep” nodes it would do the command.

It is simple, straightforwrd, and lightweight so it seemed very much like DietPi.

If there is already a feature in DietPi please let me know too :slight_smile:
-techdabbler

Hi,
there is nothing like this in DietPi. Furthermore, most SBC did not support any WOL functionality. If you switch it off, it will stay off until you power cycle. There is no hibernate feature. At least I’m not aware on a SBC supporting it.

Thanks. I didn’t think there was anything in DietPi related.

Agreed most don’t have a sleep. The board I’m looking supposedly has the abiilty to suspend to RAM + RTC wake up. I Realize this would be useful for a small % of dietpi users except in specific situations - x86-64 being the largest group I’d imagine. It could also be used for a shutdown if someone had a reason like having a UPS monitor on a different box writing to it as well. Low permission way to do a clean shut down before the power fails without SSH.

All in all this is why I asked if there was interest rather than just doing the code and contributing it.

Let’s ask the developer

MichaIng
Your view :slight_smile:

So basically a remote control feature via MQTT message flags, including WOL and STR, if supported hardware-wise. Even that I can think of a bunch of different use cases (not just backups, but also service control and other things), it is still quite specific, having two systems to communicate and auto-trigger tasks on each other.

Probably first it is something as an example MQTT use for our docs or a blog post to encourage users giving feedback, providing their use case ideas? And if something crystallises out, we can see how to implement into DietPi?

But of course we are always open for pull requests :slight_smile:: https://github.com/MichaIng/DietPi

MichaIng

Yes. Exactly.

I’m still waiting for my sbc of choice to be available for purchase to do some of my full testing on though I could maybe find my Pi 3 and fire it up. I’ve already got it the basic structure working in a x64 VM but of course sleep/wake functions (for my use) aren’t really there to test.

What’s the best way to do a blog post to get community feedback? Which I totally think makes sense to do?

It’s been a while since I did a pull request for dietpi but I’m def happy to do so if the community desire is there for a built in MQTT Control feature.

Usually RPi devices are not able to do any hibernate or WOL functionality.

For the blog post, MichaIng could create a WP account. Or you do some writing and some of our guys can copy it into WP

Joulinar you should have the ability as well, using the “Invite User” option :slight_smile:. But yes, just send either one of us a PM, or a notice that I should use your forum account mail address, and I’ll invite you.

Do I have? If yes I can manage once I know the details like user name, email aso

Just a mail address is required, then the recipient can choose username and password details, …, I guess, I never sent myself an invitation to see how it looks like :smiley:.

Yep, username, password, and optionally full name.

Sorry for the few day abscence around here. I’m open to either option. Writing something directly or sending it along to anyone.

If you want my email to create an account let me know who I need to PM to get that info.

just drop me a PN and I could create the WP account