Skip to content

gas2mqtt

License: MIT Python cosalette

Read your domestic gas meter with a magnetometer and publish to MQTT.

gas2mqtt attaches a QMC5883L magnetometer to a Raspberry Pi, detects gas meter rotations via a Schmitt trigger, and publishes counter ticks, temperature, and optional debug data to an MQTT broker — ready for Home Assistant or any MQTT consumer.


Features

  • Gas tick detection — Schmitt trigger with configurable threshold and hysteresis
  • Temperature monitoring — PT1-filtered, empirically calibrated
  • Consumption tracking — optional cumulative m³ counter with MQTT set command
  • Raw magnetometer output — optional debug device for calibration
  • Health reporting — automatic heartbeats, per-device availability, and LWT
  • Docker-ready — single docker compose up deployment

Hardware

Component Details
Sensor QMC5883L 3-axis digital magnetometer
Interface I2C (default bus 1, address 0x0D)
Platform Raspberry Pi (or any Linux SBC with I2C)

  • Getting Started


    Install gas2mqtt, connect the sensor, and see your first MQTT messages.

    Get started

  • Configuration


    All settings — environment variables, .env files, and CLI flags.

    Configure

  • MQTT Topics


    Topic reference with payload schemas, directions, and retain flags.

    Topics

  • Architecture


    Hexagonal architecture, domain logic, and cosalette framework integration.

    Architecture

  • API Reference


    Auto-generated reference for settings, ports, domain logic, devices, and adapters.

    Reference