Skip to content

kieranipalmer/refrakt

Repository files navigation

Refrakt

A Kotlin implementation of the Lifx LAN Protocol.

Getting Started

Install Library

repositories {
    ...
    maven {
        url = uri("https://maven.pkg.github.com/kieranipalmer/refrakt")
    }
}

dependencies {
    implementation("dev.shanty:refrakt:0.0.1-SNAPSHOT")
}

Setup

To begin communicating with Lifx Devices, you must instantiate an instance of Lifx. This class requires a Coroutine Scope. An example can be seen below:

    fun main() = runLocalActorSystem {
        val lifx = Lifx(this)
    }

Once created, the Lifx instance will begin Discovery of devices on the local network. You can begin listening for the discovered devices by collecting the discoveryEvents flow.

    val lifx = Lifx(this)
    lifx.discoveryEvents.onEach { device ->
        println("Discovered Device $device")
        when(device) {
            is Device.Light -> device.setPower(true)
        }
    }.collect()

About

Kotlin Implementation of the Lifx LAN Protocol

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages