Scripts that schedule a startup (WoL) or an OS (Windows) shutdown at sunrise and sunset.
I made these to help limit the power consumption of my PC (mining rig), by restricting it's operation to between the hours of sunrise and sunset. This is when solar panels installed at it's location are generating an output and thus offsetting / providing green energy for the device.
- Network device running OpenWrt
date
(GNU coreutils 8.32)curl
jq
wakeonlan
- Enable Wake on LAN on the target device.
-
Open the
sunrise-startup.sh
file, and populate it with your details as follows:LATITUDE="YOUR_LATITUDE" LONGITUDE="YOUR_LONGITUDE" MAC_ADDRESS="YOUR_MAC_ADDRESS" BROADCAST_ADDRESS="YOUR_BROADCAST_ADDRESS"
-
mv sunrise-startup.sh /usr/local/bin/sunrise-startup
on the OpenWrt device. -
Make the script executable
chmod +x /usr/local/bin/sunrise-startup
-
Run
/usr/local/bin/sunrise-startup
-
Run
crontab -l
to see the scheduled task. -
To stop, remove the task.
- Windows PowerShell
-
Open the
sunset-shutdown.ps1
file, and populate it with your latitude and longitude as follows:$latitude="YOUR_LATITUDE" $longitude="YOUR_LONGITUDE"
-
To start run
sunset-shutdown.ps1
with Powershell. -
To stop open
Task Scheduler
and delete\SunsetShutdown\ShutdownTask
.