Parsing P1 serial to Influx DB
Project description
p1-influx-db
Python package for reading DSMR/P1 telegrams from a smart meter and publishing the parsed values either to InfluxDB 2 over HTTP or to an MQTT broker.
What it does
The package exposes a module named p1_influx_db that reads telegrams from the configured serial device, parses the selected DSMR values, and forwards them using one of these output modes:
influx2: write parsed measurements to InfluxDB 2 using the HTTP APImqtt: publish parsed measurements as JSON messages over MQTT
The active behavior is driven by a TOML configuration file. A packaged example is available at p1_influx_db/example_config.toml.
Requirements
- Python 3.11 or newer
- Access to the P1 serial device exposed by your meter
- One configured output target: InfluxDB 2 or MQTT
Installation
Install from PyPI:
pip install p1-influx-db
Install from source with Poetry:
python -m poetry install
The project metadata currently defines mqtt, influxdb, and publishmethods extras, but the base install already includes both transport dependencies.
Running
Run the module with an explicit config file:
python -m p1_influx_db --config /path/to/config.toml
If --config is omitted, the module falls back to ./p1_influx_db/example_config.toml.
Configuration
The config file must contain:
- a
[p1]section with the serial device settings - either an
[influx2]section or an[mqtt]section
If both [mqtt] and [influx2] are present, the current entrypoint selects MQTT first.
All keys entries under [p1.*] should match DSMR field names exposed by dsmr-parser, such as ELECTRICITY_USED_TARIFF_1 or INSTANTANEOUS_VOLTAGE_L1.
Example configuration:
# TOML-based config
[influx2]
url = "http://localhost:8086"
org = "my-org"
token = "my-token"
[mqtt]
broker = "localhost"
port = 433
client_id = "client_id"
ca_certs = "/etc/certificate/abc"
certfile = "/etc/certificate/abc"
key = "etc/certificate/key"
max_times = 60
[p1]
device = "/dev/serial0"
[p1.electricity]
keys = ["ELECTRICITY_USED_TARIFF_1",
"ELECTRICITY_USED_TARIFF_2",
"ELECTRICITY_DELIVERED_TARIFF_1",
"ELECTRICITY_DELIVERED_TARIFF_2"]
[p1.electricity_current]
keys = ["CURRENT_ELECTRICITY_USAGE",
"CURRENT_ELECTRICITY_DELIVERY",
"INSTANTANEOUS_ACTIVE_POWER_L1_POSITIVE",
"INSTANTANEOUS_ACTIVE_POWER_L2_POSITIVE",
"INSTANTANEOUS_ACTIVE_POWER_L3_POSITIVE",
"INSTANTANEOUS_ACTIVE_POWER_L1_NEGATIVE",
"INSTANTANEOUS_ACTIVE_POWER_L2_NEGATIVE",
"INSTANTANEOUS_ACTIVE_POWER_L3_NEGATIVE"]
[p1.voltage]
keys = ["INSTANTANEOUS_VOLTAGE_L1",
"INSTANTANEOUS_VOLTAGE_L2",
"INSTANTANEOUS_VOLTAGE_L3"]
[p1.current]
keys = ["INSTANTANEOUS_CURRENT_L1",
"INSTANTANEOUS_CURRENT_L2",
"INSTANTANEOUS_CURRENT_L3"]
[p1.gas]
keys = ["HOURLY_GAS_METER_READING"]
Output behavior
- InfluxDB mode reads the
influx2configuration from the same TOML file and writes parsed measurements asynchronously. - MQTT mode publishes JSON payloads under topics prefixed with
p1/. - MQTT TLS certificates are required by the current client implementation because TLS is always enabled.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file p1_influx_db-3.0.0.tar.gz.
File metadata
- Download URL: p1_influx_db-3.0.0.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ef94470ae7dc285f6c5c5672a509a3e0f810ee44b1daa47caa4cf1a04fdf31a
|
|
| MD5 |
7d215b052355fb5f77d130eb02dc874b
|
|
| BLAKE2b-256 |
1e472afecf60db85b9d15c167f8f18c8026f7c1f1ecc5f721f68b6baa66620b4
|
Provenance
The following attestation bundles were made for p1_influx_db-3.0.0.tar.gz:
Publisher:
python-package.yml on yfredrix/p1-influx-db
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p1_influx_db-3.0.0.tar.gz -
Subject digest:
7ef94470ae7dc285f6c5c5672a509a3e0f810ee44b1daa47caa4cf1a04fdf31a - Sigstore transparency entry: 1511760859
- Sigstore integration time:
-
Permalink:
yfredrix/p1-influx-db@e8145942624b54ee9eaa88cbd94b3d16082cc99a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yfredrix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yml@e8145942624b54ee9eaa88cbd94b3d16082cc99a -
Trigger Event:
push
-
Statement type:
File details
Details for the file p1_influx_db-3.0.0-py3-none-any.whl.
File metadata
- Download URL: p1_influx_db-3.0.0-py3-none-any.whl
- Upload date:
- Size: 22.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
638056292ce59a0606117762a5c2c54c3231cde3f17c2e9da35ce7301dd468ab
|
|
| MD5 |
c57c82c1bf070b924ad6601062b64ba8
|
|
| BLAKE2b-256 |
a7140516735197ff8ca10f1f4eebd8b4f2449716185188154ae01ffd85f411df
|
Provenance
The following attestation bundles were made for p1_influx_db-3.0.0-py3-none-any.whl:
Publisher:
python-package.yml on yfredrix/p1-influx-db
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
p1_influx_db-3.0.0-py3-none-any.whl -
Subject digest:
638056292ce59a0606117762a5c2c54c3231cde3f17c2e9da35ce7301dd468ab - Sigstore transparency entry: 1511762039
- Sigstore integration time:
-
Permalink:
yfredrix/p1-influx-db@e8145942624b54ee9eaa88cbd94b3d16082cc99a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yfredrix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package.yml@e8145942624b54ee9eaa88cbd94b3d16082cc99a -
Trigger Event:
push
-
Statement type: