Skip to content

EAGrahamJr/HAssK

Repository files navigation

HomeAssistant Client for Kotlin

  • Extremely simple API with some DSL goodies
  • Uses async under the covers, so limited multi-threading is provided out-of-the-box
  • Runtime requires:
    • Java 17 or newer
    • Kotlin 1.9.0 or newer
  • Minimal external libraries (SLF4J, org.json)

Just Build Kotlin Java Apache License

Javadocs

Examples

import crackers.hassk.HAssKClient
import crackers.hassk.Constants.off
import crackers.hassk.Constants.on

private val token = "valid.ha.token"
fun main() {
  with(HAssKClient(token, "local name or ip address")) {
    val light = light("shelf_lamp")
    println(light.state())

    val group = light("bedroom_group")
    group turn on
    Thread.sleep(2000)
    group turn off
    Thread.sleep(2000)
  }
}

Building

This project uses Gradle, so the only thing you need is a compatible JDK1. Additionally, because the project is Kotlin and uses the Kotlin Gradle plugin, a Kotlin installation is also not necessary.

A default build will use the gradle-plugins to publish to the "local" Maven repository.

Documentation is created via the dokka plugin: Javadocs are created on build (but not published, yet).