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
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
usernameparameter 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
You can also use environment variables for the login information:
export USMS_USERNAME="<ic_number>"
export USMS_PASSWORD="<password>"
python -m usms -m <meter> --unit
Or:
USMS_USERNAME="<ic_number>" USMS_PASSWORD="<password>" python -m usms -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)
# get the number of the first meter
meter_no = account.meters[0].no
# to get info from a specific meter
meter = account.get_meter(meter_no)
# 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
- Add more test coverage
- Support for water meter
- Support for commercial/corporate accounts
Contributing
Prerequisites
-
Generate an SSH key and add the SSH key to your GitHub account.
-
Configure SSH to automatically load your SSH keys:
cat << EOF >> ~/.ssh/config Host * AddKeysToAgent yes IgnoreUnknown UseKeychain UseKeychain yes ForwardAgent yes EOF
-
Install VS Code and VS Code's Dev Containers extension. Alternatively, install PyCharm.
-
Optional: install a Nerd Font such as FiraCode Nerd Font and configure VS Code or PyCharm to use it.
Development Environments
The following development environments are supported:
-
⭐️ GitHub Codespaces: click on Open in GitHub Codespaces to start developing in your browser.
-
⭐️ VS Code Dev Container (with container volume): click on Open in Dev Containers to clone this repository in a container volume and create a Dev Container with VS Code.
-
⭐️ uv: clone this repository and run the following from root of the repository:
# Create and install a virtual environment uv sync --python 3.10 --all-extras # Activate the virtual environment source .venv/bin/activate # Install the pre-commit hooks pre-commit install --install-hooks
-
VS Code Dev Container: clone this repository, open it with VS Code, and run Ctrl/⌘ + ⇧ + P → Dev Containers: Reopen in Container.
-
PyCharm Dev Container: clone this repository, open it with PyCharm, create a Dev Container with Mount Sources, and configure an existing Python interpreter at
/opt/venv/bin/python.
Developing
- This project follows the Conventional Commits standard to automate Semantic Versioning and Keep A Changelog with Commitizen.
- Run
poefrom within the development environment to print a list of Poe the Poet tasks available to run on this project. - Run
uv add {package}from within the development environment to install a run time dependency and add it topyproject.tomlanduv.lock. Add--devto install a development dependency. - Run
uv sync --upgradefrom within the development environment to upgrade all dependencies to the latest versions allowed bypyproject.toml. Add--only-devto upgrade the development dependencies only. - Run
cz bumpto bump the package's version, update theCHANGELOG.md, and create a git tag. Then push the changes and the git tag withgit push origin main --tags.
License
Distributed under the MIT License. See LICENSE for more information.
Acknowledgments
Project Template
This project was built using the superlinear-ai/substrate template.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file usms-0.4.1.tar.gz.
File metadata
- Download URL: usms-0.4.1.tar.gz
- Upload date:
- Size: 51.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0426148e29941df175828e6653e7450a720133c3eb992a6e182fb2d2bc1d259
|
|
| MD5 |
32e8c228ed4f6858e626a201d140ab66
|
|
| BLAKE2b-256 |
cd64e2c1605397cba011b84137432de602512cced7346ffbe1f296460b06ce5e
|
File details
Details for the file usms-0.4.1-py3-none-any.whl.
File metadata
- Download URL: usms-0.4.1-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cf68a0690cf470bbb8104d718ec21ee162d97c5ecbc0f275dbd6e8f1ca4e0cb
|
|
| MD5 |
e030726d2d08a710b27d920090c0165f
|
|
| BLAKE2b-256 |
5914c8927d4e68e6547587d8eff56816491fa72a81457d811a8f7d7ed81d5dc4
|