cosalette¶
An opinionated Python framework for building IoT-to-MQTT bridge applications.
Think "FastAPI for MQTT daemons."
What is cosalette?¶
cosalette provides the common infrastructure that every IoT-to-MQTT bridge needs:
- MQTT lifecycle — connection, reconnection, Last Will and Testament
- Device registration — decorator-based API (
@app.command,@app.device,@app.telemetry) - Configuration — pydantic-settings with environment variables and
.envfiles - Structured logging — JSON (NDJSON) for production, text for development
- Error reporting — structured errors published to MQTT topics
- Health monitoring — per-device availability and app-level status with LWT
- CLI —
--dry-run,--version,--log-level,--log-format,--env-file - Testing —
cosalette.testingmodule with pytest fixtures and test doubles
Quick Example¶
import cosalette
app = cosalette.App(name="sensor2mqtt", version="0.1.0")
@app.telemetry("sensor", interval=30.0)
async def read_sensor() -> dict[str, object]:
reading = sensor.read()
return {"temperature": reading.temp, "humidity": reading.humidity}
if __name__ == "__main__":
app.run()
Explore the Documentation¶
-
Getting Started
Install cosalette and build your first app in 5 minutes.
-
Concepts
Understand the architecture, design patterns, and ideas behind cosalette.
-
How-To Guides
Step-by-step instructions for common tasks.
-
Reference
API reference, settings, CLI options, and payload schemas.
Architecture Decisions¶
All major design decisions are documented as Architecture Decision Records.
Status¶
cosalette is under active development.