func (c *Client) Lights(ctx context.Context) ([]*Light, error) {
	var body lightsBody
	if err := c.do(ctx, http.MethodGet, "/elgato/lights", nil, &body); err != nil {
		return nil, err
	}
	return body.Lights, nil
}
Lights retrieves the current state of all lights from a Key Light device.
package keylight
import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"math"
	"net/http"
	"net/url"
	"time"
)
const (
	brightnessMin = 3
	brightnessMax = 100
	tempMin       = 2900
	tempMax       = 7000
	tempConstant   = 9900
	tempCoefficent = 20.35
	tempHalfstep   = 25
	tempStep       = 50
)
type Client struct {
	c *http.Client
	u *url.URL
}
func NewClient(addr string, c *http.Client) (*Client, error) {
	if c == nil {
		c = &http.Client{Timeout: 2 * time.Second}
	}
	u, err := url.Parse(addr)
	if err != nil {
		return nil, err
	}
	return &Client{
		c: c,
		u: u,
	}, nil
}
type Device struct {
	ProductName         string `json:"productName,omitempty"`
	HardwareBoardType   int    `json:"hardwareBoardType,omitempty"`
	FirmwareBuildNumber int    `json:"firmwareBuildNumber,omitempty"`
	FirmwareVersion     string `json:"firmwareVersion,omitempty"`
	SerialNumber        string `json:"serialNumber,omitempty"`
	DisplayName         string `json:"displayName,omitempty"`
}
func (c *Client) AccessoryInfo(ctx context.Context) (*Device, error) {
	var d Device
	if err := c.do(ctx, http.MethodGet, "/elgato/accessory-info", nil, &d); err != nil {
		return nil, err
	}
	return &d, nil
}
func (c *Client) SetDisplayName(ctx context.Context, name string) error {
	b, err := json.Marshal(Device{DisplayName: name})
	if err != nil {
		return err
	}
	return c.do(ctx, http.MethodPut, "/elgato/accessory-info", bytes.NewReader(b), nil)
}
func (c *Client) Identify(ctx context.Context) error {
	return c.do(ctx, http.MethodPost, "/elgato/identify", nil, nil)
}
var (
	_ json.Marshaler   = &Light{}
	_ json.Unmarshaler = &Light{}
)
type Light struct {
	On bool
	Brightness int
	Temperature int
}
type jsonLight struct {
	On          int `json:"on"`
	Brightness  int `json:"brightness"`
	Temperature int `json:"temperature"`
}
func (l *Light) MarshalJSON() ([]byte, error) {
	jl := jsonLight{
		Brightness: l.Brightness,
		Temperature: convertToAPI(l.Temperature),
	}
	if l.On {
		jl.On = 1
	}
	return json.Marshal(jl)
}
func (l *Light) UnmarshalJSON(b []byte) error {
	var jl jsonLight
	if err := json.Unmarshal(b, &jl); err != nil {
		return err
	}
	l.On = jl.On == 1
	l.Brightness = jl.Brightness
	l.Temperature = convertToKelvin(jl.Temperature)
	return nil
}
type lightsBody struct {
	Lights []*Light `json:"lights"`
}