mqtt

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTopicConfig = TopicConfig{Topic: "#", Qos: 0, MeasurementIndex: -1, FieldIndex: -1, Fields: map[string]FieldConfig{}, TemplateToCall: "mqttaction"}

Functions

This section is empty.

Types

type FieldConfig

type FieldConfig struct {
	Datatype  string
	Alias     *string // name used in influx
	TrueValue *string // if datatype==bool, this is used as true value, everything else is false
}

type FieldWithType

type FieldWithType struct {
	FieldType  string
	FieldValue string
}

type FreepsMqttConfig

type FreepsMqttConfig struct {
	Enabled     bool
	Server      string // The full url of the MQTT server to connect to ex: tcp://127.0.0.1:1883
	Username    string // A username to authenticate to the MQTT server
	Password    string // Password to match username
	Topics      []TopicConfig
	ResultTopic string // Topic to publish results to; empty (default) means no publishing of results
}

type FreepsMqttImpl

type FreepsMqttImpl struct {
	Config *FreepsMqttConfig
	// contains filtered or unexported fields
}

func (*FreepsMqttImpl) Shutdown

func (fm *FreepsMqttImpl) Shutdown()

Shutdown MQTT and cancel all subscriptions

func (*FreepsMqttImpl) StartListening added in v1.3.0

func (fm *FreepsMqttImpl) StartListening() error

type HookMQTT added in v1.3.0

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

func (*HookMQTT) OnGraphChanged added in v1.3.0

func (h *HookMQTT) OnGraphChanged(ctx *base.Context, addedGraphName []string, removedGraphName []string) error

OnGraphChanged checks if subscriptions need to be changed

type JsonArgs

type JsonArgs struct {
	Measurement    string
	FieldsWithType map[string]FieldWithType
}

type OpMQTT

type OpMQTT struct {
	CR *utils.ConfigReader
	GE *freepsgraph.GraphEngine
	// contains filtered or unexported fields
}

func (*OpMQTT) ExecuteDynamic added in v1.3.0

func (o *OpMQTT) ExecuteDynamic(ctx *base.Context, fn string, fa base.FunctionArguments, input *base.OperatorIO) *base.OperatorIO

func (*OpMQTT) GetDefaultConfig added in v1.3.0

func (o *OpMQTT) GetDefaultConfig() interface{}

func (*OpMQTT) GetDynamicArgSuggestions added in v1.3.0

func (o *OpMQTT) GetDynamicArgSuggestions(fn string, arg string, otherArgs base.FunctionArguments) map[string]string

func (*OpMQTT) GetDynamicFunctions added in v1.3.0

func (o *OpMQTT) GetDynamicFunctions() []string

func (*OpMQTT) GetDynamicPossibleArgs added in v1.3.0

func (o *OpMQTT) GetDynamicPossibleArgs(fn string) []string

func (*OpMQTT) GetHook added in v1.3.0

func (o *OpMQTT) GetHook() interface{}

func (*OpMQTT) GetSubscriptions added in v1.3.0

func (o *OpMQTT) GetSubscriptions(ctx *base.Context) *base.OperatorIO

GetSubscriptions returns a list of all subscriped topics

func (*OpMQTT) InitCopyOfOperator added in v1.3.0

func (o *OpMQTT) InitCopyOfOperator(ctx *base.Context, config interface{}, name string) (base.FreepsOperatorWithConfig, error)

func (*OpMQTT) Shutdown

func (o *OpMQTT) Shutdown(ctx *base.Context)

func (*OpMQTT) StartListening added in v1.3.0

func (o *OpMQTT) StartListening(ctx *base.Context)

func (*OpMQTT) TriggerSubscriptionChange added in v1.3.0

func (o *OpMQTT) TriggerSubscriptionChange(ctx *base.Context) *base.OperatorIO

TriggerSubscriptionChange triggers a change in the subscriptions

type TopicConfig

type TopicConfig struct {
	Topic string // Topic to subscribe to
	Qos   int    // The QoS to subscribe to messages at
	// the topic string is split by slash; the values of the resulting array can be used as measurement and field - the index can be specified here
	MeasurementIndex int                    // index that points to the measurement in the topic-array
	FieldIndex       int                    // index that points to the field in the topic-array
	Fields           map[string]FieldConfig `json:",omitempty"`
	TemplateToCall   string                 `json:",omitempty"`
	GraphToCall      string
}

Jump to

Keyboard shortcuts

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