Prometheus exporter for Linky electricity meter serial TIC data.
  • Python 94.4%
  • Makefile 5.6%
Find a file
2026-02-24 15:23:57 +01:00
.gitignore ci: adding .gitignore 2025-06-30 13:24:11 +02:00
linky_exporter.py wip 2025-11-27 18:45:43 +01:00
Makefile chore(linting) adding linting and Makefile shortcut 2025-07-22 14:39:32 +02:00
poetry.lock chore(linting) adding linting and Makefile shortcut 2025-07-22 14:39:32 +02:00
pyproject.toml chore(linting) adding linting and Makefile shortcut 2025-07-22 14:39:32 +02:00
README.md docs: add README with usage, configuration, and metrics reference 2026-02-24 15:23:57 +01:00

linky-exporter

A Prometheus exporter for the French Linky electricity meter. Reads consumption data from the meter's serial TIC (Télé-Information Client) output and exposes it as Prometheus metrics.

Features

  • Reads TIC frames from the Linky meter over serial (historical mode)
  • Exposes energy indexes, intensity, apparent power, and status as Prometheus metrics
  • Tracks consumption cost based on configurable per-index tariff rates
  • Supports all standard tariff options: Base, HC/HP, EJP, Tempo

Installation

pip install linky-exporter

Or with Poetry:

poetry install

Requirements

  • Python >= 3.9
  • A serial adapter connected to the Linky meter's TIC output (e.g. /dev/serial0 on a Raspberry Pi, or a USB-to-serial adapter)
  • Read permission on the serial device (typically requires the dialout group)

Usage

python linky_exporter.py

The exporter starts an HTTP server (default port 9100) and begins polling the meter at a configurable interval (default 240s).

Scrape http://<host>:9100/metrics with Prometheus.

Configuration

Configuration is read from /etc/linky-exporter.json and can be overridden with environment variables (uppercased, _-separated path, e.g. PROMETHEUS_PORT=9101).

Example configuration

{
  "device": "/dev/serial0",
  "baudrate": 1200,
  "loop": {
    "interval": 240
  },
  "contract": {
    "monthlyrate": 15.48,
    "timestart": 0.0
  },
  "indexwhrates": {
    "BASE": 0.2516,
    "HCHC": 0.2068,
    "HCHP": 0.2700
  },
  "prometheus": {
    "port": 9100,
    "namespace": "linky"
  },
  "linky": {
    "checksummethod": 1
  },
  "logging": {
    "level": "WARNING"
  }
}

Parameters

Parameter Default Description
device /dev/serial0 Serial device path
baudrate 1200 Serial baud rate
name linky-exporter Application name (used by daemon-metrics)
loop.interval 240 Polling interval in seconds
contract.monthlyrate 0 Monthly subscription rate in euros
contract.timestart 0.0 Custom _created timestamp for index counters (useful for billing period alignment)
indexwhrates.<INDEX> 0 Rate in euros per Wh for each index (e.g. BASE, HCHC, HCHP, ...)
prometheus.port 9100 HTTP server port for the /metrics endpoint
prometheus.namespace linky Prometheus metric name prefix
linky.checksummethod 1 TIC checksum method (1 or 2, per Enedis-NOI-CPT_02E spec)
logging.level WARNING Log level (DEBUG, INFO, WARNING, ERROR, FATAL)

Metrics

All metrics are prefixed with the configured namespace (default linky_).

Metric Type Labels Description
linky_index_total Counter address, index Cumulative energy consumption in Wh per tariff index
linky_ac_power Gauge address Apparent power in VA
linky_intensity Gauge address, label Current intensity in A (IINST, ADPS, IMAX, ISOUSC)
linky_rate Gauge address, index Configured tariff rate in euros (per Wh or monthly)
linky_cost_total Counter address, index Accumulated cost in euros per tariff index
linky_status_info Info Remaining TIC fields (contract number, meter status, etc.)

The address label is the meter's ADCO contract number.

Supported TIC indexes

Index Tariff option
BASE Base
HCHC, HCHP Heures Creuses / Heures Pleines
EJPHN, EJPHPM EJP
BBRHCJB, BBRHPJB, BBRHCJW, BBRHPJW, BBRHCJR, BBRHPJR Tempo

Development

poetry install
make lint    # run all linting checks (pep8, black, pylint, mypy)
make build   # lint + build
make publish # build + publish to PyPI

License

By François Schmidts.