https://ostechnix.com/wattwise-monitor-computer-power-usage
WattWise: Monitor Your Computer’s Power Usage in Real-Time
Track Your PC's Power Consumption in Real-time with WattWise!
Have you ever wondered just how much power your computer is using? With energy costs going up, it’s good to know. That’s why Naveen Kulandaivelu, a robotics and machine learning engineer, created WattWise. It’s a real time power monitoring cli tool that runs in your computer’s terminal and helps you track power usage.
What is WattWise?
WattWise is a lightweight, opensource, command-line tool to monitor the power usage of your system in real-time.
WattWise leverages smart plugs (primarily TP-Link Kasa) to gather real-time power data and presents it in a user-friendly terminal-based dashboard.
Initially, the developer created it to track the power usage of his high-performance workstation. The future goal of this project is to automatically throttle CPU and GPU performance based on electricity pricing (Time-of-Use) and system load, aiming to reduce energy costs during peak hours.
The power monitoring functionality is currently available, while the automatic power management features are under development.
Features
Here are some cool things WattWise can do right now:
1. Real-time power monitoring
It shows you the current power your system is using in watts (that's the amount of power) and amperes (that's the electrical current).
2. Multiple connection options
You can connect WattWise directly to your TP-Link Kasa smart plugs or even through Home Assistant if you use that smart home platform. This gives you flexibility in how you get the power data.
3. Colour-coded display
To make it super easy to understand, the power usage is shown with colours.
- If it's green, you're using less than 300 watts;
- yellow means you're between 300 and 1200 watts;
- and red pops up if you're going over 1200 watts.
It's a quick way to see if your system is working hard!
4. Historical data
WattWise can even show you charts of your power usage over time right in the terminal. It uses simple block characters so it works on pretty much any terminal. This helps you see trends and how your power consumption changes.
5. Simple command-line interface
Don't worry if you're not a super techy person! The commands are straightforward.
For example, just typing wattwise
can give you a quick view, and wattwise --watch
keeps monitoring in real-time with those cool charts.
6. Raw output
If
you're into scripting and want to use the power data in other tools,
WattWise can even output just the raw wattage number using the --raw
flag.
7. Configurable refresh
You can even tell WattWise how often you want it to check the power usage, say every 5 seconds with wattwise --watch --interval 5
.
Why Was WattWise Created?
Naveen built a powerful workstation for tasks like AI work. But using a high-performance system means higher electricity bills.
He had TP-Link Kasa smart plugs in his home. These plugs can measure electricity use. The Kasa app and Home Assistant could show the data, but switching between apps was inconvenient.
He wanted something that worked inside the terminal. That’s how WattWise was born.
How to get WattWise?
WattWise is open-source and free to use! You can grab it from GitHub. There are a couple of ways to install it: Using Pip or Using Docker.
Please note that WattWise requires Python 3.8 or later. For Docker usage, you will need to have Docker installed on your system.
Also, note that the power management features, which include automatic throttling, currently require Linux systems with appropriate CPU/GPU frequency control capabilities.
Install WattWise via pip
Clone the WattWise repository from GitHub:
git clone https://github.com/naveenkul/WattWise.git
Navigate to the WattWise directory:
cd WattWise
Install the required Python packages first:
pip install -r requirements.txt
Finally, install WattWise itself using pip:
pip install .
Install WattWise using Docker
Go to the directory where you cloned the WattWise.
Build the Docker image from the project directory (if you have cloned the repository):
docker build -t wattwise .
Create directories for persistence (this is usually done only the first time):
mkdir -p ~/.config/wattwise mkdir -p ~/.local/share/wattwise
These directories are mounted into the Docker container to store configuration and data.
For first time setup, you need to configure a data source. You'll need to configure either Home Assistant or a Kasa smart plug.
To configure Home Assistant:
docker run -it --rm --network host \ -v ~/.config/wattwise:/root/.config/wattwise \ wattwise config ha
OR to configure a Kasa smart plug:
docker run -it --rm --network host \ -v ~/.config/wattwise:/root/.config/wattwise \ wattwise config kasa
Once configured, you can run a single check with Docker:
docker run -it --rm --network host \ -v ~/.config/wattwise:/root/.config/wattwise \ -v ~/.local/share/wattwise:/root/.local/share/wattwise \ wattwise
Or you can run WattWise with continuous monitoring using the --watch
flag:
docker run -it --rm --network host \ -v ~/.config/wattwise:/root/.config/wattwise \ -v ~/.local/share/wattwise:/root/.local/share/wattwise \ wattwise --watch
For easier Docker usage, you can also create a bash alias as described in the documentation:
Add the following line to your ~/.bashrc
or ~/.zshrc
file:
alias wattwise='docker run -it --rm --network host \ -v ~/.config/wattwise:/root/.config/wattwise \ -v ~/.local/share/wattwise:/root/.local/share/wattwise \ wattwise'
After adding the alias, you'll need to source your bash configuration (e.g., source ~/.bashrc
or source ~/.zshrc
) for the alias to take effect.
You can then use the wattwise
command directly, just like the normal command:
wattwise wattwise --watch
Here's the visual demonstration of WattWise:
Future Plans
While the current version is great for monitoring, Naveen's original idea was even more ambitious.
Since his electricity provider uses Time-of-Use (ToU) pricing – meaning electricity costs more during peak hours – he wanted WattWise to be able to automatically adjust his computer's performance based on these prices.
Imagine this: during those expensive peak hours, WattWise could automatically reduce the speed of his CPU and maybe even his GPUs.
This would use less power and save him some money. Then, when the prices drop, it could go back to full speed.
Naveen has even done some testing that showed reducing his CPU speed could save around 225 watts. That can add up! The plan is to use some clever tech, like a Proportional-Integral (PI) controller, to manage this power and performance balancing act.
Current Limitations
It's still a work in progress, and there are a few things to keep in mind:
- Right now, it only supports one smart plug at a time.
- It only works with TP-Link Kasa smart plugs that can monitor energy usage (like the EP25).
- For the power management features (the automatic throttling), you'll need a Linux system with the ability to control CPU/GPU frequencies.
- The automatic power optimiser part isn't fully ready yet – the current open-source version on GitHub is mostly the monitoring dashboard.
What's next for WattWise?
Naveen has lots of ideas for the future, including:
- Supporting multiple smart plugs and showing combined power usage.
- Adding compatibility for more brands of smart plugs.
- Improving the visualisations and maybe even allowing you to export the data.
- Integrating with other power management tools.
- Making the predictions for power usage even smarter.
Naveen's goal with WattWise was simple: to solve his own problem of wanting to monitor his power-hungry workstation from the terminal he always has open. The idea of automatically saving money during peak electricity hours is just a fantastic bonus.
The dashboard part of WattWise is open-source under the MIT license. So, if you're interested, feel free to check out the official WattWise GitHub Repository. You can also contribute your own ideas and help make it even better!
No comments:
Post a Comment