library

Library to control Tuya devices

License

License

GroupId

GroupId

space.dector.tuyalib
ArtifactId

ArtifactId

library
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

library
Library to control Tuya devices
Project URL

Project URL

https://github.com/dector/tuya-lib
Source Code Management

Source Code Management

https://github.com/dector/tuya-lib

Download library

Dependencies

compile (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.30

runtime (2)

Group / Artifact Type Version
org.jetbrains.kotlinx : kotlinx-coroutines-core-jvm jar 1.4.2
com.eclipsesource.minimal-json : minimal-json jar 0.9.5

Project Modules

There are no modules declared in this project.

Tuya-lib

Tuya-lib is an EXPERIMENTAL JVM library to control smart devices with Tuya firmware.

EXPERIMENTAL status means that this library is in incubating state - I'm lurking around, trying things and breaking them up. Library API and structure will be changed without additional notices. However, published maven artifacts will not be removed.

Features

WARNING: Only devices with firmware version 3.3 are supported for now.

  • Turn on a Bulb.
  • Turn off a Bulb.
  • Check if a Bulb is turned on.

Installation

  1. Library is distributed via MavenCentral. Ensure that you have it enabled in build.gradle.kts:
repositories {
    // ...
    mavenCentral()
}
For snapshots
repositories {
    // ...
    maven("https://maven.pkg.jetbrains.space/dector/p/tuya-lib/mvn")
}
  1. Add tuya-lib to your dependencies:
dependencies {
    // ...
    implementation("space.dector.tuyalib:library:0.1.0")
}
For snapshots
repositories {
    // ...
    implementation("space.dector.tuyalib:library:0.1.1-SNAPSHOT")
}
  1. Sync your project with Gradle and you are done.

Usage

Controlling a bulb

You can check sample/ directory for minimalistic library usage example.

Simple android app example is available in another repository.

WARNING: Only bulb with firmware version 3.3 is supported for now.

WARNING: Your bulb need to be activated (instructions will be provided later).

val bulb = Bulb(
    // bulb IP in local network
    ip = "192.168.0.17",

    // device ID in Tuya system
    deviceId = "1ca7b0eb833a56fcf449",

    // local AES key for device
    localKey = "3e3de0d819e34753",
)

bulb.turnOn()

Use small delay between executing operations. Devices are slow and might skip your commands if you are sending them too fast.

Changelog

See CHANGELOG.md file.

License

This project is licensed under the Apache 2.0 License - see the LICENSE.md file for details.

Acknowledgments

This library might never exist without these awesome projects and people behind them that did all the work for reversing Tuya devices protocol:

Versions

Version
0.1.1
0.1.0