Skip to main content

wattaged

PyPI version

Wattage Daemon is a utility that logs the consummed electricity and allows you to quickly compute the consummed kWh

Getting started

To install the CLI, run the following:

pip3 install -U wattaged
wattage --help

# Install the daemon to /opt/wattaged
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/sam1902/wattaged/HEAD/install.sh)"

The install script (separate from pip3 install) does a lot of things:

  • It moves the wattage_apcupsd.sh script to /opt/wattaged
  • It adds a root cron task to run wattage_apcupsd.sh every 5 minutes and log the results to /var/wattaged/watts.log
  • It adds a logrotate config to rotate the wattaged logs before it gets out of hands
  • Finally, it installs the CLI to the global Python interpreter with pip install

The CLI will try reading logs from /var/log/wattaged. Since the daemon logs every 5 minutes, wait at least 5 minutes to see the first log appear.

The CLI also displays the price in EUR based on the price per kWh in France in 2021-07-27.

If you want to use the output of wattage for something, you can get the Wh value alone by doing:

wattage 2>/dev/null | cut -f 1

as the price in EUR is outputted to stderr, and the Wh value is tab separated from the unit and timespan.

Development

To install the latest version from Github, run:

git clone git@github.com:sam1902/wattaged.git wattaged
cd wattaged
chmod +x install.sh
./install.sh
pip3 install -U .

Usage

usage: wattage [-h] [--start START] [--end END] [--logdir LOGDIR]

Computes how much watt-hours were consummed in the time span requested

optional arguments:
  -h, --help       show this help message and exit
  --start START    The start date to compute the consumption, any format recognised by dateutil.parser.parse will work. By default, starts at
                   the last boot time.
  --end END        The end date to compute the consumption. By default computes till the latest record.
  --logdir LOGDIR  The path where .log and .log.gz-ddMMYY are stored

Release files for wattaged 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wattaged 0.1.1
File Size Uploaded
wattaged-0.1.1.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wattaged 0.1.1
File Interpreter ABI Platform
wattaged-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / wattaged-0.1.1.tar.gz

Download URL wattaged-0.1.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a247df1eece821ca130434bd7ef4e1cbddf0ae8d5b6a4549a5da64370b150f15
BLAKE2b-256 checksum
How to use checksums
0b79386c7e15a51ebcdadab027446f0007b07e53e36164f1f3ddc778931e0fb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7

Release files / wattaged-0.1.1-py3-none-any.whl

Download URL wattaged-0.1.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a536b5b5aa778bea97f18683236a974c5b2b419281ea2e23d6497eeaa65309f
BLAKE2b-256 checksum
How to use checksums
d506068652b8fb582b52d7b39eb6979f083dabcd60ca3bd29a475b2c1301b473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page