How-To Guides¶
Step-by-step instructions for common tasks.
These guides assume you've read the Getting Started section and are familiar with the basic concepts.
Building Devices¶
-
Telemetry Device
Build a sensor-polling device with optional publish strategies.
-
Advanced Telemetry Techniques
On-demand reads, coalescing groups, cron scheduling, and retry/backoff resilience.
-
Command & Control Device
Build a device that receives commands via MQTT.
-
Streaming
Stream continuous sensor data from a
StreamablePortadapter with lifecycle and DI wired automatically. -
Periodic Tasks
Run background coroutines on a fixed interval — flush buffers, send pings, warm caches.
-
Multi-Device Registration
Register multiple similar devices from settings with
@app.on_configureand dict-name decorators.
Structuring an Application¶
-
Router Composition
Organize multi-module apps with
Routerfor testable boundaries. -
Shared State
Use adapters-as-state to share data between command and telemetry handlers.
-
Lifespan
Run startup and shutdown code with the lifespan context manager.
-
Hardware Adapters
Register adapters: direct, lazy import, dry-run swapping.
-
Configure Your Application
Extend Settings, use
.envfiles, override via CLI.
Contracts & Schemas¶
-
Contract-First Route Design
Add contract metadata to decorators for machine-readable, auditable interface declarations.
-
Schema Enforcement
Validate MQTT topics and payloads against an AsyncAPI schema. CI gate and fleet-level network schemas.
Testing & Errors¶
-
Test Your Application
Use
cosalette.testing, AppHarness, and pytest fixtures. -
Custom Error Types
Map domain exceptions to structured error payloads.
Operating & Tooling¶
-
Containerize Your Application
Package a cosalette app as a Docker image with hardware-specific and multi-arch support.
-
Deploy with Docker Compose
Containerise and deploy with Docker, Compose, and Ansible.
-
Harden Your Deployment
Security hardening, production logging, and runtime constraints for containerised applications.
-
Troubleshoot a Deployment
Diagnose and fix common problems with containerised cosalette applications.
-
Transport Availability
Mark devices offline when transports fail. Standardised availability signaling with auto-recovery for SSH, BLE, serial, and HTTP adapters.
-
Version Migration
Upgrade between cosalette versions — breaking changes, typed payloads, Router adoption, testing harness updates.
-
MCP Server
Expose fourteen structured tools for IDE-native AI agents to query registrations and generate idiomatic scaffolding.