converter

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogTopicOnce

func LogTopicOnce(converter string, input Input)

Types

type Config

type Config interface {
	Name() string
	Implementation() string
	TargetMeasurement() string
	MqttTopics() []string
	InfluxClients() []string
	LogHandleOnce() bool
}

type HandleFunc

type HandleFunc func(c Config, input Input, outputFunc OutputFunc)

func GetHandler

func GetHandler(implementation string) (h HandleFunc, err error)

type Input

type Input interface {
	Topic() string
	Payload() []byte
}

type Output

type Output interface {
	Measurement() string
	Tags() map[string]string
	Fields() map[string]interface{}
	Time() time.Time
}

type OutputFunc

type OutputFunc func(output Output)

type SensorMessage

type SensorMessage struct {
	Time    string
	AM2301  *TemperatureHumidity
	SI7021  *TemperatureHumidity
	DS18B20 *struct {
		Temperature float64
	}
	TempUnit string
}

type StateMessage

type StateMessage struct {
	Time   string  // save to timeValue
	Uptime string  // save to timeValue
	Vcc    float64 // save to floatValues
	Power  string  // save to boolValues
	Power1 string  // save to boolValues
	Power2 string  // save to boolValues
	Power3 string  // save to boolValues
	Power4 string  // save to boolValues
	Wifi   Wifi
}

examples:

{
  "Time":"2018-12-16T23:05:14","Uptime":"1T11:32:21","Vcc":3.177,"POWER":"OFF",
  "Wifi":{"AP":1,"SSId":"piegn-iot","BSSId":"04:F0:21:33:40:99","Channel":1,"RSSI":66}
}
{
  "Time":"2018-12-16T23:06:09","Uptime":"8T03:08:26","Vcc":3.112,
  "POWER1":"ON","POWER2":"OFF","POWER3":"OFF","POWER4":"OFF",
  "Wifi":{"AP":1,"SSId":"piegn-iot","BSSId":"04:F0:21:2F:B7:CC","Channel":1,"RSSI":100}
}

type TemperatureHumidity

type TemperatureHumidity struct {
	Temperature float64
	Humidity    float64
}

type Wifi

type Wifi struct {
	AP      int
	SSId    string
	BSSId   string
	Channel int
	RSSI    int
}

Jump to

Keyboard shortcuts

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