A robotics and machine learning engineer has developed a command-line interface tool that monitors power use from a smart plug and then tunes system performance based on electricity pricing. The simple program, called WattWise, came about when Naveen built a dual-socket EPYC workstation with plans to add four GPUs. It's a power-intensive setup, so he wanted a way to monitor its power consumption using a Kasa smart plug. The enthusiast has released the monitoring portion of the project to the public now, but the portion that manages clocks and power will be released later.
Unfortunately, the Kasa Smart app and the Home Assistant dashboard was inconvenient and couldn't do everything he desired. He already had a terminal window running monitoring tools like htop, nvtop, and nload, and decided to take matters into his own hands rather than dealing with yet another app.
Naveen built a terminal-based UI that shows power consumption data through Home Assistant and the TP-Link integration. The app monitors real-time power use, showing wattage and current, as well as providing historical consumption charts. More importantly, it is designed to automatically throttle CPU and GPU performance.
Naveen’s power provider uses Time-of-Use (ToU) pricing, so using a lot of power during peak hours can cost significantly more. The workstation can draw as much as 1400 watts at full load, but by reducing the CPU frequency from 3.7 GHz to 1.5 GHz, he's able to reduce consumption by about 225 watts. (No mention is made of GPU throttling, which could potentially allow for even higher power savings with a quad-GPU setup.)
Results will vary based on the hardware being used, naturally, and servers can pull far more power than a typical desktop — even one designed and used for gaming.
WattWise optimizes the system’s clock speed based on the current system load, power consumption as reported by the smart plug, and the time — with the latter factoring in peak pricing. From there, it uses a Proportional-Integral (PI) controller to manage the power and adapts system parameters based on the three variables.
At the moment, the app only supports one smart plug at a time and only works with the Kasa brand. However, Naveem says there are plans to add support for multiple plugs, more smart plug brands, integration with other power management tools, and other features. The app in its current form is a pretty simple tool, but sometimes simple is all you need to solve a problem.
Naveen made WattWise open source under the MIT license, and you can download it directly from GitHub. If you’re interested, you can leave feedback and contributions, or you can fork it and adapt it for other systems. Note that the current version only contains the dashboard, not the actual power optimizer, which still needs further work.