Skip to content

Color and Temperature

Logan Savage edited this page May 27, 2026 · 4 revisions

Color and Temperature

The Color() action sets the color of the devices selected in the command by a 24-bit color value. While this takes in a single int value for representing the color, the veego.RGB(uint8,uint8,uint8) helper can be used to generate this value.

The Temperature() action behaves similarly, using the veego.K helper to generate a Kelvin color temperature. Note that unlike the Color() action, this helper should always be used, since it keeps the value passed in within the temperature bounds for the lights.

Examples

// Cycles through colors
package main

import (
    "log"
    "log/slog"
    "net/http"
    "os"
    "time"

    "github.com/lxsavage/veego"
)

const key = "GOVEE_KEY"

func main() {
    // Create a new controller to handle device interaction using the default HTTP
    // client
    logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
    controller, err := veego.NewController(key, logger).
        WithClient(http.DefaultClient).
        Init()
    if err != nil {
        log.Fatal(err)
    }

    // Switch the color to red (#FF0000)
    err = controller.Devices().
        TypeIs(veego.DeviceLight).
        Color(veego.RGB(255, 0, 0)). // 0xFF0000 also works here
        Sleep(1 * time.Second).
        Temperature(veego.K(3000)).
        Exec()
    if err != nil {
        log.Fatal(err)
    }
}

Clone this wiki locally