Skip to main content

A Python client for retrieving hourly meter data from Thames Water

Project description

thameswaterapi

pip install thameswaterapi

A Python client for retrieving meter data from Thames Water.

This is a fork of thameswaterclient by Ayrton Bourn.

Python API

from thameswaterapi import ThamesWater

email = 'myname@provider.com'
password = '**********'

thames_water = ThamesWater(email=email, password=password)

If you have multiple accounts, you can specify which one to use:

thames_water = ThamesWater(email=email, password=password, account_number=123456789)

Listing accounts and meters

thames_water.get_account_numbers()  # [123456789011, 123456789012]
thames_water.get_meter_numbers()    # ['123456789']

Daily usage

from thameswaterapi import lines_to_timeseries

meters = thames_water.get_meters()
readings = lines_to_timeseries(meters.Lines)
for r in readings:
    print(r.start, r.usage, r.total)

Hourly usage

import datetime
from thameswaterapi import meter_usage_lines_to_timeseries

meter = thames_water.get_meter_numbers()[0]
start = datetime.datetime(2024, 10, 1)
end = datetime.datetime(2024, 10, 2)

meter_usage = thames_water.get_meter_usage(meter, start, end)
readings = meter_usage_lines_to_timeseries(start, meter_usage.Lines)
for r in readings:
    print(r.hour_start, r.usage, r.total)

Command line

python -m thameswaterapi EMAIL PASSWORD [options]

Options:

  • --account-number N — use a specific contract account number (defaults to the account default)
  • --list-accounts — list available contract account numbers and exit
  • --list-meters — list meter serial numbers and exit
  • --meter M — query a specific meter (defaults to first meter)

Examples:

# Show daily and hourly readings for the default account and first meter
python -m thameswaterapi myname@provider.com mypassword

# List available account numbers
python -m thameswaterapi myname@provider.com mypassword --list-accounts

# List meters on a specific account
python -m thameswaterapi myname@provider.com mypassword --account-number 123456789012 --list-meters

# Query a specific meter
python -m thameswaterapi myname@provider.com mypassword --meter 123456789

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thameswaterapi-0.3.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thameswaterapi-0.3.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file thameswaterapi-0.3.0.tar.gz.

File metadata

  • Download URL: thameswaterapi-0.3.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for thameswaterapi-0.3.0.tar.gz
Algorithm Hash digest
SHA256 478209042ec909766adaa27e06c6bca21e16a4e1cc67e5dfb152ee6a98fe9efc
MD5 ef7fd7da019e1e612f980d0ba19354b3
BLAKE2b-256 54686adc40543b3f145ad997b66f23d7ae2dd4646a28445ae7b779b04ab31d8f

See more details on using hashes here.

File details

Details for the file thameswaterapi-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: thameswaterapi-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for thameswaterapi-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2dd9bb3e5d8934f1f5cdc2a96e59a0bdb1dc7fbc395c2f34fae084c0f9255ef
MD5 c1458e0cca34a3fcc0547fb6678d6891
BLAKE2b-256 980efd71082bd4c80c6768a16614aab3d97c0aed12b5e3a5e1f1a44be833934c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page