Skip to main content

air2mqtt

CI PyPI Python License: MIT

Indoor air quality for Home Assistant, from a Raspberry Pi.

air2mqtt reads a BME680 (temperature, humidity, pressure) and an MH-Z19 (CO₂) sensor on a Raspberry Pi and publishes the values to Home Assistant via MQTT.

BME680 ──I²C──┐
              ├── Raspberry Pi (air2mqtt) ──MQTT──> Broker ──> Home Assistant
MH-Z19 ──UART─┘

Features

  • No setup in Home Assistant: the device and its entities appear automatically through MQTT discovery.
  • Runs unattended as a systemd service and reconnects to the broker on its own.
  • Reliable availability: the device shows as unavailable when the Pi goes offline, and values expire if a sensor stops reporting.
  • Fault tolerant: if one sensor is missing or fails, the other keeps working.

Requirements

  • Raspberry Pi (or another Linux board) with Python 3.11 or newer
  • A BME680 and/or an MH-Z19 sensor, wired up with I²C/UART enabled
  • Home Assistant 2024.11 or newer with an MQTT broker

See Prerequisites for wiring and broker setup.

Quick start

1. Install into a virtual environment:

sudo mkdir /opt/air2mqtt && sudo chown $USER:$USER /opt/air2mqtt
cd /opt/air2mqtt
python3 -m venv .venv
.venv/bin/pip install air2mqtt

2. Configure. Create /opt/air2mqtt/.env with your broker details:

MQTT_HOST=homeassistant.local
MQTT_USERNAME=air2mqtt
MQTT_PASSWORD=change-me

3. Run:

.venv/bin/air2mqtt

The device appears in Home Assistant under Settings → Devices & services → MQTT. To start air2mqtt automatically at boot, set it up as a systemd service.

Documentation

Guide Contents
Prerequisites Sensors and wiring, enabling I²C/UART, Home Assistant and MQTT broker
Installation Installing, running as a service, updating and uninstalling
Configuration All settings and their defaults
Usage Operating the service, MQTT topics and troubleshooting
Development Setup, tests, conventions and releasing
Changelog Changes in each release

Metadata

Release files for air2mqtt 0.2.0

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

Source distribution (sdist)

Source distribution for air2mqtt 0.2.0
File Size Uploaded Provenance Actions
air2mqtt-0.2.0.tar.gz 16.3 kB Without provenance Details for air2mqtt-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for air2mqtt 0.2.0
File Interpreter ABI Platform Actions
air2mqtt-0.2.0-py3-none-any.whl Python 3 none any Details for air2mqtt-0.2.0-py3-none-any.whl

Total release size: 32.6 kB

Release files / air2mqtt-0.2.0.tar.gz

Download URL air2mqtt-0.2.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f0ef124d65d29a363cba46d5d870b11e0cf47168b2e8660f8616c428fda23a1c
BLAKE2b-256 checksum
How to use checksums
4aafe85fc1b5b8fbf50a01752547a2d3fafb83fb64525a840404775cee16fb03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / air2mqtt-0.2.0-py3-none-any.whl

Download URL air2mqtt-0.2.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
955e5b6fd655b6c455db4cca1a0fd2b16dd87cac037cea9bbeaf407a810f2daa
BLAKE2b-256 checksum
How to use checksums
bedc679638f8ef1d6fd7ed379115b50e350d43b016bdf96e06cf3c921e1474bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for air2mqtt 0.2.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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