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.2.0.tar.gz (6.8 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.2.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for thameswaterapi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cbb3b9060d565f6507ab0a13df54d4895fc1c89f39415b9b33027fa125c14188
MD5 2332a687c7114df8d56855f9f3e58fe2
BLAKE2b-256 72171fe4aace2862e5eaba81ab358556aadef72deca1930f92d6e3345036be20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thameswaterapi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00303c6f871bd79c689a57a96e71f61a7883694c4789b00681d3b0294c848d39
MD5 4b3262a1c38a155b7601ec851363465e
BLAKE2b-256 e694947e777f9b76f53e1efaf9e9a42c75a8d38fcd1651b04ea30007fb77e76a

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