Skip to main content

A Python library for getting historical and forecasted usage/cost from utilities that use opower.com such as PG&E

Project description

opower

A Python library for getting historical and forecasted usage/cost from utilities that use opower.com such as PG&E.

Supported utilities (in alphabetical order):

  • American Electric Power (AEP) subsidiaries
    • AEP Ohio
    • AEP Texas
    • Appalachian Power
    • Indiana Michigan Power
    • Kentucky Power
    • Public Service Company of Oklahoma (PSO)
    • Southwestern Electric Power Company (SWEPCO)
  • Arizona Public Service (APS)
  • City of Austin Utilities
  • Consolidated Edison (ConEd)
    • Orange & Rockland Utilities (ORU)
  • Duquesne Light Company (DQE)
  • Enmax Energy
  • Evergy
  • Exelon subsidiaries
    • Atlantic City Electric
    • Baltimore Gas and Electric (BGE)
    • Commonwealth Edison (ComEd)
    • Delmarva Power
    • PECO Energy Company (PECO)
    • Potomac Electric Power Company (Pepco)
  • Mercury NZ Limited
  • National Grid NY Upstate
  • Pacific Gas & Electric (PG&E)
  • Portland General Electric (PGE)
  • Puget Sound Energy (PSE)
  • Sacramento Municipal Utility District (SMUD)
  • Seattle City Light (SCL)

Support a new utility

To add support for a new utility that uses opower JSON API (you can tell if the energy dashboard of your utility makes network requests to opower.com, e.g. pge.opower.com in the network tab of your browser's developer tools) add a file similar to pge.py or pse.py or bge.py etc.

Name the file after the utility website, e.g. pge.py for pge.com.

Since this library is used by Home Assistant, see https://www.home-assistant.io/integrations/opower/, per https://github.com/home-assistant/architecture/blob/master/adr/0004-webscraping.md we cannot have a dependency on a headless browser and we can only parse HTML during login.

An exception is made for the authentication phase. An integration is allowed to extract fields from forms. To make it more robust, data should not be gathered by scraping individual fields but instead scrape all fields at once.

So follow that advice and try to scrape all fields at once, similar to the get_form_action_url_and_hidden_inputs in helpers.py.

Development environment

python3 -m venv .venv
source .venv/bin/activate
# for Windows CMD:
# .venv\Scripts\activate.bat
# for Windows PowerShell:
# .venv\Scripts\Activate.ps1

# Install dependencies
python -m pip install --upgrade pip
python -m pip install .

# Run pre-commit
python -m pip install pre-commit
pre-commit install
pre-commit run --all-files

# Alternative: run formatter, lint, and type checking
python -m pip install isort black flake8 ruff mypy
isort . ; black . ; flake8 . ; ruff check . --fix ; mypy --install-types .

# Run tests
python -m pip install pytest python-dotenv
pytest

# Run command line
python -m opower --help
# To output debug logs and API responses to a file run:
python -m opower -vv 2> out.txt

# Build package
python -m pip install build
python -m build

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

opower-0.8.5.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

opower-0.8.5-py3-none-any.whl (51.9 kB view details)

Uploaded Python 3

File details

Details for the file opower-0.8.5.tar.gz.

File metadata

  • Download URL: opower-0.8.5.tar.gz
  • Upload date:
  • Size: 38.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.10

File hashes

Hashes for opower-0.8.5.tar.gz
Algorithm Hash digest
SHA256 009f5ae9fd6a5c69f16da628f74120ca83f0cac0a0eaafaf4c2c61d2fb0a647c
MD5 7400aa8273d1d4082a14a8d3f22c7e9f
BLAKE2b-256 6950c5c20cd3b524744f8a88ac4973bf555e5c3353057d812d0d69d22ed10e4b

See more details on using hashes here.

File details

Details for the file opower-0.8.5-py3-none-any.whl.

File metadata

  • Download URL: opower-0.8.5-py3-none-any.whl
  • Upload date:
  • Size: 51.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.10

File hashes

Hashes for opower-0.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1d1b0dc68b5004c1713f352128417528eafc6c6d80319029d2819fea294d62b9
MD5 fbbf4df4ee2e2f319ed9d14e70296c93
BLAKE2b-256 852433201a3bb2c04666a6ea60729592e086df64ec984f04e3ed574b1c29d779

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