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.1.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.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: thameswaterapi-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2841db589bd5adbf4673bccbf723da881be88a88597efed740f45031bb12920a
MD5 9b71140ea3b922be6f333b2719323bb7
BLAKE2b-256 7f578f70792c4ccb1fe6fcc86f8d025cd14f486d72e73eda253f3c3ad83b15aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thameswaterapi-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 422ec6cf5d36971582bf7094ddfc0adc03f05617350526f0e294e3584e0bee05
MD5 234238f17550c98ab82d504f7b00a21b
BLAKE2b-256 cca79b9662b5252394dc47e3b7cba6fb2fdbd52f776544d3de48b4ae97f52e47

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