sensors

package
v0.0.0-...-84454fc Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FlagRtl433Path string
View Source
var SupportedSensorDevices = map[string]*SupportedDevice{
	"usb_zytemp": {"USB CO2 sensor: Holtek Semiconductor, Inc. USB-zyTemp", InitFlags_zytemp, InitSensor_zytemp},
	"rtl_433":    {"Generic wrapper using rtl_433 to collect measurements", InitFlags_rtl433, InitSensor_rtl433},
}

Functions

func F_2_C

func F_2_C(v float64) float64

func IN_2_MM

func IN_2_MM(v float64) float64

func InitFlags_rtl433

func InitFlags_rtl433()

func InitFlags_zytemp

func InitFlags_zytemp()

func KM_H_2_M_S

func KM_H_2_M_S(v float64) float64

func KPA_2_HPA

func KPA_2_HPA(v float64) float64

func MI_H_2_M_S

func MI_H_2_M_S(v float64) float64

func NO_CONV

func NO_CONV(v float64) float64

func PSI_2_HPA

func PSI_2_HPA(v float64) float64

Types

type DeviceConfig

type DeviceConfig map[string]string

type Measurement

type Measurement struct {
	Type        MeasurementType
	Value       float64
	SensorModel string // model of sensor to use as label - in case multiple sensors report the same measurement
	SensorId    string // id of sensor to use as label - in case multiple sensors report the same measurement
}

type MeasurementType

type MeasurementType int

define supported measurement types

const (
	// measurements from zyTemp
	TEMPERATURE_C MeasurementType = iota
	HUMIDITY_PERCENT
	CO2_PPM

	// additional measurements from rtl 433 - is there a complete list
	BATTERY
	BATTERY_OK

	POWER_W

	PREASURE_HPA

	RAIN_RATE_MM_H
	RAIN_MM

	UV_INDEX

	WIND_AVG_M_S
	WIND_MAX_M_S
	WIND_DIR_DEG

	// couter types
	VALUES_COUNTER
	IGNORED_COUNTER

	// types for error counters
	ERRORS_CONNECT
	ERRORS_IO
	ERRORS_PARSE
)

func GetAllMeasurementTypes

func GetAllMeasurementTypes() []MeasurementType

type MeasurementTypeDetails

type MeasurementTypeDetails struct {
	MetricName  string // will be used as last part prometheus metric FQName
	MetricHelp  string // metric help
	MetricValue ValueType
}

func GetMeasurementTypeDetails

func GetMeasurementTypeDetails(m_type MeasurementType) MeasurementTypeDetails

type SensorDevice

type SensorDevice interface {
	DeviceType() string
	DeviceId() string
	DeviceVendor() string
	DeviceName() string
	GetMeasurements() []Measurement
}

define generic interface to be implemented by each sensor device

func InitSensor_rtl433

func InitSensor_rtl433(cfg *DeviceConfig) (SensorDevice, error)

func InitSensor_zytemp

func InitSensor_zytemp(cfg *DeviceConfig) (SensorDevice, error)

type SupportedDevice

type SupportedDevice struct {
	Description       string
	InitFlagsFunction func()
	InitFunction      func(*DeviceConfig) (SensorDevice, error)
}

type UnitConverter

type UnitConverter struct {
	SrcType string
	DstType string
	Convert UnitConverterFunc
}

func GetMeasurementConverter

func GetMeasurementConverter(typedUnit string) (string, *UnitConverter)

type UnitConverterFunc

type UnitConverterFunc func(float64) float64

define unit conversion routines

type ValueType

type ValueType int

now define for each MeasurementType details to be used for creating a prometheus metric for it

const (
	COUNTER ValueType = iota
	GAUGE
)

Jump to

Keyboard shortcuts

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