mqttForwarders

package
v3.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelToSnakeCase

func CamelToSnakeCase(str string) string

func RunMqttForwarders

func RunMqttForwarders(
	cfg Config,
	mc mqttClient.Client,
	devicePool *pool.Pool[*restarter.Restarter[device.Device]],
	stateStorage *dataflow.ValueStorage,
	commandStorage *dataflow.ValueStorage,
)

Types

type CommandMessage

type CommandMessage struct {
	NumericValue *float64 `json:"NumVal,omitempty"`
	TextValue    *string  `json:"TextVal,omitempty"`
	EnumIdx      *int     `json:"EnumIdx,omitempty"`
}

type Config

type Config interface {
	ClientId() string

	AvailabilityClient() MqttSectionConfig
	AvailabilityClientTopic() string

	AvailabilityDevice() MqttSectionConfig
	AvailabilityDeviceTopic(deviceName string) string

	Structure() MqttSectionConfig
	StructureTopic(deviceName string) string

	Telemetry() MqttSectionConfig
	TelemetryTopic(deviceName string) string

	Realtime() MqttSectionConfig
	RealtimeTopic(deviceName, registerName string) string

	HomeassistantDiscovery() MqttSectionConfig
	HomeassistantDiscoveryTopic(component, nodeId, objectId string) string

	Command() MqttSectionConfig
	CommandTopic(deviceName, registerName string) string

	LogDebug() bool
}

type EnumTelemetryValue

type EnumTelemetryValue struct {
	Category    string `json:"Cat"`
	Description string `json:"Desc"`
	EnumIdx     int    `json:"Idx"`
	Value       string `json:"Val"`
}

type MqttDeviceSectionConfig

type MqttDeviceSectionConfig interface {
	Name() string
	Filter() dataflow.RegisterFilterConf
}

type MqttSectionConfig

type MqttSectionConfig interface {
	Enabled() bool
	Interval() time.Duration
	Retain() bool
	Qos() byte
	Devices() []MqttDeviceSectionConfig
}

type Nameable

type Nameable interface {
	Name() string
}

type NumericTelemetryValue

type NumericTelemetryValue struct {
	Category    string  `json:"Cat"`
	Description string  `json:"Desc"`
	Value       float64 `json:"Val"`
	Unit        string  `json:"Unit,omitempty"`
}

type RealtimeMessage

type RealtimeMessage struct {
	NumericValue *float64 `json:"NumVal,omitempty"`
	TextValue    *string  `json:"TextVal,omitempty"`
	EnumIdx      *int     `json:"EnumIdx,omitempty"`
}

type StructRegister

type StructRegister struct {
	Category    string         `json:"Cat" example:"Monitor"`
	Name        string         `json:"Name" example:"PanelPower"`
	Description string         `json:"Desc" example:"Panel power"`
	Type        string         `json:"Type" example:"number"`
	Enum        map[int]string `json:"Enum,omitempty"`
	Unit        string         `json:"Unit,omitempty" example:"W"`
	Sort        int            `json:"Sort" example:"100"`
	Writable    bool           `json:"Cmnd" example:"false"`
}

func NewStructRegister

func NewStructRegister(reg dataflow.Register) StructRegister

type StructureMessage

type StructureMessage struct {
	AvailabilityTopics []string         `json:"Avail,omitempty"`
	TelemetryTopic     string           `json:"Tele,omitempty"`
	RealtimeTopic      string           `json:"Real,omitempty"`
	CommandTopic       string           `json:"Cmnd,omitempty"`
	Registers          []StructRegister `json:"Regs"`
}

type TelemetryMessage

type TelemetryMessage struct {
	Time          string                           `json:"Time"`
	NextTelemetry string                           `json:"NextTelemetry"`
	Model         string                           `json:"Model"`
	NumericValues map[string]NumericTelemetryValue `json:"NumericValues,omitempty"`
	TextValues    map[string]TextTelemetryValue    `json:"TextValues,omitempty"`
	EnumValues    map[string]EnumTelemetryValue    `json:"EnumValues,omitempty"`
}

type TextTelemetryValue

type TextTelemetryValue struct {
	Category    string `json:"Cat"`
	Description string `json:"Desc"`
	Value       string `json:"Val"`
}

Jump to

Keyboard shortcuts

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