Hello everyone!
I’d like to introduce Kortex - Kotlin Multiplatform client toolkit for Home Assistant.
The goal of Kortex is to make it easy for Kotlin developers to build reactive Home Assistant clients and tools across multiple platforms such as:
- Android
- Desktop
- iOS
- Web (future)
- Embedded devices
It provides a type-safe and observable API for interacting with Home Assistant entities.
Current Features
Even though the project is at the very early stage, it already includes:
-
Communication via WebSocket API
-
Service calls
-
Observable entity model
Entities expose reactive state updates so you can easily react to changes. -
Supported entities
- BinarySensor
- Button
- Calendar
- Cover
- DeviceTracker
- Fan
- Image
- Light
- MediaPlayer
- Number
- Person
- Sensor
- Switch
- Timer
- Zone
- Compose Multiplatform integration
A small helper library that integrates with Compose usingcollectAsState.
Examples usage:
Native usage:
startKortexObservable { entities ->
val lights = entities.lights
val scope = CoroutineScope(currentCoroutineContext())
val tablePrinter = StatusTablePrinter(lights)
tablePrinter.render()
lights.forEach { light ->
light.onToggled(scope) {
tablePrinter.updateStatus(entityId, state)
}
}
}
Compose UI:
KortexApplication(token, host) {
val state = LocalKortexApplication.current
when {
state.error != null -> {
Text(state.error!!)
}
state.isLoading -> {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator()
}
}
else -> {
HomeAssistant(state)
}
}
}
Planned Features
Some ideas for future development:
- Automation interaction
- Full WebSocket API coverage
- More Compose UI components for dashboards
Why Kotlin?
Kotlin Multiplatform allows writing shared code across Android, iOS, desktop, and web. Compose UI support is making it a great fit for building cross-platform Home Assistant tools and dashboards.
Contributions & Feedback
The project is still very early, so feedback, ideas, and contributions are highly welcome.
If you’re interested, check out the repository:
I’d love to hear:
- what features you would like
- what would make this useful for your projects
- suggestions for the API design
Thanks!