# feed

Dennis Schröder

07/10/2020, 11:44 AM
Interested in Kotlin and home automation? Then have a look at Khome, a home automation library build for Home Assistant (the fastest growing smart home application out there). Khome enables you to write your own Home Assistant automation applications, that can observe state changes, listen to events, and much more. Here is a simple example to give you ua quick feeling what it is:
Copy code
val KHOME = khomeApplication()

val LivingRoomLuminance = KHOME.LuminanceSensor("livingRoom_luminance")
val LivingRoomMainLight = KHOME.SwitchableLight("livingRoom_main_light")

fun main() {
    LivingRoomLuminance.attachObserver { //this: Actuator<LuminanceState,LuminanceAttributes>
        if (actualState.value < 3.0) {
            LivingRoomMainLight.desiredState = SwitchableState(ON)

👀 7
👍 3


07/10/2020, 12:34 PM
Interesting. We are currently doing device server prototypes for SCADA systems using kotlin multi-platform. The core device API should be more or less the same, so please write me if you are willing to collaborate on a common library.


07/10/2020, 1:21 PM
Interesting! How is this different from AppDaemon though?

Dennis Schröder

07/10/2020, 2:06 PM
First of all, it is written in a static typed language 😉 Second, we give the developer more freedom since Khome was build as un opinionated as it could be. As you can see in the simple example, Khome encourages you to think in states rather than services you have to call. This is less error-prone and helps the developer to stay in the mindset of states. And we did something to help you build safer applications. See' And we diffentiate between Actuator (mutable) and Sensors (immutable) entites.
As a quick wrap up!
Here is the link to reddit with more questions and answers to Khome