Skip to main content

sml-exporter

Prometheus Exporter for smart meters that communicate using the SML language, which is widely available through read-only interfaces on smart power meters in Germany.

Built on top of pysml, which does most of the heavy lifting, by parsing the message stream into python objects.

Install

The package can be installed from PyPi. It provides an executable that should be installed automatically into your environment.

$ python3 -m pip install sml-exporter

Update an existing installation using

$ python3 -m pip install -U sml-exporter

Usage

The only two options available configure the serial interface where your USB to D0 (or similiar) adapter is connected at. Setting an explicit port number is useful when you have multiple power meters.

❯ sml-exporter --help
Usage: sml-exporter [OPTIONS] TTY

Options:
  -p, --http-port INTEGER RANGE  HTTP Port for the Prometheus Exporter
                                 [default: 9761]

  --help                         Show this message and exit.

Make sure to use stable device symlinks provided by /dev/serial/by-id/, so you don't mixup different serial devices.

# ls /dev/serial/by-id/
usb-FTDI_FT232R_USB_UART_XXXXXXXX-if00-port0
usb-FTDI_FT232R_USB_UART_YYYYYYYY-if00-port0

Metrics

Metrics are identified by their OBIS numbering and transformed into a the following metrics:

# HELP smartmeter_wirkarbeit_verbrauch_total_wh Summe Wirkarbeit Verbrauch über alle Tarife (1-0:1.8.0*255)
# TYPE smartmeter_wirkarbeit_verbrauch_total_wh gauge
smartmeter_wirkarbeit_verbrauch_total_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 6.8437382e+06
# HELP smartmeter_wirkarbeit_lieferung_total_wh Summe Wirkarbeit Lieferung über alle Tarife (1-0:2.8.0*255)
# TYPE smartmeter_wirkarbeit_lieferung_total_wh gauge
smartmeter_wirkarbeit_lieferung_total_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 5.8312058e+06
# HELP smartmeter_wirkarbeit_verbrauch_tarif1_wh Summe Wirkarbeit Verbrauch im Tarif 1 (1-0:1.8.1*255)
# TYPE smartmeter_wirkarbeit_verbrauch_tarif1_wh gauge
smartmeter_wirkarbeit_verbrauch_tarif1_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 6.8437382e+06
# HELP smartmeter_wirkarbeit_lieferung_tarif1_wh Summe Wirkarbeit Lieferung im Tarif 1 (1-0:2.8.1*255)
# TYPE smartmeter_wirkarbeit_lieferung_tarif1_wh gauge
smartmeter_wirkarbeit_lieferung_tarif1_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 5.8312058e+06
# HELP smartmeter_wirkarbeit_verbrauch_tarif2_wh Summe Wirkarbeit Verbrauch im Tarif 2 (1-0:1.8.2*255)
# TYPE smartmeter_wirkarbeit_verbrauch_tarif2_wh gauge
smartmeter_wirkarbeit_verbrauch_tarif2_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 0.0
# HELP smartmeter_wirkarbeit_lieferung_tarif2_wh Summe Wirkarbeit Lieferung im Tarif 2 (1-0:2.8.2*255)
# TYPE smartmeter_wirkarbeit_lieferung_tarif2_wh gauge
smartmeter_wirkarbeit_lieferung_tarif2_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 0.0
# HELP smartmeter_wirkleistung_w Momentane Wirkleistung (1-0:16.7.0*255)
# TYPE smartmeter_wirkleistung_w gauge
smartmeter_wirkleistung_w{device="1 EMH00 XXXXXXXX",vendor="EMH"} 892.4
# HELP smartmeter_wirkarbeit_verbrauch_total_wh Summe Wirkarbeit Verbrauch über alle Tarife (1-0:1.8.0*255)
# TYPE smartmeter_wirkarbeit_verbrauch_total_wh gauge
smartmeter_wirkarbeit_verbrauch_total_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 6.8437382e+06
# HELP smartmeter_wirkarbeit_lieferung_total_wh Summe Wirkarbeit Lieferung über alle Tarife (1-0:2.8.0*255)
# TYPE smartmeter_wirkarbeit_lieferung_total_wh gauge
smartmeter_wirkarbeit_lieferung_total_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 5.8312058e+06
# HELP smartmeter_wirkarbeit_verbrauch_tarif1_wh Summe Wirkarbeit Verbrauch im Tarif 1 (1-0:1.8.1*255)
# TYPE smartmeter_wirkarbeit_verbrauch_tarif1_wh gauge
smartmeter_wirkarbeit_verbrauch_tarif1_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 6.8437382e+06
# HELP smartmeter_wirkarbeit_lieferung_tarif1_wh Summe Wirkarbeit Lieferung im Tarif 1 (1-0:2.8.1*255)
# TYPE smartmeter_wirkarbeit_lieferung_tarif1_wh gauge
smartmeter_wirkarbeit_lieferung_tarif1_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 5.8312058e+06
# HELP smartmeter_wirkarbeit_verbrauch_tarif2_wh Summe Wirkarbeit Verbrauch im Tarif 2 (1-0:1.8.2*255)
# TYPE smartmeter_wirkarbeit_verbrauch_tarif2_wh gauge
smartmeter_wirkarbeit_verbrauch_tarif2_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 0.0
# HELP smartmeter_wirkarbeit_lieferung_tarif2_wh Summe Wirkarbeit Lieferung im Tarif 2 (1-0:2.8.2*255)
# TYPE smartmeter_wirkarbeit_lieferung_tarif2_wh gauge
smartmeter_wirkarbeit_lieferung_tarif2_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 0.0
# HELP smartmeter_wirkleistung_w Momentane Wirkleistung (1-0:16.7.0*255)
# TYPE smartmeter_wirkleistung_w gauge
smartmeter_wirkleistung_w{device="1 EMH00 XXXXXXXX",vendor="EMH"} 892.4# HELP smartmeter_wirkarbeit_verbrauch_total_wh Summe Wirkarbeit Verbrauch über alle Tarife (1-0:1.8.0*255)
# TYPE smartmeter_wirkarbeit_verbrauch_total_wh gauge
smartmeter_wirkarbeit_verbrauch_total_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 6.8437382e+06
# HELP smartmeter_wirkarbeit_lieferung_total_wh Summe Wirkarbeit Lieferung über alle Tarife (1-0:2.8.0*255)
# TYPE smartmeter_wirkarbeit_lieferung_total_wh gauge
smartmeter_wirkarbeit_lieferung_total_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 5.8312058e+06
# HELP smartmeter_wirkarbeit_verbrauch_tarif1_wh Summe Wirkarbeit Verbrauch im Tarif 1 (1-0:1.8.1*255)
# TYPE smartmeter_wirkarbeit_verbrauch_tarif1_wh gauge
smartmeter_wirkarbeit_verbrauch_tarif1_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 6.8437382e+06
# HELP smartmeter_wirkarbeit_lieferung_tarif1_wh Summe Wirkarbeit Lieferung im Tarif 1 (1-0:2.8.1*255)
# TYPE smartmeter_wirkarbeit_lieferung_tarif1_wh gauge
smartmeter_wirkarbeit_lieferung_tarif1_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 5.8312058e+06
# HELP smartmeter_wirkarbeit_verbrauch_tarif2_wh Summe Wirkarbeit Verbrauch im Tarif 2 (1-0:1.8.2*255)
# TYPE smartmeter_wirkarbeit_verbrauch_tarif2_wh gauge
smartmeter_wirkarbeit_verbrauch_tarif2_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 0.0
# HELP smartmeter_wirkarbeit_lieferung_tarif2_wh Summe Wirkarbeit Lieferung im Tarif 2 (1-0:2.8.2*255)
# TYPE smartmeter_wirkarbeit_lieferung_tarif2_wh gauge
smartmeter_wirkarbeit_lieferung_tarif2_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 0.0
# HELP smartmeter_wirkleistung_w Momentane Wirkleistung (1-0:16.7.0*255)
# TYPE smartmeter_wirkleistung_w gauge
smartmeter_wirkleistung_w{device="1 EMH00 XXXXXXXX",vendor="EMH"} 892.4# HELP smartmeter_wirkarbeit_verbrauch_total_wh Summe Wirkarbeit Verbrauch über alle Tarife (1-0:1.8.0*255)
# TYPE smartmeter_wirkarbeit_verbrauch_total_wh gauge
smartmeter_wirkarbeit_verbrauch_total_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 6.8437382e+06
# HELP smartmeter_wirkarbeit_lieferung_total_wh Summe Wirkarbeit Lieferung über alle Tarife (1-0:2.8.0*255)
# TYPE smartmeter_wirkarbeit_lieferung_total_wh gauge
smartmeter_wirkarbeit_lieferung_total_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 5.8312058e+06
# HELP smartmeter_wirkarbeit_verbrauch_tarif1_wh Summe Wirkarbeit Verbrauch im Tarif 1 (1-0:1.8.1*255)
# TYPE smartmeter_wirkarbeit_verbrauch_tarif1_wh gauge
smartmeter_wirkarbeit_verbrauch_tarif1_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 6.8437382e+06
# HELP smartmeter_wirkarbeit_lieferung_tarif1_wh Summe Wirkarbeit Lieferung im Tarif 1 (1-0:2.8.1*255)
# TYPE smartmeter_wirkarbeit_lieferung_tarif1_wh gauge
smartmeter_wirkarbeit_lieferung_tarif1_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 5.8312058e+06
# HELP smartmeter_wirkarbeit_verbrauch_tarif2_wh Summe Wirkarbeit Verbrauch im Tarif 2 (1-0:1.8.2*255)
# TYPE smartmeter_wirkarbeit_verbrauch_tarif2_wh gauge
smartmeter_wirkarbeit_verbrauch_tarif2_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 0.0
# HELP smartmeter_wirkarbeit_lieferung_tarif2_wh Summe Wirkarbeit Lieferung im Tarif 2 (1-0:2.8.2*255)
# TYPE smartmeter_wirkarbeit_lieferung_tarif2_wh gauge
smartmeter_wirkarbeit_lieferung_tarif2_wh{device="1 EMH00 XXXXXXXX",vendor="EMH"} 0.0
# HELP smartmeter_wirkleistung_w Momentane Wirkleistung (1-0:16.7.0*255)
# TYPE smartmeter_wirkleistung_w gauge
smartmeter_wirkleistung_w{device="1 EMH00 XXXXXXXX",vendor="EMH"} 892.4

Caveats

The exporter caches new values as they arrive, until they are overwritten by newer ones. This design was chosen as the arrival of data usually does not match up with any particular polling interval. In an ideal world we would migrate this exporter to reuse pushgateway. This did not happen because I don't have any experience using it.

License

This software is provided under the MIT license and uses

Metadata

Release files for sml-exporter 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sml-exporter 0.1.5
File Size Uploaded Provenance
sml_exporter-0.1.5.tar.gz 5.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sml-exporter 0.1.5
File Interpreter ABI Platform
sml_exporter-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / sml_exporter-0.1.5.tar.gz

Download URL sml_exporter-0.1.5.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c2b32580c0107e59f6e63cdeb8d631738dc0fa593f4faed4793acbcc80b8f79a
BLAKE2b-256 checksum
How to use checksums
2aea670712cf6807a11ede686853677f57e0f01142125322f09e6555f6b8ee93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.11 Linux/6.2.13

Release files / sml_exporter-0.1.5-py3-none-any.whl

Download URL sml_exporter-0.1.5-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7de70ad2daecd73f375b296931667316970f009676438eae21cc818b636b9362
BLAKE2b-256 checksum
How to use checksums
94e149f30bff5495aa8baa74722b2d7c205367b22be4891c8f74459dd04ba046
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.11 Linux/6.2.13

Security for sml-exporter 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page