https://github.com/omarmiatello/yeelight-ktor-docker
Control your Xiaomi Yeelight lamp from Kotlin. Use ktor library for network.
https://github.com/omarmiatello/yeelight-ktor-docker
docker kotlin kotlin-library ktor smart-devices smarthome xiaomi yeelight
Last synced: 2 months ago
JSON representation
Control your Xiaomi Yeelight lamp from Kotlin. Use ktor library for network.
- Host: GitHub
- URL: https://github.com/omarmiatello/yeelight-ktor-docker
- Owner: omarmiatello
- License: mit
- Created: 2019-03-26T21:07:26.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-07T10:14:47.000Z (over 4 years ago)
- Last Synced: 2025-01-09T10:33:35.395Z (4 months ago)
- Topics: docker, kotlin, kotlin-library, ktor, smart-devices, smarthome, xiaomi, yeelight
- Language: Kotlin
- Size: 292 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yeelight-ktor-docker demo project
## NOTE: Yeelight API are moved to https://github.com/omarmiatello/yeelight
[](https://jitpack.io/#jacklt/yeelight-kt)
## Setup
Add this in your root `build.gradle` file:
```gradle
repositories {
// ...
maven { url "https://jitpack.io" }
}
```Grab via Gradle (v4 or later):
```groovy
implementation 'com.github.jacklt:yeelight-kt:1.0.0'
```## Examples: How to use
### Sample
**[build.gradle](demo/build.gradle)**
**[Main.kt](demo/src/main/kotlin/Main.kt)**
NOTE: NEW Yeelight API available here: https://github.com/omarmiatello/yeelight
```kotlin
// EXAMPLE DEPRECATED -- use: https://github.com/omarmiatello/yeelight
fun main() = runBlocking {
println("Start search...")
val devices = Yeelight.findDevices()
println("Found ${devices.size} devices:\n${devices.joinToString("\n")}")
devices.forEach { yeelight ->
yeelight.startFlowPolice()
}
println("Finish!")
}
```**Result**:
Start search...
Found 2 devices:
Yeelight(info={Cache-Control=max-age=3600, Location=yeelight://192.168.85.186:55443, Server=POSIX UPnP/1.0 YGLC/1, id=0x00000000031b0f7c, model=color, fw_ver=70, support=get_prop set_default set_power toggle set_bright start_cf stop_cf set_scene cron_add cron_get cron_del set_ct_abx set_rgb set_hsv set_adjust adjust_bright adjust_ct adjust_color set_music set_name, power=off, bright=1, color_mode=1, ct=4000, rgb=16750848, hue=36, sat=100}, ip=192.168.85.186, port=55443)
Yeelight(info={Cache-Control=max-age=3600, Location=yeelight://192.168.85.25:55443, Server=POSIX UPnP/1.0 YGLC/1, id=0x00000000047e92c2, model=bslamp1, fw_ver=169, support=get_prop set_default set_power toggle set_bright start_cf stop_cf set_scene cron_add cron_get cron_del set_ct_abx set_rgb set_hsv set_adjust adjust_bright adjust_ct adjust_color set_music set_name, power=off, bright=1, color_mode=1, ct=4000, rgb=16750592, hue=36, sat=100}, ip=192.168.85.25, port=55443)
192.168.85.186 --> {"method":"start_cf","params":[8,0,"500,1,16711680,100,200,7,0,0,500,1,255,100,200,7,0,0"],"id":1}
<-- {"id":1, "result":["ok"]}
192.168.85.25 --> {"method":"start_cf","params":[8,0,"500,1,16711680,100,200,7,0,0,500,1,255,100,200,7,0,0"],"id":1}
<-- {"id":1, "result":["ok"]}
Finish!### Web server with [Ktor](https://ktor.io)
**[build.gradle](demo-ktor-docker/build.gradle)**
**[README.md](demo-ktor-docker/README.md)** (for Docker)
You can start a local web server (`./gradlew run`) or use Docker for:
Find devices
```
http://localhost:8080
```Switch on/off devices (+ find devices if needed)
```
http://localhost:8080/toggle
```Start "Police flow" (+ find devices if needed)
```
http://localhost:8080/police
```