BCHydro API
Project description
BCHydroHomie API
BCHydro Python API for extracting electricity usage statistics from your personal account.
This was taken up from Eric McNeice's work here: https://github.com/emcniece/bchydro
BC Hydro seems to be making changes to break these projects.
Installation
Via PyPi:
pip install bchydrohomie
That's it! The appropriate Playwright browser will be installed automatically on first use:
- macOS: webkit (Safari-based)
- Linux: chromium
- Windows: chromium
Note: The first time you use the library (when you call a method that requires authentication), it will automatically download and install the browser binary (~100-300MB). This is a one-time download and will only take a minute. Subsequent uses will be instant.
If you prefer to pre-install the browser before using the library, you can run:
# macOS
playwright install webkit
# Linux/Windows
playwright install chromium
Via Github:
# Fetch the code
git clone https://github.com/rhude/bchydrohomie.git
cd bchydrohomie
# Set up environment
pip install -r requirements.txt
Usage
Running the example script:
pip install bchydro
export BCH_USER=your.email@domain.com
export BCH_PASS=your-bch-password
python test.py
Using in a project:
import asyncio
from bchydrohomie import BCHydroApiBrowser
async def main():
bch = BCHydroApiBrowser("username", "password")
# Asynchronous usage:
print(await bch.get_usage())
print(await bch.get_latest_point())
print(await bch.get_latest_usage())
print(await bch.get_latest_interval())
print(await bch.get_latest_cost())
# Mostly synchronous usage:
await bch.refresh()
print(bch.usage)
print(bch.latest_point)
print(bch.latest_usage)
print(bch.latest_interval)
print(bch.latest_cost)
asyncio.run(main())
⚠ Read-Only Account Sharing
This project accesses your BCHydro account as would a human in a browser. It is recommended that a read-only account is set up for use with this project for more secure operation. Using this secondary account also enables backup access in the event of account lockout.
- Read-only accounts can be configured here after logging in.
Maintenance
Dependencies can be updated with pip-tools:
# Install pip-compile and pip-sync
pip install pip-tools
# Upgrade requirements
pip-compile --upgrade
Disclaimer
This package has been developed without the express permission of BC Hydro. It accesses data by pretending to be a browser and downloading a CSV with usage data. I would be happy to work with BCHydro on a better option however they have actively been working against us, blocking previous projects.
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 bchydrohomie-1.0.0.tar.gz.
File metadata
- Download URL: bchydrohomie-1.0.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aa9cb529e78018abca355215f0ebbbb0dd54996fa62c50f9658f4020aea11ed
|
|
| MD5 |
9377f51cf032d96fbd09c94208b55672
|
|
| BLAKE2b-256 |
6550c833a2ce54a86ec45927d473cf3c1ee8b1b489abe9f303a9b3c567fe5305
|
File details
Details for the file bchydrohomie-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bchydrohomie-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21ea9e510252694fbff72ec8fff09f111af0329cdb77252764b618fa0c2cc0d7
|
|
| MD5 |
1ab3b905acf650b20e2462ac53fb89a3
|
|
| BLAKE2b-256 |
89f2a4a85e5fe3e9be2427a2ffb953152a1ef43f6fdfa50bd01e51006bef795e
|