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

License

MIT

Metadata

Release files for air2mqtt 0.1.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.1.0
File Size Uploaded Provenance Actions
air2mqtt-0.1.0.tar.gz 13.7 kB Without provenance Details for air2mqtt-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 29.0 kB

Release files / air2mqtt-0.1.0.tar.gz

Download URL air2mqtt-0.1.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1fc98ce9c780bbff7b28d383a3c3bc4b3b85d3ddec183c0820fc24f25b584ee0
BLAKE2b-256 checksum
How to use checksums
02d1dab192a885a1fd285b4dad3a14e496a366b7f08187807d55069f563e695e
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.1.0-py3-none-any.whl

Download URL air2mqtt-0.1.0-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
873dc7d8f794b5081717d6a97d1b5c869a421da456cea6afd8aadf75a2e0a0d9
BLAKE2b-256 checksum
How to use checksums
b457688dbd7256dfdd53c65828a4302652fdac2f310cb2a7a10ead94a5f49fb2
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.1.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