pkg

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const AutoDisconnectTime = 1000
View Source
const DefaultMQTTPort = 1883
View Source
const ExpectedColorCount = 3
View Source
const StateOff = "off"
View Source
const StateOn = "on"

Variables

View Source
var ErrorIntervalGreaterThanZero = errors.New("query engine interval must be greater than 1 second")
View Source
var ErrorMustHaveOneIndex = errors.New("query engine controller list must have at least 1 index")
View Source
var ErrorStateMachineNil = errors.New("query engine state machine must not be nil")

Functions

This section is empty.

Types

type Config

type Config struct {
	Controllers   []string
	QueryInterval time.Duration

	MQTTHost        string
	MQTTPort        int
	MQTTClientID    string
	MQTTUsername    string
	MQTTPassword    string
	MQTTTopicPrefix string
}

func GetConfig

func GetConfig() Config

func (*Config) GetControllerList

func (c *Config) GetControllerList() []string

func (*Config) GetMQTTClientID

func (c *Config) GetMQTTClientID() string

func (*Config) GetMQTTHost

func (c *Config) GetMQTTHost() string

func (*Config) GetMQTTPassword

func (c *Config) GetMQTTPassword() string

func (*Config) GetMQTTPort

func (c *Config) GetMQTTPort() int

func (*Config) GetMQTTTopicPrefix

func (c *Config) GetMQTTTopicPrefix() string

func (*Config) GetMQTTUsername

func (c *Config) GetMQTTUsername() string

func (*Config) GetQueryInterval

func (c *Config) GetQueryInterval() time.Duration

type FalconMessage

type FalconMessage struct {
	Command string   `json:"command"`
	Args    []string `json:"args"`
}

type LightMessage

type LightMessage struct {
	Controller string `json:"controller,omitempty"`
	State      string `json:"state"`
	RGBColor   []int  `json:"color,omitempty"`
}

type MQTTClient

type MQTTClient struct {
	Log *logrus.Entry
	// contains filtered or unexported fields
}

func NewMQTTClient

func NewMQTTClient(log *logrus.Logger, host string, port int, clientID, username, password, topicPrefix string) *MQTTClient

func (*MQTTClient) GetClient

func (mc *MQTTClient) GetClient() MQTT.Client

func (*MQTTClient) HandleSetLightMessage

func (mc *MQTTClient) HandleSetLightMessage(slug string, payload LightMessage)

func (*MQTTClient) OnClientConnect

func (mc *MQTTClient) OnClientConnect(client MQTT.Client)

func (*MQTTClient) OnClientDisconnect

func (mc *MQTTClient) OnClientDisconnect(client MQTT.Client, err error)

func (*MQTTClient) PublishOverlayModelStatus

func (mc *MQTTClient) PublishOverlayModelStatus(slug string, model OverlayModel)

func (*MQTTClient) Start

func (mc *MQTTClient) Start(stateMachine *StateMachine) error

func (*MQTTClient) Stop

func (mc *MQTTClient) Stop()

type OnStateChange

type OnStateChange func(string, OverlayModel)

type OverlayModel

type OverlayModel struct {
	Name     string
	State    bool
	RGBColor []int
}

type OverlayModelResponseData

type OverlayModelResponseData struct {
	Name     string `json:"name"`
	IsActive int    `json:"isActive"`
}

type QueryEngine

type QueryEngine struct {
	Controllers  []string
	Interval     time.Duration
	StateMachine *StateMachine
	Log          *logrus.Entry
	// contains filtered or unexported fields
}

func (*QueryEngine) Start

func (qe *QueryEngine) Start() error

func (*QueryEngine) Stop

func (qe *QueryEngine) Stop()

type StateMachine

type StateMachine struct {
	OverlayModels syncmap.Map
	Callback      OnStateChange
}

func (*StateMachine) GenerateSlug

func (sm *StateMachine) GenerateSlug(controller, name string) string

func (*StateMachine) UpdateBySlug

func (sm *StateMachine) UpdateBySlug(slug, name string, state bool, rgbColor []int)

Jump to

Keyboard shortcuts

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