magichome

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Discover added in v1.1.0

func Discover(options DiscoverOptions) (*[]Device, error)

Discover searches for Magic Home devices on the network

Types

type Color

type Color struct {
	R uint8
	G uint8
	B uint8
	W uint8
}

Color represents a RGBW color

type Controller

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

Controller represents a Magic Home LED Strip Controller

func New

func New(ip net.IP, port uint16) (*Controller, error)

New initializes a new Magic Home LED Strip Controller

func (*Controller) Close

func (c *Controller) Close() error

Close closes the tcp connection to the LED Strip

func (*Controller) GetDeviceState added in v1.2.0

func (c *Controller) GetDeviceState() (*DeviceState, error)

GetDeviceState can be used to get information about the state of the LED Strip

func (*Controller) SetColor

func (c *Controller) SetColor(color Color) error

SetColor can be used to change the color of the LED Strip

func (*Controller) SetState

func (c *Controller) SetState(s State) error

SetState can be used to switch the LED Strip on (magichome.On) or off (magichome.Off)

type Device added in v1.1.0

type Device struct {
	IP    net.IP
	ID    string
	Model string
}

Device represents a Magic Home device that answered the udp broadcast

type DeviceState added in v1.2.0

type DeviceState struct {
	DeviceType       uint8
	State            State
	LedVersionNumber uint8
	Mode             uint8
	Slowness         uint8
	Color            Color
}

DeviceState represents the state of the device

type DiscoverOptions added in v1.1.0

type DiscoverOptions struct {
	BroadcastAddr string
	Timeout       uint8
}

DiscoverOptions are used to configure the discovering

type State

type State uint8

State represents the status of the device (on or off)

const (
	// On represents the switched-on state of the device
	On State = 1

	// Off represents the switched-off state of the device
	Off State = 0
)

Jump to

Keyboard shortcuts

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