Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
Power Open Source Hardware

Open-Source Tool Designed To Throttle PC and Server Performance Based On Electricity Pricing (tomshardware.com) 54

Robotics and machine learning engineer Naveen Kul developed WattWise, a lightweight open-source CLI tool that monitors power usage via smart plugs and throttles system performance based on electricity pricing and peak hours. Tom's Hardware reports: 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.
A blog post with more information is available here.

WattWise is also available on GitHub.

Open-Source Tool Designed To Throttle PC and Server Performance Based On Electricity Pricing

Comments Filter:
  • And I hope the companies involved in detecting such nonsense maintain their professionalism and flag this BS appropriately.
  • Waste to save. (Score:5, Insightful)

    by Gravis Zero ( 934156 ) on Wednesday April 02, 2025 @10:40PM (#65277859)

    Requirements
            Python 3.8 or later
            A TP-Link Kasa smart plug connected to your equipment
            Optional: Home Assistant setup with the Kasa integration

    So to "save electricity" you have to always run:
      * an IoT WiFi relay switch that is always on and computing some crap to phones home about
      * a docker instance to communicate with it using bloated python code

    If you're going to do SCADA then build a real SCADA system. Using internet-of-shit components just wastes energy and money.

    • by SirSlud ( 67381 )

      Anybody using this is already running Home Assistant for other purposes. The plug draws a watt (*drops monocle*) to adjust for ToU electricity usage. Simple goal, simple project. Do people like you suffocate if you aren't constantly bitching about something?

      • by dknj ( 441802 )

        Anybody running OpenHAB can do this without any third party tools.

        In fact, the servers in my office shutdown automagically when the ambient temperature rises above a setpoint to prevent the HVAC from kicking in. A simple schedule ensures it does not happen during Free nights and weekends, or when my total monthly power consumption is below a set threshold. All done from the UI of OpenHAB.

        So yeah, it's kind of a 'why are you wasting your time doing this when there are more capable tools which do the same th

    • HA and Kasa doesn't require any cloud/IoT access. It works 100% local.

      I guarantee you that the vampire power draw of many devices, especially gaming consoles and entertainment systems, dwarfs the power draw of a Kasa smartplug.

      I've implemented dozens of these throughout the house. All blocked from any cloud access, and only deployed where the power savings outweighed the cost of the device factored over 5 years of savings, including the constant power draw of the Kasa device.

      • I've implemented dozens of these throughout the house. All blocked from any cloud access, and only deployed where the power savings outweighed the cost of the device factored over 5 years of savings, including the constant power draw of the Kasa device.

        What a waste. A simple SCADA system would have been cheaper, saved more power, and required less effort.

        • by Monoman ( 8745 )

          That sounds interesting. Can you provide some links to projects showing how to get started with SCADA at home?

    • Tell me you know nothing about Home Assistant without telling me you know nothing about Home Assistant.
      I find it sad when people spew nonsense with conviction.

    • Re: Waste to save. (Score:5, Interesting)

      by madbrain ( 11432 ) on Thursday April 03, 2025 @02:14AM (#65278037) Homepage Journal

      I have 57 Tp Link Kasa energy monitoring KP125 plugs. They each consume about 0.25 W. I'm using them for various purposes, such as "Appliance is ready", ot turning on my subwoofers when my receiver comes up - turns out the subs still consume about 10 watts each, even in power saving mode, and I have 8 subs throughout the house. That alone more than offsets the wattage from the plugs themselves.

      The plugs work fine locally without any cloud access. They do unfortunately require cloud for the initial setup, which is a major deficiency. If TP-LINK servers go away, no new plugs will be able to be setup. And most likely Wifi properties won't be modifiable either.

      Zwave plugs don't have this issue, but unfortunately the bus is too slow to transport energy monitoring information frequently enough, especially not with 50+ energy monitors.

      I'm still hoping there will be a fully cloud tree solution from start to finish some day.

      Docker isn't required if you run HAOS. It's self contained. The TP link integration is built in. Nothing to install. It auto discovers the smartplugs.

      • by AmiMoJo ( 196126 )

        There are many smart plugs with energy monitoring that support the open source Tasmota firmware. No cloud needed, full control, WiFi.

        • by madbrain ( 11432 )

          Thanks. Do you have personal experience with any of them ? And if so, could you please provide the model(s) ? And are any of them UL certified ?

          The last time I looked into Tasmota, it required hardware modifications to the device in order to be able to load the firmware. I believe this was with smartplugs from Wyze, but could be misremembering. I am not able to do very small hardware modifications such as soldering due to macular degeneration.

          • by AmiMoJo ( 196126 )

            Local Bytes do some that are CE certified, but for Europe of course. There is a big list of compatible plugs here: https://templates.blakadder.co... [blakadder.com]

            Sonoff products often support Tasmota too, but can be a bit difficult to flash. The cheaper ones tend to be easier to flash, often just needing a couple of screws removing.

            If you can't flash yourself, Local Bytes have them pre-flashed, or you can pre-flashed ones on eBay and AliExpress. I'm sure there must be US suppliers that offer them pre-flashed, if we have

      • Shelly devices do not require Cloud access to set up or work properly. They can use cloud, if you want to, but it's not mandatory.
        They also seamlessly integrate with Home Assistant.
        https://www.shelly.com/ [shelly.com]

        • by madbrain ( 11432 )

          Thanks ! It appears all their Shelly Plus Plug US energy monitoring smartplugs are currently out of stock. There are some on ebay, but they are asking way above MSRP - about twice what I paid for my KP125s per unit. Still, I wish I had known about these before investing in all my KP125s. I didn't realize that setup required cloud at the time. But using the devices does not. TP-Link even advertises the Home assistant local interface in their Kasa app. But it's still impossible to add a plug while ISP is cut

          • I own about 25 Shelly devices, but I live in the EU, therefore they are simple to acquire.
            They certainly do not need cloud to configure, they contain ESP32 and I can access the AP IP directly via whichever device.
            Also, their Home Assistant integration is superb, they properly support Energy dashboard and have plenty data points.

            • Thanks. The Home assistant integration for Kasa is also great. Energy dashboard works. But my biggest energy hogs are hardwired. So, I find my Rainforest eagle smart meter proxy to be more useful for tracking consumption.

              My KP125s are used for various automation i mentioned earlier, not for tracking energy use per se.

    • None of this is Internet-of-shit. All of the things in the post are either open source, or are locally controlled.

      By the way Python doesn't use power, and the Kasa smart plug uses less than half a watt. As with everything if you build this system to only run once a year you're probably too stupid to set it up in the first place.

      If you're going to do SCADA then build a real SCADA system.

      On the flip side SCADA systems have no low power mode and will cost you a metric fuckton. Next time you suggest a solution I invite you to first look at the problem before ranting on

    • These days you can get realtime current consumption from processors and GPUs, so the only part not accounted for is the motherboard itself and that is not a huge current draw unless you have a bunch of PCIE 5. It will be a lot less code to read those sensors (you do need appropriate addin kernel modules for the CPU power though) so it should be pretty easy to switch it over from using the network device to just reading some stuff out of proc.

    • Assuming you have variable electricity plan, everyone knows that residential costs are peak between 4pm-9pm ..... just make software that throttles it than, with less of the overly complex solution this is.
  • Why not "wattage and amperage", beau?

  • Or ... (Score:4, Interesting)

    by fahrbot-bot ( 874524 ) on Wednesday April 02, 2025 @11:29PM (#65277903)

    I set the "cpufreq" governor to "conservative" on my Linux Mint system and (probably) get much the same benefit. (I tried "ondemand" but like the former better for my use...

    From Linux CPUFreq Governors [kernel.org]:

    2.5 Conservative: The CPUfreq governor "conservative", much like the "ondemand" governor, sets the CPU frequency depending on the current usage. It differs in behavior in that it gracefully increases and decreases the CPU speed rather than jumping to max speed the moment there is any load on the CPU.

    On my OPNsense system, I enabled PowerD and set the AC and Normal power modes to "Adaptive" (and Battery to "Minimum") -- which seems to give about the same results as on my Linux systems.

    Certainly lowers the power consumption when idle -- I tested both systems with a Kill-A-Watt type meter.

    • Not the same. This isn't about reducing idle consumption, it's a bout limiting maximum consumption.

      The problem of course is that power != energy. It doesn't help me if I save 10% power if my PC runs at this full load 10% longer. It still uses the same energy.

  • Have a script poll the API where the electricity price is, when it is high, throttle CPU, when not, then don't.
    • It seems what he is doing is time average limiting his power consumption, not just blindly throttling the CPU. E.g. you may not want to throttle the CPU when it's just performing one quick task. That task itself will be shorter (and use the same energy) thus not saving you anything but slowing down the system needlessly. If on the other hand you're blasting your CPU for a while then it appears to throttle the CPU.

      • It seems what he is doing is time average limiting his power consumption, not just blindly throttling the CPU. E.g. you may not want to throttle the CPU when it's just performing one quick task. That task itself will be shorter (and use the same energy) thus not saving you anything but slowing down the system needlessly. If on the other hand you're blasting your CPU for a while then it appears to throttle the CPU.

        For years and years I've used the ignore_nice_load option in Linux cpufreq governors. If I know the task will be running longer and it doesn't matter if it takes a bit longer, I'll set its niceness level higher, so it won't trigger an increase in the CPU frequency.

        I've also used my own scripts for turning applications on/off depending on electricity price for quite a while. I've only bought my electricity with the hourly market rate for about a year and a half, but the idea really started with my profita

  • Or you could just turn it off when not using.
  • You could just turn it off when not using.
  • The motherboard in question for this setup already has an AST2600 BMC that is capable of reporting real time power consumption for the machine (which makes sense - I can't imagine anyone producing a board of this class without an integrated BMC of some sort). The use of a "smart plug" is completely superfluous, consumes more energy, and requires more effort than using the linux kernel IPMI driver that is already there...

  • but the price of electricity, for most applications, just doesn't matter. If you have a service and it's only available at super off peak hours, then what good is that when most people will want to use the service in their free time, which is likely during on-peak hours?

    I could only see this mattering if you were mining crypto and profit only happened during specific energy price points.

    Seems like a neat tool that could have some niche applications but I'm not seeing the widespread appeal here. We should ju

  • Conservation just causes prices to get adjusted upwards over the medium to long term. It's plain economics. Companies will do anything to keep their revenue increasing from year to year.

    Conservation works against this dynamic.

    What is needed to counter this dynamic is demand destruction. [https://en.wikipedia.org/wiki/Demand_destruction]

    Load defection [https://virtual-peaker.com/blog/utility-customer-defection/] accomplishes this and sends the right economic signals to the investor-owned utilities.

    Solar + So

  • Always throttle the PC.

  • The 15% you save by doing all of this, can be achieved by simply not running Python on Docker on Windows.

"Just think, with VLSI we can have 100 ENIACS on a chip!" -- Alan Perlis

Working...