Skip to main content

An unofficial Python library to interface with your USMS account and smart meters.

Project description

USMS

An unofficial Python library to interface with your USMS account and smart meters.

Getting Started

Prerequisites

  • Python >= 3.8
  • pip

Dependencies

  • httpx
  • lxml

Installation

pip install usms

Quickstart

python -m usms --help
usage: __main__.py [-h] [-l LOG] -u USERNAME -p PASSWORD [-m METER] [--unit] [--consumption] [--credit]

options:
  -h, --help            show this help message and exit
  -l LOG, --log LOG
  -u USERNAME, --username USERNAME
  -p PASSWORD, --password PASSWORD
  -m METER, --meter METER
  --unit
  --consumption
  --credit

[!NOTE] The username parameter is the login ID that you use to log-in on the USMS website/app, i.e. your IC Number.

As an example, you can use the following command to get the current remaining unit:

python -m usms -u <ic_number> -p <password> -m <meter> --unit

Usage

from usms import USMSAccount
from datetime import datetime

username = "01001234" # your ic number
password = "hunter1"

# initialize the account
account = USMSAccount(username, password)

# print out the account information
print(account.reg_no)
print(account.name)
print(account.contact_no)
print(account.email)

# print out info on all meters under the account
for meter in account.meters:
    print(meter.no)
    print(meter.type)
    print(meter.address)
    print(meter.remaining_unit)
    print(meter.remaining_credit)

# to get info from a specific meter
meter = account.get_meter(12345678) # example meter number

# getting hourly breakdown of today's consumptions
date = datetime.now()
hourly_consumptions = meter.get_hourly_consumptions(date)
print(hourly_consumptions)
# getting daily breakdown of this month's comsumptions
daily_consumptions = meter.get_daily_consumptions(date)
print(daily_consumptions)

# get yesterday's total consumption
date = date.replace(day=date.day-1)
print(meter.get_total_day_consumption(date))

# get last month's total cost based un total consumption
date = date.replace(month=date.month-1)
print(meter.get_total_month_cost(date))

To-Do

  • Publish package to PyPI
  • Improve README
  • Support for water meter
  • Support for commercial/corporate accounts

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgments

  • requests
  • BeautifulSoup
  • USMS

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

usms-0.2.6.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

usms-0.2.6-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file usms-0.2.6.tar.gz.

File metadata

  • Download URL: usms-0.2.6.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for usms-0.2.6.tar.gz
Algorithm Hash digest
SHA256 164c9d58435d0f3606a235ff3182e3d95fb9ee315c8bdd1a5e4735ba30b2c0e3
MD5 1933ed41c2ae6a67602a7c670bf8ac84
BLAKE2b-256 1d262a76a13108b94b3b87012616e639a9cf805bed025c8d8d251b1926fcfbd9

See more details on using hashes here.

File details

Details for the file usms-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: usms-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for usms-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 dfe751a7a6d8cbf9b1e2c06a8af6d2cc1166dc0b5f4fd2cfd93325d24c2e2bba
MD5 c895cad3e2cf8555cd975eb65a45dcde
BLAKE2b-256 61e4c27b1cd2f6d2e4052c30567721cd330d95c2901e86a515918eeaa6fa541a

See more details on using hashes here.

Supported by

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