mqttlight

package
v0.0.0-...-d0bc179 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package mqttlight provides support for the Home-Assistant light.mqtt_json component.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(address, username, password, topic, clientId string, messages chan []byte) (MQTT.Client, error)

Types

type State

type State struct {
	Brightness uint8
	Color_temp uint16
	Color      struct {
		R uint8
		G uint8
		B uint8
	}
	Effect      string
	State       string
	Transition  int
	White_value int
}

State holds the message from the Home-Assistant

func Unmarshal

func Unmarshal(cmd []byte) (State, error)

Unmarshal converts a JSON payload into a command structure.

func (State) On

func (c State) On() bool

func (State) TransformColor

func (c State) TransformColor(existing colorful.Color) colorful.Color

func (State) Type

func (c State) Type() StateType

Type returns the update command type, based on which fields were set during JSON unmarshalling.

type StateType

type StateType int

Which kind of JSON message was sent.

const (
	Unknown StateType = iota
	BrightnessChanged
	EffectChanged
	RGBChanged
	StateChanged
	TemperatureChanged
	WhiteValueChanged
)

Jump to

Keyboard shortcuts

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