Giter Club home page Giter Club logo

opower-smud's Introduction

opower

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

Supported utilities:

  • condEdison (ConEd)
  • 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)
  • Pacific Gas & Electric (PG&E)
  • Puget Sound Energy (PSE)

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 pge.py.

Example

See demo.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 formatter
python -m pip install isort black
isort .
black .

# Run lint
python -m pip install flake8 ruff
flake8 .
ruff . --fix

# Run formatter and lint
isort . ; black . ; flake8 . ; ruff . --fix

# Run tests
python -m pip install pytest
pytest

# Run demo
python src/demo.py --help
# To output debug logs to a file, change DEBUG_LOG_RESPONSE to True in opower.py and run:
python src/demo.py --verbose 2> out.txt

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

opower-smud's People

Contributors

tronikos avatar trancefam avatar akoebbe avatar andylittle avatar chen-ye avatar paultyng avatar francoishuet avatar mjrsnyder avatar domoritz avatar fabaff avatar mark-ignacio avatar sebmaster avatar tboyce021 avatar kitchung avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.