Advanced: metering data API - plan-d-io/P1-dongle GitHub Wiki
The P1-dongle has a REStful API to access the most recent received data from the P1 port. This API can be accessed over HTTP or MQTT.
Endpoint <dongle ip>/data
Supported methods GET,
A GET to the config endpoint returns all configured meter readings present in the meter telegram.
Example output:
[
{
"value": 125443.07,
"unit": "kWh",
"timestamp": 1291890620,
"friendly_name": "Total energy consumed",
"sensorId": "beta_meter.total_energy_consumed",
"entity": "Beta meter",
"metric": "GridElectricityImport",
"metricKind": "cumulative"
},
{
"value": 126052.26,
"unit": "kWh",
"timestamp": 1291890620,
"friendly_name": "Total energy injected",
"sensorId": "beta_meter.total_energy_injected",
"entity": "Beta meter",
"metric": "GridElectricityExport",
"metricKind": "cumulative"
}
]
For more information about the formatting, please see the payload format page.
A GET to the <dongle ip>/data?basic endpoint returns the most important meter readings present in the meter telegram.
When MQTT is enabled, the dongle pushes its metering data to the <mqtt-prefix>/ topic, with each detected and enabled measurement sent to a different topic.
The
<mqtt-prefix>defaults todata/devices/utility_meter
The default MQTT topic structure is
data/devices/utility_meter/[MEASUREMENT]
with [MEASUREMENT] being the name of the measurement.
E.g. the value of the active power consumption measurement is sent to data/devices/utility_meter/active_power_consumption. The same formatting as the HTTP API applies.
If you run mosquitto as MQTT broker on your server, you can scan the topics with the command mosquitto_sub -v -t data/devices/utility_meter/#.
The frequency of the MQTT data push is dependent on the Update interval (s) setting.
The dongle uses the <mqtt-prefix> to post alive and last will messages. As long as the dongle is online and connected, this topic will retain the message online. If the connection to the broker is lost, this topic will display offline.
If enabled, the dongle will push the complete P1 DSMR telegram to <mqtt-prefix>/telegram.
Warning: the full telegram is quite large (>4kB). Make sure your MQTT broker supports large payloads.