This library is a wrapper around the excellent HAP-Java to simplify the integration in projects using Kotlin and Project Reactor.
Accessories are built from a list of services, each service having a fixed list of possible characteristics.
A few sample scripts are available
- switch.main.kts: A minimal example exposing a switch
- tv.main.kts: A more complex example with a television service
To run the sample scripts, just make sure that a recent version of the Kotlin compiler is available, then just execute them as a script. Shortly afterwards, the bridge will show up in the home up and can be added using the PIN printed in the console.
To add the library to a gradle build, you need to...
- add the Jitpack-repo:
maven("https://jitpack.io")
- add dependency
dependencies { implementation("io.github.dfrommi:rehaktor:master-SNAPSHOT") }
Characteristics and services are generated from Apple's definition file shipped with HAS
(Homekit Accessory Simulator) plus a hand-crafted definition for TV accessory.
This approach was heavily inspired by HAP-NodeJS.
The list of all services is here and characteristics here.
The goal of this project is to simplify the usage of HAP-Java in projects using Kotlin and Project Reactor. To achieve this, it has the following underlying design principles:
- Optional characteristics are expressed by optional nullable constructor parameters rather than parameters of type
Optional
Flux
is used as event stream for value changes, as opposed toCompletableFuture
- Lambdas are used to trigger actions from Homekit. They subscribe automatically if they resolve to
Mono
On top of that, a few simple wrapper classes are available to define new accessories in a fluent way without the need to implement interfaces.