Ever felt guilty about leaving your home server humming 24/7, even when it's barely being used? I did – until I found a way to give my UNRAID server a smarter, greener life. Now, it sleeps when idle and wakes up only when I actually need it – all controlled remotely with a Telegram bot on a Raspberry Pi.
Here's how I did it, why it works beautifully, and how you can set it up too.
The Problem: Idle Power Waste
My UNRAID server plays a simple role in my digital life. It stores backups of my photos, lets me browse archives of documents, and occasionally streams something lightweight. But here's the thing: most of the time, it's doing absolutely nothing
Yet it was running 24/7 – consuming power, generating heat, and contributing to noise pollution in my workspace. I wanted a setup that would:
- Save electricity
- Reduce wear and tear
- Still be available on-demand, without jumping through hoops
The Solution: Smart Sleep + Wake-on-LAN
Here's the architecture I landed on:
- UNRAID server: Sleeps when idle, wakes when needed
- Raspberry Pi (always on): Lightweight secondary server
- Telegram Bot: Sends a Wake-on-LAN magic packet and monitors server status
1. Letting UNRAID sleep with Dynamix Sleep Plugin
I installed the Dynamix S3 Sleep plugin on my UNRAID server – a game-changer. It lets your server sleep automatically after a set period of inactivity.
My configuration:
- Server sleeps after 15 minutes of idle time
- Wakes via Wake-on-LAN
- Sends me a Telegram message whenever it goes to sleep or wakes up
To send those notifications, I use a simple POST request to the Telegram Bot API. Here's an example of what the custom command looks like:
curl -s -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage" \
-d chat_id=<YOUR_CHAT_ID> \
-d text="UNRAID is going to sleep…"
You can place similar commands in the plugin's "Command before sleep" and "Command after wake" to get real-time updates.
2. Wake-on-LAN: A Gentle Nudge to Wake the Giant
I enabled Wake-on-LAN (WOL) in both the server BIOS and within UNRAID itself. This allows the server to wake up when a "magic packet" is sent to its MAC address from another device on the network.
3. Raspberry Pi + Telegram Bot: Remote Access Superpowers
To wake the server and check its status, I use a Telegram bot running on a Raspberry Pi. It's always on, low-power, and built to do one thing reliably: listen for commands.
Here's the full example of the bot code using node-telegram-bot-api:
const TelegramBot = require('node-telegram-bot-api');
const { exec } = require('child_process');
// Replace with your actual values
const TOKEN = 'YOUR_TELEGRAM_BOT_TOKEN';
const CHAT_ID = 'YOUR_CHAT_ID';
const UNRAID_IP = '192.168.1.100';
const MAC_ADDRESS = 'XX:XX:XX:XX:XX:XX';
const bot = new TelegramBot(TOKEN, { polling: true });
// /poweron command
bot.onText(/\/poweron/, (msg) => {
if (msg.chat.id.toString() !== CHAT_ID) return;
bot.sendMessage(msg.chat.id, 'Sending Wake-on-LAN packet...');
exec(`wakeonlan ${MAC_ADDRESS}`, (err, stdout, stderr) => {
if (err) {
bot.sendMessage(msg.chat.id, 'Failed to send WOL packet.');
console.error(err);
} else {
bot.sendMessage(msg.chat.id, 'WOL packet sent to UNRAID.');
}
});
});
// /status command
bot.onText(/\/status/, (msg) => {
if (msg.chat.id.toString() !== CHAT_ID) return;
exec(`ping -c 1 -W 1 ${UNRAID_IP}`, (err, stdout, stderr) => {
if (err) {
bot.sendMessage(msg.chat.id, 'UNRAID is offline or unreachable.');
} else {
bot.sendMessage(msg.chat.id, 'UNRAID is online and reachable.');
}
});
});
Explanation:
wakeonlan XX:XX:XX:XX:XX:XX
: Sends the magic packet to your server's MAC address. (This assumes your server has wakeonlan installed)ping -c 1 -W 1
: Sends one ping (-c 1) and waits 1 second max (-W 1) for a reply.- Bot listens for /poweron and /status and replies with confirmations.
This allows me to wake the server or check its availability from my phone anytime, anywhere.
Why This Setup Works So Well
This isn't just a fun project – it's practical:
- Energy Efficient: My UNRAID server stays off when not needed.
- Low Noise: No background hum or spinning fans.
- On-Demand Access: I can wake or check the server instantly via Telegram.
- Real-Time Feedback: Sleep and wake events notify me automatically.
Final Thoughts
This setup taught me a valuable lesson: convenience and power savings don't have to be opposites. With a smart sleep setup and a little Telegram magic, your homelab can run cleaner, quieter, and smarter than ever.
If you've got a UNRAID server idling too much, maybe it's time to teach it how to nap – and how to wake up when called.
Want a pre-built version of the bot, help with setup, or tips on making it even smarter? Message me or drop a comment – happy to share more!