lutron

package module
v0.0.0-...-eba6f6e Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: MIT Imports: 11 Imported by: 0

README

go-lutron

minimal golang library for interacting with telnet based Lutron integration protocol (for Caseta)

http://www.lutron.com/TechnicalDocumentLibrary/040249.pdf

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CasetaDevice

type CasetaDevice struct {
	ID   int
	Name string
	Area string
}

Simpler interface

type CasetaInventory

type CasetaInventory struct {
	LIPIDList struct {
		Devices []struct {
			ID      int    `json:"ID"`
			Name    string `json:"Name"`
			Buttons []struct {
				Name   string `json:"Name"`
				Number int    `json:"Number"`
			} `json:"Buttons"`
			Area struct {
				Name string `json:"Name"`
			} `json:"Area"`
		} `json:"Devices"`
		Zones []struct {
			ID   int    `json:"ID"`
			Name string `json:"Name"`
			Area struct {
				Name string `json:"Name"`
			} `json:"Area"`
		} `json:"Zones"`
	} `json:"LIPIdList"`
}

Raw parsed json from the caseta app via https://mholt.github.io/json-to-go/

func NewCasetaInventory

func NewCasetaInventory(path string) *CasetaInventory

func (*CasetaInventory) Get

func (i *CasetaInventory) Get(id int) (CasetaDevice, error)

func (*CasetaInventory) IdFromName

func (i *CasetaInventory) IdFromName(n string) (id int, err error)

func (*CasetaInventory) NameFromId

func (i *CasetaInventory) NameFromId(id int) (name string, err error)

type Command

type Command string
const (
	Output  Command = "OUTPUT"
	Device  Command = "DEVICE"
	Group   Command = "GROUP"
	Unknown Command = "UNKNOWN"
)

type Inventory

type Inventory interface {
	NameFromId(int) (string, error)
	IdFromName(string) (int, error)
	Get(int) (CasetaDevice, error)
}

type Lutron

type Lutron struct {
	Port string

	Username string
	Password string
	// contains filtered or unexported fields
}

func NewLutron

func NewLutron(hostName, inventoryPath string) *Lutron

func (*Lutron) Connect

func (l *Lutron) Connect() error

func (*Lutron) Disconnect

func (l *Lutron) Disconnect() error

func (*Lutron) NameFromId

func (l *Lutron) NameFromId(i int) (string, error)

func (*Lutron) Send

func (l *Lutron) Send(msg string) error

func (*Lutron) SendCommand

func (l *Lutron) SendCommand(c *LutronMsg) (resp string, err error)

func (*Lutron) SetById

func (l *Lutron) SetById(id int, level float64) error

TODO - how many API variations to support - need to have one with Fade

func (*Lutron) SetByName

func (l *Lutron) SetByName(name string, level float64) error

func (*Lutron) Watch

func (l *Lutron) Watch(c *LutronMsg) (responses chan *LutronMsg, stop chan bool)

type LutronMsg

type LutronMsg struct {
	// the lutron component number
	Id    int
	Name  string
	Value float64
	// duration in seconds for a set action
	// TODO parse > 60 seconds into string "M:SS"
	Fade float64
	// the action to take with the command, Get, Set, Watch, Default: Get
	Type MsgType
	// the integration command type - Output, Device
	Cmd Command
	// usually the button press
	Action int
	// in Unix nanos format
	Timestamp int64
}

type MsgType

type MsgType int
const (
	Get MsgType = iota
	Set
	Watch
	Response
)

type ResponseWatcher

type ResponseWatcher struct {
	Responses chan *LutronMsg
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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