cosalette — an opinionated Python framework for building IoT-to-MQTT bridge applications
Translation pending
Developer toolsPython · ShellGitHub @ff-fabOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
An opinionated Python framework for building IoT-to-MQTT bridge applications
Translation pending
Taken from the repository README
Loading the full README. The saved excerpt is shown below.
cosalette lets you build IoT-to-MQTT bridge daemons in Python with minimal boilerplate.
You define devices (telemetry pollers or command handlers), register hardware
adapters, and the framework handles MQTT wiring, structured logging, health reporting,
error publishing, and graceful lifecycle management.
See the full
Quickstart for a
complete walkthrough.
For production apps, use Router to organize devices into separate modules without
circular imports:
bash
pip install cosalette
bash
uv add cosaletteRead the full README ↗Documentation · Dev Docs (latest) · Quickstart · API Reference
cosalette lets you build IoT-to-MQTT bridge daemons in Python with minimal boilerplate. You define devices (telemetry pollers or command handlers), register hardware adapters, and the framework handles MQTT wiring, structured logging, health reporting, error publishing, and graceful lifecycle management.
import cosalette
app = cosalette.App(name="sensor2mqtt", version="0.1.0")
@app.telemetry("sensor", interval=5.0)
async def sensor() -> dict[str, object]:
return {"temperature": 21.5, "humidity": 55.0}
if __name__ == "__main__":
app.run()
See the full Quickstart for a complete walkthrough.
For production apps, use Router to organize devices into separate modules without
circular imports:
# sensors.py
import cosalette
router = cosalette.Router(prefix="sensors")
@router.telemetry("temperature", interval=30)
async def read_temp() -> dict[str, object]:
return {"celsius": 22.5}
# main.py
import cosalette
from sensors import router
app = cosalette.App(name="home2mqtt", version="1.0.0")
app.include_router(router)
# → publishes to: home2mqtt/sensors/temperature/state
See Router Composition for full patterns.
cosalette supports Pydantic-validated payloads and typed returns for type-safe command handlers and telemetry, plus dependency injection for shared logic:
from typing import Annotated
from pydantic import BaseModel
import cosalette
app = cosalette.App(name="thermo2mqtt", version="1.0.0")
class SetpointCommand(BaseModel):
value: float
unit: str = "celsius"
class ThermostatState(BaseModel):
setpoint: float
unit: str
def get_device_id() -> str:
return "thermo-001"
@app.command("thermostat/set")
async def set_temp(
cmd: Annotated[SetpointCommand, cosalette.Payload()],
device_id: Annotated[str, cosalette.Depends(get_device_id)],
) -> ThermostatState:
return ThermostatState(setpoint=cmd.value, unit=cmd.unit)
Inspect the contract to generate AsyncAPI docs or consumer artifacts:
cosalette manifest myapp.main:app # JSON AsyncAPI 3.0.0
cosalette manifest myapp.main:app --table # human-readable table
Or programmatically:
doc = app.asyncapi() # returns dict conforming to AsyncAPI 3.0.0
See Contract-First Route Design and Schema Enforcement for full details.
@app.telemetry(), @app.command(), and @app.device()
(guide)ctx.commands() for clean control
flows (guide)ctx.sleep_until() wall-clock timingpip install cosalette
Or with uv:
uv add cosalette
To include the optional MCP server for IDE-native AI agent integration (VS Code Copilot, Cursor, Windsurf, Claude Code):
uv add 'cosalette[mcp]'
pip install 'cosalette[mcp]'
See the MCP Server guide for setup and tool reference.
See CONTRIBUTING.md for development setup, commands, project structure, and code quality standards.
Full documentation is published at
ff-fab.github.io/cosalette. Development docs
tracking the main branch are available at
Dev Docs (latest).
| Section | What you'll find |
|---|---|
| Getting Started | Installation, quickstart tutorial |
| Concepts | Architecture, lifecycle, health checks, filters, persistence |
| How-To Guides | Telemetry, commands, adapters, lifespan DI, schema, testing, MCP |
| Reference | API docs, CLI options, payload schemas |
| ADRs | Architecture Decision Records |
MIT License. See LICENSE for details.