tradfri

package
v0.0.0-...-2aa9fcf Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPort = "5684"

SERVER

Variables

View Source
var ErrorNoBlindControl = errors.New("tradfri Error: device has no blind control")
View Source
var ErrorNoDimmerControl = errors.New("tradfri Error: device has no dimmer control")
View Source
var ErrorNoHexControl = errors.New("tradfri Error: device has no hex control")
View Source
var ErrorNoStateControl = errors.New("tradfri Error: device has no state control")
View Source
var ErrorTradfriConnectionRefused = errors.New("Tradfri Error: Connection refused")
View Source
var MQTTSendTopic func(string, []byte, bool) error

Functions

func ConnectGateway

func ConnectGateway(ctx context.Context, cfg GatewayConfig, onConnect func(), onDisconnect func(), onCanceled func(), onConnectionFailed func()) (coap.CoapDTLSConnection, error)

func Discover

func Discover(force bool)

func GetLevelForHex

func GetLevelForHex(ColorSpace, hex string) (int, error)

func GetNewPSK

func GetNewPSK(gateway string, key string, handler func(ident string, key string, err error))

func Level

func Level(deviceID int, state int)

func ListColorsInMap

func ListColorsInMap(colorMap ColorMap)

func Observe

func Observe()

func RebootGateway

func RebootGateway()

func SendConfigObject

func SendConfigObject(msg []byte)

func SendState

func SendState(msg []byte) error

func SetBlind

func SetBlind(deviceID int, position int)

func SetConnecion

func SetConnecion(conn coap.CoapDTLSConnection)

func SetHex

func SetHex(deviceID int, hex string)

func SetRGB

func SetRGB(id int64, rgb string) error

func SetXY

func SetXY(deviceID int, x int, y int)

func Start

func Start(wg *sync.WaitGroup, status_channel chan (error))

func State

func State(deviceID int, state int)

func Stop

func Stop()

func Test

func Test()

Types

type BlindConfig

type BlindConfig struct {
	CommandTopic        string     `json:"command_topic"`
	PositionTopic       string     `json:"position_topic"`
	PositionTemplate    string     `json:"position_template"`
	SetPositionTopic    string     `json:"set_position_topic"`
	SetPositionTemplate string     `json:"set_position_template"`
	PayloadOpen         string     `json:"payload_open"`
	PayloadClose        string     `json:"payload_close"`
	PayloadStop         string     `json:"payload_stop"`
	Device              DeviceInfo `json:"device"`
	Name                string     `json:"name"`
	UniqueID            string     `json:"unique_id"`
}

type ColorDefinition

type ColorDefinition struct {
	X int64
	Y int64
}

func (*ColorDefinition) ToFloat

func (c *ColorDefinition) ToFloat() (float64, float64)

type ColorMap

type ColorMap map[int]map[string]string

func CWSmap

func CWSmap() ColorMap

func CWmap

func CWmap() ColorMap

func GetColorMap

func GetColorMap(ColorSpace string) (ColorMap, error)

type DeviceInfo

type DeviceInfo struct {
	Identifiers  []string `json:"identifiers"`
	Manufacturer string   `json:"manufacturer"`
	Model        string   `json:"model"`
	Name         string   `json:"name"`
	SwVersion    string   `json:"sw_version"`
}

type DeviceList

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

func (*DeviceList) GetDeviceInfo

func (d *DeviceList) GetDeviceInfo(id int, handler func(*TradfriDevice, error))

func (*DeviceList) Init

func (d *DeviceList) Init()

type DimmerConfig

type DimmerConfig struct {
	Schema       string `json:"schema"`
	CommandTopic string `json:"command_topic"`
	StateTopic   string `json:"state_topic"`
	// StateValueTemplate      string     `json:"state_value_template"`
	// BrightnessCommandTopic  string     `json:"brightness_command_topic"`
	BrightnessScale int `json:"brightness_scale"`
	// BrightnessStateTopic    string     `json:"brightness_state_topic"`
	// BrightnessValueTemplate string     `json:"brightness_value_template"`
	// OnCommandType       string     `json:"on_command_type"`
	Brightness          bool       `json:"brightness"`
	Device              DeviceInfo `json:"device"`
	Name                string     `json:"name"`
	UniqueID            string     `json:"unique_id"`
	ColorMode           bool       `json:"color_mode"`
	SupportedColorModes []string   `json:"supported_color_modes"`
}

type GatewayConfig

