coap

package
v0.0.0-...-1cd6bff Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootDevices = 15001
	RootGroups  = 15004
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(network, address, username, psk string) (*Client, error)

func (*Client) Auth

func (c *Client) Auth(username string) (psk string, err error)

func (*Client) GetDevice

func (c *Client) GetDevice(id int) (d Device, err error)

func (*Client) GetGroup

func (c *Client) GetGroup(id int) (g Group, err error)

func (*Client) ListDevices

func (c *Client) ListDevices() ([]Device, error)

func (*Client) ListGroups

func (c *Client) ListGroups() ([]Group, error)

func (*Client) SetLightControlDimmer

func (c *Client) SetLightControlDimmer(root, id int, dimmer int, transition time.Duration) error

func (*Client) SetLightControlMireds

func (c *Client) SetLightControlMireds(root, id int, mireds int, transition time.Duration) error

func (*Client) SetLightControlState

func (c *Client) SetLightControlState(root, id int, on bool) error

type Device

type Device struct {
	Resource
	DeviceInfo struct {
		Manufacturer string      `json:"0"`
		Model        string      `json:"1"`
		Serial       string      `json:"2"`
		Firmware     string      `json:"3"`
		PowerSource  PowerSource `json:"6"`
		BatteryLevel Percent100  `json:"9"`
	} `json:"3"`
	LastSeen     Timestamp      `json:"9020"`
	Reachable    YesNo          `json:"9019"`
	LightControl []LightControl `json:"3311"`
}

func (Device) Long

func (d Device) Long() string

func (Device) Short

func (d Device) Short() string

type Group

type Group struct {
	Resource
	State         OnOff      `json:"5850"`
	Dimmer        Percent255 `json:"5851"`
	LightColorHex string     `json:"5706"`
	MoodID        int        `json:"9039"`
	GroupMembers  struct {
		HSLink struct {
			IDs []int `json:"9003"`
		} `json:"15002"`
	} `json:"9018"`
}

func (Group) Long

func (g Group) Long() string

func (Group) Short

func (g Group) Short() string

type LightControl

type LightControl struct {
	State         OnOff      `json:"5850"`
	Dimmer        Percent255 `json:"5851"`
	LightColorHex string     `json:"5706"`
	LightColorX   int        `json:"5709"`
	LightColorY   int        `json:"5710"`
	LightMireds   int        `json:"5711"`
	Unknown       int        `json:"5717"`
}

type LightControlInput

type LightControlInput struct {
	State         *OnOff      `json:"5850,omitempty"`
	Dimmer        *Percent255 `json:"5851,omitempty"`
	LightColorHex *string     `json:"5706,omitempty"`
	LightColorX   *int        `json:"5709,omitempty"`
	LightColorY   *int        `json:"5710,omitempty"`
	LightMireds   *int        `json:"5711,omitempty"`
	Transition    *int        `json:"5712,omitempty"`
}

type OnOff

type OnOff int

func (OnOff) String

func (o OnOff) String() string

type Percent100

type Percent100 int

func (Percent100) String

func (p Percent100) String() string

type Percent255

type Percent255 int

func (Percent255) String

func (p Percent255) String() string

type PowerSource

type PowerSource int

func (PowerSource) String

func (ps PowerSource) String() string

type Resource

type Resource struct {
	Name      string    `json:"9001"`
	CreatedAt Timestamp `json:"9002"`
	ID        int       `json:"9003"`
}

type SetGroupProperties

type SetGroupProperties struct {
	State       int
	Dimmer      int
	ColorHex    string
	ColorX      int
	ColorY      int
	ColorMireds int
	Transition  int
}

type Timestamp

type Timestamp int

func (Timestamp) String

func (ts Timestamp) String() string

type YesNo

type YesNo int

func (YesNo) String

func (yn YesNo) String() string

Jump to

Keyboard shortcuts

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