api

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LMSPPort    = 7575
	LMSPVersion = 0x0100

	EncodingRAW  = 0
	EncodingPNG  = 1
	EncodingJPEG = 2
	EncodingGIF  = 3
)

LMSP protocol constants.

Variables

This section is empty.

Functions

func NewAPIError

func NewAPIError(statusCode int, body []byte) error

NewAPIError parses a JSON error response body and returns the appropriate typed error.

Types

type APIError

type APIError struct {
	StatusCode int
	Messages   []string
}

APIError represents a LaMetric API error response. LaMetric returns: {"errors":[{"message":"..."}]}

func (*APIError) Error

func (e *APIError) Error() string

type App

type App struct {
	Package string            `json:"package"`
	Vendor  string            `json:"vendor,omitempty"`
	Version string            `json:"version,omitempty"`
	Widgets map[string]Widget `json:"widgets,omitempty"`
}

App represents an installed app/widget.

type Audio

type Audio struct {
	Volume int `json:"volume"`
}

Audio represents audio settings.

type AudioUpdate

type AudioUpdate struct {
	Volume *int `json:"volume,omitempty"`
}

AudioUpdate is the payload for updating audio settings.

type AuthError

type AuthError struct {
	APIError
}

AuthError represents a 401 authentication error.

func (*AuthError) Error

func (e *AuthError) Error() string

type Bluetooth

type Bluetooth struct {
	Available    bool   `json:"available"`
	Active       bool   `json:"active"`
	Name         string `json:"name"`
	MAC          string `json:"mac,omitempty"`
	Pairable     bool   `json:"pairable"`
	Discoverable bool   `json:"discoverable"`
}

Bluetooth represents bluetooth settings.

type BluetoothUpdate

type BluetoothUpdate struct {
	Active       *bool   `json:"active,omitempty"`
	Name         *string `json:"name,omitempty"`
	Pairable     *bool   `json:"pairable,omitempty"`
	Discoverable *bool   `json:"discoverable,omitempty"`
}

BluetoothUpdate is the payload for updating bluetooth settings.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the LaMetric local API client.

func NewClient

func NewClient(ip, apiKey string) *Client

NewClient creates a Client for a LaMetric device at the given IP. It auto-detects the protocol: HTTPS:4343 first, fallback HTTP:8080.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string) error

Delete performs a DELETE request.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, out any) error

Get performs a GET request.

func (*Client) GetStreamStatus

func (c *Client) GetStreamStatus(ctx context.Context) (*StreamStatus, error)

GetStreamStatus returns current streaming status via GET /api/v2/device/stream.

func (*Client) IP

func (c *Client) IP() string

IP returns the device IP address.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body, out any) error

Post performs a POST request.

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, body, out any) error

Put performs a PUT request.

func (*Client) StartStream

func (c *Client) StartStream(ctx context.Context) (*StreamStartResponse, error)

StartStream initiates a streaming session via PUT /api/v2/device/stream/start.

func (*Client) StopStream

func (c *Client) StopStream(ctx context.Context) error

StopStream ends the streaming session via PUT /api/v2/device/stream/stop.

type CloudIcon

type CloudIcon struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
	Code  string `json:"code"`
	Type  string `json:"type"` // "picture" or "movie"
}

CloudIcon represents an icon from the LaMetric cloud icon library.

func GetPopularIcons

func GetPopularIcons(ctx context.Context, limit int) ([]CloudIcon, error)

GetPopularIcons returns popular icons from the LaMetric cloud library.

func SearchIcons

func SearchIcons(ctx context.Context, query string, limit int) ([]CloudIcon, error)

SearchIcons searches the LaMetric cloud icon library. It fetches icons and filters by title containing the query (case-insensitive).

type Device

type Device struct {
	ID           string    `json:"id"`
	UUID         string    `json:"uuid"`
	Name         string    `json:"name"`
	SerialNumber string    `json:"serial_number"`
	OSVersion    string    `json:"os_version"`
	Mode         string    `json:"mode"`
	Model        string    `json:"model"`
	Audio        Audio     `json:"audio"`
	Bluetooth    Bluetooth `json:"bluetooth"`
	Display      Display   `json:"display"`
	WiFi         WiFi      `json:"wifi"`
}

Device represents a LaMetric device info response.

type Display

type Display struct {
	Brightness     int          `json:"brightness"`
	BrightnessMode string       `json:"brightness_mode"` // auto|manual
	Width          int          `json:"width"`
	Height         int          `json:"height"`
	Type           string       `json:"type"`
	Screensaver    *Screensaver `json:"screensaver,omitempty"`
}

