homely

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

README

Homely API client

This is an unofficial API client for the Homely API. The API is in beta at the time of writing. To connect use your email as the username and your Homely password as the password.

Feature requests and issues are welcome!

Usage

Download with:

go get github.com/tokongs/homely

See the usage example in examples/main.go.

It is currently possible to list your locations. Get a detailed snapshot of a given location and its devices, and listening for update events. This is all the Homely API currently supports.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Feature     string    `json:"feature"`
	StateName   string    `json:"stateName"`
	Value       any       `json:"value"`
	LastUpdated time.Time `json:"lastUpdated"`
}

type Client

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

func New

func New(c Config) *Client

func (*Client) LocationDetails

func (c *Client) LocationDetails(ctx context.Context, locationID uuid.UUID) (LocationDetails, error)

func (*Client) Locations

func (c *Client) Locations(ctx context.Context) ([]Location, error)

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, locationID uuid.UUID, h func(e Event)) error

type Config

type Config struct {
	Username string
	Password string
	BaseURL  string
}

type Device

type Device struct {
	ID           uuid.UUID          `json:"id"`
	Name         string             `json:"name"`
	SerialNumber string             `json:"serialNumber"`
	Location     string             `json:"location"`
	Online       bool               `json:"online"`
	ModelID      uuid.UUID          `json:"modelId"`
	ModelName    string             `json:"modelName"`
	Features     map[string]Feature `json:"features"`
}

type Event

type Event struct {
	Type string    `json:"type"`
	Data EventData `json:"data"`
}

type EventData

type EventData struct {
	DeviceID       uuid.UUID `json:"deviceId"`
	GatewayID      uuid.UUID `json:"gatewayId"`
	LocationID     uuid.UUID `json:"locationId"`
	ModelID        uuid.UUID `json:"modelId"`
	RootLocationID uuid.UUID `json:"rootLocationId"`
	Changes        []Change  `json:"changes"`
	PartnerCode    int       `json:"partnerCode"`
}

type Feature

type Feature struct {
	States map[string]State `json:"states"`
}

type Location

type Location struct {
	Name          string    `json:"name"`
	LocationID    uuid.UUID `json:"locationId"`
	UserID        uuid.UUID `json:"userId"`
	GatewaySerial string    `json:"gatewayserial"`
	PartnerCode   int       `json:"partnerCode"`
}

type LocationDetails

type LocationDetails struct {
	LocationID         uuid.UUID `json:"locationID"`
	GatewaySerial      string    `json:"gatewayserial"`
	Name               string    `json:"name"`
	AlarmState         string    `json:"alarmState"`
	UserRoleAtLocation string    `json:"userRoleAtLocation"`
	Devices            []Device  `json:"devices"`
}

type State

type State struct {
	Value       any       `json:"value"`
	LastUpdated time.Time `json:"lastUpdated"`
}

Directories

Path Synopsis
This package supports a tiny subset of the [Socket.IO] protocol.
This package supports a tiny subset of the [Socket.IO] protocol.

Jump to

Keyboard shortcuts

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