Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Binozo committed Dec 23, 2024
1 parent 9796f62 commit a860a7f
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ Features:
- 🔬 Battle tested with a Tuya TCL A/C

> [!IMPORTANT]
> Currently only Tuya devices with Version 3.3 are supported
> Currently only Tuya devices with Version 3.3 are supported because I don't own any devices that are using different protocol versions.
> Feel free to add them. If you need help you can take a look at the [tuyapi project](https://github.com/codetheweb/tuyapi/tree/master/lib) or create an Issue.
> [!NOTE]
> This Go api wouldn't be possible without the amazing [tuyapi project](https://github.com/codetheweb/tuyapi)
I use this package myself at my home with two A/Cs, so don't worry if there is no commit for a longer period of time.
If this package breaks I will fix it :)

## Quickstart
### Install the Package:
```bash
Expand Down Expand Up @@ -65,10 +69,45 @@ func main() {
}
```

### 🔌 Extending
To use this Api to connect to your tuya device take a look at the tuya package.
The `ac` package is a wrapper for that.
### 🔌 Extending with your own Tuya device
Tuya devices work all the same way. They work with _dictionaries_.
Let's explain this with an example:

```go
state := map[string]int{
"TEMPERATURE": 2,
"SPEED": 5,
"FEATURE_C": 0,
"FEATURE_D": 1,
}
```

Now if we want to set the temperature to 10°C we would just set
```go
state["TEMPERATURE"] = 10
```
programmatically and upload that dictionary to the Tuya device. We don't need to send every value, we can just send the key value pair we just changed.

This is the way it works under the hood. Easy, isn't it? 😄

Now if you want to add your own device you just have to find out which keys exist in that map and which values the can have:

```go
package main

import (
"fmt"
"github.com/Binozo/GoTuya/pkg/tuya"
)

func main() {
device := tuya.CreateDevice("IP", "DEVICEID", "KEY", tuya.Version_3_3)
state := device.GetCurrentStatus() // TODO
fmt.Println("Current state:", state)
}
```
Execute this code everytime you changed a parameter (e.g. Temeprature) of your device. This way you can find out which key stands for what feature.

Generally looking at the implementation of the `ac` device will help you implement your specific device.
The `ac` package is a prebuilt wrapper for A/Cs. Looking at the implementation could help you implement your own device.

Contributions are always welcome!
PRs are always welcome!

0 comments on commit a860a7f

Please sign in to comment.