type GatewayConfig struct {
	Gateway   string
	Identity  string
	Passkey   string
	KeepAlive int
}

type MQTTLightMessage

type MQTTLightMessage struct {
	Color struct {
		X float64 `json:"x"`
		Y float64 `json:"y"`
	} `json:"color"`
	State      string `json:"state"`
	Brightness int    `json:"brightness"`
	ColorTemp  int    `json:"color_temp"`
	ColorMode  string `json:"color_mode"`
}

type MQTTboolMessage

type MQTTboolMessage struct {
	Value bool `json:"value"`
}

type MQTTmessage

type MQTTmessage struct {
	Value int `json:"value"`
}

type SwitchConfig

type SwitchConfig struct {
	PayloadOff    bool       `json:"payload_off"`
	PayloadOn     bool       `json:"payload_on"`
	ValueTemplate string     `json:"value_template"`
	CommandTopic  string     `json:"command_topic"`
	StateTopic    string     `json:"state_topic"`
	Device        DeviceInfo `json:"device"`
	Name          string     `json:"name"`
	UniqueID      string     `json:"unique_id"`
}

type TradfriBlind

type TradfriBlind struct {
	Id           int64
	Name         string
	Level        float64
	Model        string
	Manufacturer string
}

func ParseBlindInfo

func ParseBlindInfo(aDevice []byte) (TradfriBlind, error)

func (TradfriBlind) Describe

func (p TradfriBlind) Describe() string

type TradfriBlinds

type TradfriBlinds []TradfriBlind

type TradfriDevice

type TradfriDevice struct {
	DeviceInfo struct {
		Manufacturer    string `json:"0"`
		Model           string `json:"1"`
		Num2            string `json:"2"`
		FirmvareVersion string `json:"3"`
		Num6            int    `json:"6"`
		Num7            int    `json:"7"`
		Num8            int    `json:"8"`
		BatteryStatus   int    `json:"9"`
	} `json:"3"`
	LightControl []struct {
		ColorHex string `json:"5706"`
		Num5707  int    `json:"5707"`
		Num5708  int    `json:"5708"`
		ColorX   int    `json:"5709"`
		ColorY   int    `json:"5710"`
		Num5849  int    `json:"5849"`
		State    int    `json:"5850"`
		Dimmer   int    `json:"5851"`
		Num9003  int    `json:"9003"`
	} `json:"3311"`
	PlugControl []struct {
		Num5849 int `json:"5849"`
		State   int `json:"5850"`
		Num5851 int `json:"5851"`
		Num9003 int `json:"9003"`
	} `json:"3312"`
	BlindControl []struct {
		Position float64 `json:"5536"`
		Num9003  int     `json:"9003"`
	} `json:"15015"`
	DeviceType int    `json:"5750"`
	Name       string `json:"9001"`
	Num9002    int    `json:"9002"`
	Id         int    `json:"9003"`
	Num9019    int    `json:"9019"`
	Num9020    int    `json:"9020"`
	Num9054    int    `json:"9054"`
}

func (*TradfriDevice) SetBlind

func (d *TradfriDevice) SetBlind(position int) (string, string, error)

func (*TradfriDevice) SetHex

func (d *TradfriDevice) SetHex(hex string) (string, string, error)

func (*TradfriDevice) SetLevel

func (d *TradfriDevice) SetLevel(level int) (string, string, error)

func (*TradfriDevice) SetState

func (d *TradfriDevice) SetState(state int) (string, string, error)

func (*TradfriDevice) SetXY

func (d *TradfriDevice) SetXY(x int, y int) (string, string, error)

type TradfriLight

type TradfriLight struct {
	Id               int64
	Name             string
	StateDescription string
	State            bool
	Dimmer           int64
	Manufacturer     string
	Model            string
	ColorSpace       string
	ColorValues      ColorDefinition
	Hex              string
}

func ParseLightInfo

func ParseLightInfo(aDevice []byte) (TradfriLight, error)

func (*TradfriLight) SetState

func (d *TradfriLight) SetState(state int) (uri string, payload string, err error)

type TradfriPlug

type TradfriPlug struct {
	Id               int64
	Name             string
	State            bool
	StateDescription string
	Manufacturer     string
	Model            string
}

func ParsePlugInfo

func ParsePlugInfo(aDevice []byte) (TradfriPlug, error)

func (TradfriPlug) Describe

func (p TradfriPlug) Describe() string

type TradfriPlugs

type TradfriPlugs []TradfriPlug

Jump to

Keyboard shortcuts

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