Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
Connect() bool
Subscribe() bool
Listen()
Disconnect()
HandleMessage(topic string, payload []byte)
SetParameterFromString(name string, value string)
SetParameter(name string, param Parameter)
GetParameterValue(parameter string) interface{}
TriggerParameterUpdate(parameter string, value string)
EvalExpressionsInString(in string, functions map[string]govaluate.ExpressionFunction) string
AddParameterSubscription(topic string, parameter string)
RemoveParameterSubscription(topic string, parameter string)
AddRuleFromString(ruleset string, rule string, value string)
AddRule(ruleset string, rule string, r Rule)
GetRule(ruleset string, rule string) *Rule
AddRuleSubscription(topic string, ruleset string, rule string)
RemoveRuleSubscription(topic string, ruleset string, rule string)
ExecuteRule(ruleset string, rule string, triggerPayload string)
Publish(topic string, qos byte, retained bool, payload string)
IsSubscribed(topic string) bool
InjectConfigFile(c ConfigFile)
}
Agent implements the main rules agent
func New ¶
func New(mqttClient MqttClient, prefix string) Agent
Creates and initializes a new MQTT rules client
type ConfigFile ¶
type ConfigFile struct {
Config Config
Parameters map[string]Parameter
Rules map[string]map[string]Rule
}
func ConfigFromFile ¶
func ConfigFromFile(path string) (configFile *ConfigFile, e error)
type MessageHandler ¶
type MqttClient ¶
type MqttClient interface {
IsConnected() bool
Connect() bool
Disconnect()
SetSubscriptionCallback(callback func(string, string))
Publish(topic string, qos byte, retained bool, payload interface{}) bool
Subscribe(topic string, qos byte) bool
Unsubscribe(topics ...string) bool
}
MqttClient provides the interface to a MQTT Client implementation. This interface is provided to enable tests with a mock client
type PahoClient ¶
type PahoClient interface {
IsConnected() bool
Connect() bool
Disconnect()
SetSubscriptionCallback(callback func(string, string))
Publish(topic string, qos byte, retained bool, payload interface{}) bool
Subscribe(topic string, qos byte) bool
Unsubscribe(topics ...string) bool
}
func NewPahoClient ¶
func NewPahoClient(o *mqtt.ClientOptions) PahoClient
Click to show internal directories.
Click to hide internal directories.