Skip to main content

PG&E Share My Data API for Self Access users

Project description

PG&E Share My Data API for Self Access

This python module is a helper for the Share My Data API which allows the utility customer to download their meter data using the Energy Services Provider Interface (ESPI), part of the Green Button standard. Click here to register with PG&E as a Self Access user

Install

pip

pip install pgesmd_self_access

source

git clone https://github.com/JPHutchins/pgesmd_self_access

cd pgesmd_self_access

Virtual environment is optional but suggested if you are fiddling around:

python3 -m venv venv

source venv/bin/activate

Install the dependencies:

pip install -r requirements.txt

Access Your Data

In order to listen for messages from the PGE server you will need to provide the path to the SSL certificate (or symlink) that you provided to PGE. For example, the files (or symlinks) could be in ~/pgesmd_self_access/cert/cert.crt and ~/pgesmd_self_access/cert/private.key.

Create a file ~/pgesmd_self_access/auth/auth.json:

{
  "third_party_id" : string, from PGE - use "" if unknown
  "client_id" : string, from PGE after completing registration
  "client_secret" : string, from PGE after completing registration
  "cert_crt_path" : string, like above
  "cert_key_path" : string, like above
}

You may test some commands in the REPL to verify that everything is set up correctly:

from pgesmd_self_access.api import SelfAccessApi
pge_api = SelfAccessApi.auth( < full path to the auth.json > ) # for example, /home/jp/pgesmd_self_access/auth/auth.json
pge_api.get_service_status()

Complete the testing as required by PG&E:

from pgesmd_self_access.api import PgeRegister
pge_reg = PgeRegister() # this will look for your auth.json at ./auth/auth.json
pge_reg.complete_testing() # hopefully this succeeds - if not check the SMD Portal and auth

PGE SMD will send data to the notification URI that you specified when you registered. Login to the PGE SMD portal to change it if needed. In order to listen for the messages from PGE you will need to forward port 443 to the server that this module runs at (default) port 7999. Once it is open you can start the server:

from pgesmd_self_access.api import SelfAccessApi
from pgesmd_self_access.server import SelfAccessServer
from pgesmd_self_access.helpers import save_espi_xml
pge_api = SelfAccessApi.auth( < full path to the auth.json > )
SelfAccessServer(pge_api, save_file=save_espi_xml)

The PGE server usually takes between 10-40 seconds to package and send the message. The helper function will save the response XML in your current working directory. You may like to see helpers.parse_espi_xml for more possibilities.

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

pgesmd_self_access-0.0.6.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

pgesmd_self_access-0.0.6-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file pgesmd_self_access-0.0.6.tar.gz.

File metadata

  • Download URL: pgesmd_self_access-0.0.6.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for pgesmd_self_access-0.0.6.tar.gz
Algorithm Hash digest
SHA256 25eacbde2396f34a5e2ef10e38ecd5c4054312e6c6065bcf5b3aab996fddfb74
MD5 ea245cb36d8ad5f81a211a4e090ce3de
BLAKE2b-256 7f930ea1ede590568e2a8e81f9cc6bf7bab44cb0ff6691ed8feb65a00325b747

See more details on using hashes here.

File details

Details for the file pgesmd_self_access-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: pgesmd_self_access-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for pgesmd_self_access-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bb22ee2cdb23cb0625c8f6bb87e3d96e20bab50ac31df5ea68d910746e81e256
MD5 4fe79d5327799b91ce86fa8eb57d6d67
BLAKE2b-256 c38e6a182be72d0ac2966747466089f53b252ccee2cbb65217406502b4a971e6

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