Interested in Kotlin and home automation? Then ha...
# feed
d
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)
        }
    }

    KHOME.runBlocking()
}
👀 7
👍 3
a
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.
o
Interesting! How is this different from AppDaemon though?
d
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 https://github.com/dennisschroeder/khome/blob/master/docs/Safety'sFirst.md 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 https://www.reddit.com/r/homeassistant/comments/hoob9y/khome_new_kid_on_the_block_home_automation/