api

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 12 Imported by: 1

README

Litter API Go Report Badge GoDocBadge

Litter API is an interface to the Litter Robot API.

This is an experimental API. The upstream Litter Robot API is not publicly documented and may cause breaking changes with no notice. Breaking changes will be handled as soon as possible.

Examples

package main

import (
	"fmt"
	. "github.com/tlkamp/litter-api"
	"log"
)

func main() {
	lc, err := NewClient(Config{
		Email:    "your-email@example.com",
		Password: "your-password-here",
		APIKey:   "your-api-key",
	})
	if err != nil {
		log.Fatalln(err)
	}

	states, err := lc.States()
	if err != nil {
		log.Fatalln(err)
	}

	for _, state := range states {
		log.Println(fmt.Sprintf("%+v", state))
	}
}

Logging

Logrus is the logger used in this project. The log level and format can be altered accordingly.

log.SetLevel(log.DebugLevel)

Unit Status

The unit status is represented by a non-negative integer.

String Int Description
RDY 0 Ready
CCP 1 Clean Cycle in Progress
CCC 2 Clean Cycle Complete
CSF 3 Cat Sensor Fault
DF1 4 Drawer full - will still cycle
DF2 5 Drawer full - will still cycle
CST 6 Cat Sensor Timing
CSI 7 Cat Sensor Interrupt
BR 8 Bonnet Removed
P 9 Paused
OFF 10 Off
SDF 11 Drawer full - will not cycle
DFS 12 Drawer full - will not cycle

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*Config
	Expiry time.Duration
	// contains filtered or unexported fields
}

Client - The Client for interacting with the Litter Robot API.

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient - Initialize a new Client with provided configuration Config

func (*Client) Cycle

func (c *Client) Cycle(robotId string)

Cycle - Start a clean cycle.

func (*Client) Insights

func (c *Client) Insights(id string, days, timezoneOffset int) ([]Insight, error)

Insights - return the Litter Robot Insights over the specified number of days.

func (*Client) NightLightOff

func (c *Client) NightLightOff(robotId string)

NightLightOff - Turn nightlight off.

func (*Client) NightLightOn

func (c *Client) NightLightOn(robotId string)

NightLightOn - Turn nightlight on.

func (*Client) PanelLockOff

func (c *Client) PanelLockOff(robotId string)

PanelLockOff - Disable the panel lock.

func (*Client) PanelLockOn

func (c *Client) PanelLockOn(robotId string)

PanelLockOn - Enable the panel lock.

func (*Client) PowerOff

func (c *Client) PowerOff(robotId string)

PowerOff - Turn unit power off.

func (*Client) PowerOn

func (c *Client) PowerOn(robotId string)

PowerOn - Turn unit power on.

func (*Client) RefreshToken

func (c *Client) RefreshToken()

RefreshToken - Refreshes the access_token granted by the initial client creation.

func (*Client) States

func (c *Client) States() ([]State, error)

States - Fetch states from the Litter Robot API

func (*Client) Wait

func (c *Client) Wait(robotId string, val string)

Wait - Set clean cycle wait time.

type Config

type Config struct {
	ApiUrl       string
	AuthUrl      string
	ClientId     string
	ClientSecret string
	Email        string
	Password     string
	ApiKey       string
}

Config - Configuration for the Litter Robot client

type Insight

type Insight struct {
	AverageCycles float64 `json:"averageCycles"`
	TotalCycles   int     `json:"totalCycles"`
}

Insight - represents a Litter Robot Insights response.

type State

type State struct {
	CleanCycleWaitTimeMinutes float64
	CyclesAfterDrawerFull     float64
	CycleCapacity             float64
	CycleCount                float64
	CyclesUntilFull           float64
	DidNotifyOffline          bool
	DFICycleCount             float64
	DFITriggered              bool
	LitterRobotID             string
	LitterRobotSerial         string
	Name                      string
	NightLightActive          bool
	PanelLockActive           bool
	PowerStatus               string
	SleepModeActive           bool
	UnitStatus                float64
}

State - the exported state of the Litter Robot.

Jump to

Keyboard shortcuts

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