Skip to content

Unimplemented Functionality

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

If you want to use functionality that is not currently implemented in this library, the library exports a function (with a stable contract) that directly queries the Govee API in the same way that the rest of the library does: veego.Request[T any](*Controller,string,string,[]byte) (*T, error). With the arguments:

  • [T any]: the struct to deserialize the response into (if applicable). All properties must be exported (capitalized) or else they will not be set properly.
  • *Controller: the controller instance to use
  • string: the HTTP verb to use
  • string: the endpoint to use
  • []byte: the serialized request body (if applicable), otherwise nil

The function returns a *T storing the response body, otherwise nil if one could not be found.

Example

Fragment of how Device.Stat() utilizes this function (v0.2.0)

body, err := json.Marshal(map[string]any{
    "requestId": uuid.NewString(),
    "payload": map[string]string{
        "sku":    d.SKU,
        "device": d.MACAddress,
    },
})
if err != nil {
    return nil, errors.New("failed to marshal JSON body for " + d.MACAddress + ": " + err.Error())
}

status, err := Request[struct {
    Payload struct {
        Capabilities []deviceCapabilityState
    }
}](*c, "POST", "/device/state", body)
if err != nil {
    return nil, errors.New("failed to get device stat for " + d.MACAddress + ": " + err.Error())
}

return status.Payload.Capabilities, nil

Clone this wiki locally