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
Pre-requisites
- Python >= 3.8
- pip
Dependencies
Installation
python -m 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
Project details
Release history Release notifications | RSS feed
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.3.4.tar.gz
(10.7 kB
view details)
Built Distribution
usms-0.3.4-py3-none-any.whl
(9.8 kB
view details)
File details
Details for the file usms-0.3.4.tar.gz
.
File metadata
- Download URL: usms-0.3.4.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77ce4ae2fc17811e38d0cc8d86257a4fc10feda0f5b4fcdfdbad162434a5e9bf |
|
MD5 | d20b3167e73c2b09230f5348dc4009b3 |
|
BLAKE2b-256 | 88c1812119481069c7f0587a44eb8190a0d997e1144a5c1020ef32e9b0317555 |
File details
Details for the file usms-0.3.4-py3-none-any.whl
.
File metadata
- Download URL: usms-0.3.4-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f5b891ae3d6eb487f5f6f1d1c119fd68b03342f329fcb959f06ef38b2e77d5f |
|
MD5 | ae48b9664e7e643d968fd67c4296d30d |
|
BLAKE2b-256 | 6df72949fdbc15da7c7d56764f037546d1a965129d88ee96aa9c1d331446f3dd |