Glimta
A local-first Rust library and optional CLI for talking directly to the classic IKEA TRÅDFRI gateway.
Glimta uses the gateway's local CoAP/DTLS interface. It does not require IKEA cloud services, Home Assistant, MQTT, or a Python runtime, and it deliberately leaves deployment, credential storage, and automation policy to the application embedding it.
What it supports
- mDNS discovery of classic TRÅDFRI gateways
- first-time client provisioning from the printed gateway security code
- CoAP over DTLS-PSK using the gateway's compatible cipher suite
- device and group enumeration
- typed resources that tolerate unknown gateway attributes
- lights: on/off, brightness, color temperature, hex, XY, and HSB commands
- switched outlets
- blinds
- air purifiers
- groups
- cancellable CoAP Observe subscriptions exposed as async Rust streams
- an optional CLI for discovery, provisioning, inspection, and basic control
The protocol model is independent from network I/O, so parsing and command generation can be tested without physical hardware.
Library usage
Enable the default network feature for discovery and gateway communication:
[]
= { = "https://github.com/Mik-pe/glimta" }
Provision credentials once and hand the returned value to your own credential store:
use Duration;
use Gateway;
# async
Connect later with previously provisioned credentials:
use ;
use ;
# async
192.0.2.10 and the credentials above are documentation-only placeholders.
Observe changes
# async
Dropping an observation, or calling cancel(), sends an explicit CoAP Observe termination.
Core-only usage
Applications that only need protocol types and command construction can disable networking:
[]
= { = "https://github.com/Mik-pe/glimta", = false }
That keeps CoAP, DTLS, Tokio, and mDNS out of the dependency graph.
CLI
Build or install the optional CLI with the cli feature:
The provisioning command reads the gateway security code without echoing it and writes the resulting credential file with owner-only permissions on Unix. Callers remain free to use a different secret store when using the library API.
A gateway address can be supplied explicitly instead of using mDNS:
Architecture
protocolcontains TRÅDFRI endpoint and attribute identifiers.modelowns typed gateway resources while preserving unknown fields.commandbuilds validated wire commands without doing I/O.transportowns CoAP over DTLS-PSK.discoveryowns mDNS gateway discovery.clientprovides the async public API and Observe streams.
Bulk reads reuse a read-only DTLS session. Writes open fresh sessions because classic gateways have historically behaved differently when multiple PUT operations reuse one connection.
Compatibility references
Glimta is a new implementation informed by two existing open-source projects:
home-assistant-libs/pytradfrifor broad classic-gateway behaviour and resource coverage.tirithen/tradfri_gatewayfor prior Rust interoperability knowledge.
Neither project is required at runtime.
Development
Real-gateway interoperability is intentionally separate from unit tests because CI does not assume access to local hardware.
License
MIT