Display represents display settings.

type DisplayUpdate

type DisplayUpdate struct {
	Brightness     *int    `json:"brightness,omitempty"`
	BrightnessMode *string `json:"brightness_mode,omitempty"`
}

DisplayUpdate is the payload for updating display settings.

type Frame

type Frame struct {
	Icon      string    `json:"icon,omitempty"`
	Text      string    `json:"text,omitempty"`
	GoalData  *GoalData `json:"goalData,omitempty"`
	ChartData []int     `json:"chartData,omitempty"`
}

Frame represents a single notification frame.

type GoalData

type GoalData struct {
	Start   int    `json:"start"`
	Current int    `json:"current"`
	End     int    `json:"end"`
	Unit    string `json:"unit,omitempty"`
}

GoalData represents goal progress data.

type IconsResponse

type IconsResponse struct {
	Meta struct {
		TotalIconCount int `json:"total_icon_count"`
		Page           int `json:"page"`
		PageSize       int `json:"page_size"`
		PageCount      int `json:"page_count"`
	} `json:"meta"`
	Data []CloudIcon `json:"data"`
}

IconsResponse is the API response for the icons endpoint.

type Notification

type Notification struct {
	ID       string `json:"id"`
	Type     string `json:"type,omitempty"`
	Priority string `json:"priority,omitempty"`
	Created  string `json:"created,omitempty"`
}

Notification represents a created/queued notification.

type NotificationModel

type NotificationModel struct {
	Frames []Frame `json:"frames"`
	Sound  *Sound  `json:"sound,omitempty"`
	Cycles int     `json:"cycles,omitempty"`
}

NotificationModel holds the frames, sound, and cycle config.

type NotificationRequest

type NotificationRequest struct {
	Priority string            `json:"priority,omitempty"`  // info|warning|critical
	IconType string            `json:"icon_type,omitempty"` // none|info|alert
	Lifetime int               `json:"lifetime,omitempty"`  // ms
	Model    NotificationModel `json:"model"`
}

NotificationRequest is the payload sent to create a notification.

type RetryTransport

type RetryTransport struct {
	Base       http.RoundTripper
	MaxRetries int
}

RetryTransport wraps an http.RoundTripper with retry logic and exponential backoff.

func NewRetryTransport

func NewRetryTransport(base http.RoundTripper) *RetryTransport

NewRetryTransport creates a RetryTransport with default 3 retries.

func (*RetryTransport) RoundTrip

func (t *RetryTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes the request with retry logic.

type Screensaver

type Screensaver struct {
	Enabled bool   `json:"enabled"`
	Widget  string `json:"widget,omitempty"`
}

Screensaver represents screensaver configuration.

type Sound

type Sound struct {
	Category string `json:"category,omitempty"` // notifications|alarms
	ID       string `json:"id,omitempty"`
	Repeat   int    `json:"repeat,omitempty"`
}

Sound represents a notification sound.

type StreamSession

type StreamSession struct {
	SessionID string // UUID from start response
	DeviceIP  string
	Width     int // 37 for TIME, 8 for SKY
	Height    int // always 8
	// contains filtered or unexported fields
}

StreamSession represents an active LMSP streaming session.

func NewStreamSession

func NewStreamSession(deviceIP, sessionID string, width, height int) (*StreamSession, error)

NewStreamSession creates a StreamSession and opens the UDP connection.

func (*StreamSession) Close

func (s *StreamSession) Close() error

Close closes the UDP connection.

func (*StreamSession) SendFrame

func (s *StreamSession) SendFrame(encoding byte, data []byte) error

SendFrame sends a single frame via UDP with LMSP header.

type StreamStartResponse

type StreamStartResponse struct {
	SessionID string `json:"session_id"`
}

StreamStartResponse is returned by the streaming start endpoint.

type StreamStatus

type StreamStatus struct {
	Active    bool   `json:"active"`
	SessionID string `json:"session_id,omitempty"`
}

StreamStatus is returned by the streaming status endpoint.

type WiFi

type WiFi struct {
	Active     bool   `json:"active"`
	MAC        string `json:"mac"`
	SSID       string `json:"ssid"`
	IP         string `json:"ip"`
	Netmask    string `json:"netmask"`
	Strength   int    `json:"strength"`
	Encryption string `json:"encryption,omitempty"`
}

WiFi represents wifi status (read-only).

type Widget

type Widget struct {
	ID       string `json:"id,omitempty"`
	Index    int    `json:"index"`
	Package  string `json:"package,omitempty"`
	Settings any    `json:"settings,omitempty"`
}

Widget represents a single widget within an app.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL