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
DEVICE_ID=livingroom

Set DEVICE_ID to a stable name. It defaults to the hostname, so renaming the Pi would otherwise create a new device in Home Assistant.

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 1.0.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 1.0.0
File Size Uploaded Provenance Actions
air2mqtt-1.0.0.tar.gz 17.9 kB Without provenance Details for air2mqtt-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 34.4 kB

Release files / air2mqtt-1.0.0.tar.gz

Download URL air2mqtt-1.0.0.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
943cea20190daf070c881863b16d0845a899b0aea73c497446c428a1a022b350
BLAKE2b-256 checksum
How to use checksums
9ce2424afae787567c2f2005fd901ac7400412e755630ffce293363e036050f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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-1.0.0-py3-none-any.whl

Download URL air2mqtt-1.0.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9cc26b5332f3de49dfafcd97831dfc41c7c2cd8521f2368736babee809e7ecb3
BLAKE2b-256 checksum
How to use checksums
a2360226e367d64f411a932e338e70bfc3e7037b245978e2fda5a0b7bcad21d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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 1.0.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