Skip to content

Commit

Permalink
docs: update readme with new example
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant3W committed Jul 17, 2024
1 parent c812242 commit 4a5c3c6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
go-vee - Govee API Wrapper for Go
</h1>

go-vee is an unofficial Go wrapper for the Govee API. It makes it easy to control your Govee smart devices from your Go code. It is based on the [official Govee API documentation](https://govee-public.s3.amazonaws.com/developer-docs/GoveeDeveloperAPIReference.pdf). **This project is a work in progress, use in production at your own risk.**
go-vee is an unofficial Go wrapper for the Govee API. It makes it easy to control your Govee smart devices from your Go code. It is based on the [official Govee API documentation](https://developer.govee.com/reference). **This project is a work in progress, use in production at your own risk.**

> To get started with the Govee API, you need to request an API key. You can do this from the Govee Home app. Open the app, go to Profile > Settings > Apply for API Key.
Expand All @@ -25,15 +25,21 @@ import (

client := govee.New("your-api-key")

listRequest := client.ListDevices()
response, err := client.Run(listRequest)
// get all devices
devices, err := client.GetDevices()
if err != nil {
panic(err)
}
devices := response.Devices()

controlRequest, _ := client.Device(devices[0].Device, devices[0].Model).TurnOn()
_, err = client.Run(controlRequest)
// get a device's state
deviceState, err := client.GetDeviceState(devices[0])
if err != nil {
panic(err)
}
fmt.Println(deviceState.Capabilities[1])

// send a command to a device
err = client.ControlDevice(devices[0], "devices.capabilities.on_off", "powerSwitch", 1)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 4a5c3c6

Please sign in to comment.