Skip to main content

Retrieve interval meter data from SA Power Networks

Project description

sapnmeterdata

sapnmeterdata is an unofficial Python client for downloading NEM12 interval meter data from SA Power Networks' Your Meter Data customer portal.

It signs in with an existing SAPN portal account, discovers the NMIs assigned to that account, requests a detailed NEM12 report, and returns the readings as a Pandas DataFrame.

This project is not affiliated with or supported by SA Power Networks. It relies on the portal's web interface and may require updates when that interface changes.

Installation

python -m pip install sapnmeterdata

Version 0.3.1 requires Python 3.12 or newer. It uses nemreader 1.x and Polars internally while preserving the package's existing public Pandas DataFrame result.

SAPN account

Register for the free Your Meter Data service before using this package:

https://www.sapowernetworks.com.au/your-power/manage-your-power-use/your-meter-data/

Only access NMIs for which you are the customer or an authorised representative. Do not commit SAPN credentials to source control.

Example

import os
from datetime import datetime, timedelta

from sapnmeterdata import login


sapn = login(
    os.environ["SAPN_EMAIL"],
    os.environ["SAPN_PASSWORD"],
)

print(sapn.getNMIs())

end = datetime.now()
start = end - timedelta(days=14)
data = sapn.getAllData(start, end)

print(data)

Retrieve one NMI:

from sapnmeterdata import meter


single_meter = meter("YOUR_NMI", sapn)
data = single_meter.getdata(start, end)

Retrieve selected NMIs:

from sapnmeterdata import getall


data = getall(
    ["FIRST_NMI", "SECOND_NMI"],
    start,
    end,
    sapn,
)

If one NMI has no downloadable data for the requested period, getall() emits a MeterDataWarning, skips only that NMI, and continues retrieving the others. The returned DataFrame records those NMIs in data.attrs["skipped_nmis"]. Calling meter.getdata() directly for the same NMI raises NoDataError.

Returned data

Meter readings are returned as a Pandas DataFrame:

  • the index contains the interval start timestamp;
  • columns use a two-level meter / channel MultiIndex;
  • multiple NMIs are outer-joined by timestamp.

Common NEM12 channels include E1 for general consumption, E2 for controlled load, and B1 for solar export. The exact channels depend on the meter configuration.

SAPN data is historical interval data, not a real-time power feed.

Errors

The public exception types are:

  • LoginError — the login form changed, credentials were rejected, or SAPN requested another authentication step;
  • AuthError — the authenticated session expired or Salesforce remoting metadata could not be found;
  • NoDataError — SAPN returned no downloadable NEM12 payload for a particular NMI and date range;
  • FetchError — another portal request, RPC response, or NEM12 parse failed.

MeterDataWarning is emitted when getall() catches NoDataError for one NMI and continues with the rest.

Development

Create a Python 3.12+ virtual environment and install the package with its current development tools:

python -m pip install ".[dev]"

Run the unit tests:

python -m unittest discover -s tests -v

Build the source distribution and wheel:

python -m build

See RELEASING.md for the GitHub Actions and PyPI Trusted Publishing setup.

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

sapnmeterdata-0.3.1.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sapnmeterdata-0.3.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file sapnmeterdata-0.3.1.tar.gz.

File metadata

  • Download URL: sapnmeterdata-0.3.1.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for sapnmeterdata-0.3.1.tar.gz
Algorithm Hash digest
SHA256 5c118bf0cb7efd18ba4257c5d9b76a22feca6e70b5e55d3078c6be882dfd758d
MD5 c4af7b6449f9d0054d0ce6688df5e855
BLAKE2b-256 0d9aee8ee918b6aee29a8f41b0862da057255a96b6859c7c6b13a652377c5642

See more details on using hashes here.

Provenance

The following attestation bundles were made for sapnmeterdata-0.3.1.tar.gz:

Publisher: publish.yml on bfulham/sapnmeterdata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sapnmeterdata-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: sapnmeterdata-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for sapnmeterdata-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f24014bbca8a67f99315e0d2c8bc0ff8eccbe16d0d33edcb407a1ece7f23763
MD5 fc965b2c2b1311f24b57671f641f0140
BLAKE2b-256 4cba4af212dd52e01bd9e41c8160a476fc74d29d2cf53e9a36d91a44f2a073cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for sapnmeterdata-0.3.1-py3-none-any.whl:

Publisher: publish.yml on bfulham/sapnmeterdata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page