Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Characteristic ¶ added in v1.3.0
type Characteristic struct {
// contains filtered or unexported fields
}
Characteristic is a songle sensor value.
type DevicePlugin ¶ added in v1.6.7
type DevicePlugin interface { MqttSubscription // SetMeasurementChannel assigns a channel plugin should write extracted indoor climate measurements to. SetMeasurementChannel(chan<- IndoorClimateMeasurement) }
DevicePlugin is used to subscribe to MQTT topics and extract measurements from published data.
type DevicePluginKey ¶ added in v1.6.7
type DevicePluginKey string
DevicePluginKey defines a plugin for devices of a specific manufacturer.
const ( PLUGIN_SHELLY DevicePluginKey = "shelly" PLUGIN_LOGGER DevicePluginKey = "logger" )
type IndoorClimateMeasurement ¶ added in v1.3.0
type IndoorClimateMeasurement struct { DeviceId string Timestamp time.Time Type MeasurementType Value string }
IndoorClimateMeasurement is a metric read from a sensor device.
type MeasurementType ¶ added in v1.6.0
type MeasurementType string
MeasurementType is a indoor climate date type, e.g. temperature.
const ( MEASUREMENTTYPE_TEMPERATURE MeasurementType = "temperature" MEASUREMENTTYPE_HUMIDITY MeasurementType = "humidity" MEASUREMENTTYPE_BATTERY MeasurementType = "battery" )
type MockPlugin ¶ added in v1.6.8
type MockPlugin struct {
// contains filtered or unexported fields
}
MockPlugin can be used for testing. it generates static indoor climate measuremnts based on received message.
Message | Indoor CLimate Data
--------------------------------------
temperature | Temperature 24.7°C humidity | Humidity 53.9% battery | Capacity 87% <default> | Temperature 12.3°C
func NewMockPlugin ¶ added in v1.6.8
func NewMockPlugin(logger log.Logger, deviceId *string) *MockPlugin
NewMockPlugin creates a new mock plugin.
func (*MockPlugin) MessageHandler ¶ added in v1.6.8
func (plugin *MockPlugin) MessageHandler(client mqtt.Client, message mqtt.Message)
MessageHandler process message received from MQTT topic and pulishes static indoor climate data depending on message payload.
func (*MockPlugin) SetMeasurementChannel ¶ added in v1.6.8
func (plugin *MockPlugin) SetMeasurementChannel(channel chan<- IndoorClimateMeasurement)
SetMeasurementChannel assign a channel measuremnts should be written to.
type MockTarget ¶ added in v1.6.8
type MockTarget struct {
Measurements []IndoorClimateMeasurement
}
MockTarget can be used for testing. It appends all measurements to an internal slice.
func NewMockTarget ¶ added in v1.6.8
func NewMockTarget() *MockTarget
func (*MockTarget) SendMeasurement ¶ added in v1.6.8
func (target *MockTarget) SendMeasurement(measurement IndoorClimateMeasurement) error
type MqttCollector ¶ added in v1.6.7
type MqttCollector struct {
// contains filtered or unexported fields
}
MqttCollector subcribes to MQTT topics to extract indoor climate date from published messages.
func NewMqttCollector ¶ added in v1.6.7
func NewMqttCollector(conf config.Config, logger log.Logger) *MqttCollector
NewMqttCollector returns a new collector listen for MQTT messages to obtain indoor climate data.
func (*MqttCollector) AppendSubscription ¶ added in v1.6.8
func (collector *MqttCollector) AppendSubscription(subscription MqttSubscriptionConfig)
AppendSubscription will append passed subscription to internal subscription list.
func (*MqttCollector) AppendTarget ¶ added in v1.6.7
func (collector *MqttCollector) AppendTarget(newTarget Publisher)
AooendTarget will append passed target to internal publisher list.
type MqttLivenessObserver ¶ added in v1.8.1
type MqttLivenessObserver struct {
// contains filtered or unexported fields
}
MqttLivenessObserver can be use to observer a MQTT server.
func NewMqttLivenessObserver ¶ added in v1.8.1
func NewMqttLivenessObserver(conf config.Config, logger log.Logger) *MqttLivenessObserver
NewMqttLivenessObserver creates a new liveness probe for MQTT.
func (*MqttLivenessObserver) MessageHandler ¶ added in v1.8.1
func (observer *MqttLivenessObserver) MessageHandler(mclient mqtt.Client, msg mqtt.Message)
MessageHandler listen for message on liveness topic and writes them to internal prove chan.
type MqttSubscription ¶ added in v1.6.7
type MqttSubscription interface { // MessageHandler process received data received from a mqtt topic MessageHandler(mqtt.Client, mqtt.Message) }
MqttSubscription is used to handle messages received from subscribes MQTT topics.
type MqttSubscriptionConfig ¶ added in v1.6.7
type MqttSubscriptionConfig struct { Topic string Plugin DevicePlugin }
MqttSubscriptionConfig define a MQTT topic and it's message handler plugin.
type Publisher ¶ added in v1.3.0
type Publisher interface { // SendMeasurement will start to transfer passed measurement to a target. SendMeasurement(IndoorClimateMeasurement) error }
Publisher sends given measuremnts to different targets.