Documentation ¶
Index ¶
- func Cached[T any](g func() (T, error), cache time.Duration) func() (T, error)
- func NewBoolGetterFromConfig(ctx context.Context, config Config) (func() (bool, error), error)
- func NewBoolSetterFromConfig(ctx context.Context, param string, config Config) (func(bool) error, error)
- func NewBytesSetterFromConfig(ctx context.Context, param string, config Config) (func([]byte) error, error)
- func NewCombinedProvider(plugged, charging func() (bool, error)) *combinedProvider
- func NewFloatGetterFromConfig(ctx context.Context, config Config) (func() (float64, error), error)
- func NewFloatSetterFromConfig(ctx context.Context, param string, config Config) (func(float642 float64) error, error)
- func NewIntGetterFromConfig(ctx context.Context, config Config) (func() (int64, error), error)
- func NewIntSetterFromConfig(ctx context.Context, param string, config Config) (func(int64) error, error)
- func NewStringGetterFromConfig(ctx context.Context, config Config) (func() (string, error), error)
- func NewStringSetterFromConfig(ctx context.Context, param string, config Config) (func(string) error, error)
- func ResetCached()
- func ResettableCached[T any](g func() (T, error), cache time.Duration) *cached[T]
- type Auth
- type BoolProvider
- type Cacheable
- type Case
- type Config
- type FloatProvider
- type Getters
- type Go
- func (p *Go) BoolGetter() (func() (bool, error), error)
- func (p *Go) BoolSetter(param string) (func(bool) error, error)
- func (p *Go) FloatGetter() (func() (float64, error), error)
- func (p *Go) FloatSetter(param string) (func(float64) error, error)
- func (p *Go) IntGetter() (func() (int64, error), error)
- func (p *Go) IntSetter(param string) (func(int64) error, error)
- func (p *Go) StringGetter() (func() (string, error), error)
- func (p *Go) StringSetter(param string) (func(string) error, error)
- type HTTP
- func (p HTTP) BoolGetter() (func() (bool, error), error)
- func (p *HTTP) BoolSetter(param string) (func(bool) error, error)
- func (p HTTP) FloatGetter() (func() (float64, error), error)
- func (p *HTTP) FloatSetter(param string) (func(float64) error, error)
- func (p HTTP) IntGetter() (func() (int64, error), error)
- func (p *HTTP) IntSetter(param string) (func(int64) error, error)
- func (p *HTTP) StringGetter() (func() (string, error), error)
- func (p *HTTP) StringSetter(param string) (func(string) error, error)
- func (p *HTTP) WithAuth(typ, user, password string) (*HTTP, error)
- func (p *HTTP) WithBody(body string) *HTTP
- func (p *HTTP) WithHeaders(headers map[string]string) *HTTP
- func (p *HTTP) WithPipeline(pipeline *pipeline.Pipeline) *HTTP
- type IntProvider
- type Javascript
- func (p *Javascript) BoolGetter() (func() (bool, error), error)
- func (p *Javascript) BoolSetter(param string) (func(bool) error, error)
- func (p *Javascript) FloatGetter() (func() (float64, error), error)
- func (p *Javascript) FloatSetter(param string) (func(float64) error, error)
- func (p *Javascript) IntGetter() (func() (int64, error), error)
- func (p *Javascript) IntSetter(param string) (func(int64) error, error)
- func (p *Javascript) StringGetter() (func() (string, error), error)
- func (p *Javascript) StringSetter(param string) (func(string) error, error)
- type Modbus
- func (m *Modbus) BoolGetter() (func() (bool, error), error)
- func (m *Modbus) BoolSetter(param string) (func(bool) error, error)
- func (m *Modbus) BytesSetter(_ string) (func([]byte) error, error)
- func (m *Modbus) FloatGetter() (func() (f float64, err error), error)
- func (m *Modbus) FloatSetter(_ string) (func(float64) error, error)
- func (m *Modbus) IntGetter() (func() (int64, error), error)
- func (m *Modbus) IntSetter(_ string) (func(int64) error, error)
- func (m *Modbus) StringGetter() (func() (string, error), error)
- type ModbusSunspec
- type Mqtt
- func (p Mqtt) BoolGetter() (func() (bool, error), error)
- func (m *Mqtt) BoolSetter(param string) (func(bool) error, error)
- func (p Mqtt) FloatGetter() (func() (float64, error), error)
- func (m *Mqtt) FloatSetter(param string) (func(float64) error, error)
- func (p Mqtt) IntGetter() (func() (int64, error), error)
- func (m *Mqtt) IntSetter(param string) (func(int64) error, error)
- func (m *Mqtt) StringGetter() (func() (string, error), error)
- func (m *Mqtt) StringSetter(param string) (func(string) error, error)
- func (m *Mqtt) WithPayload(payload string) *Mqtt
- func (p *Mqtt) WithPipeline(pipeline *pipeline.Pipeline) *Mqtt
- func (m *Mqtt) WithRetained() *Mqtt
- func (m *Mqtt) WithScale(scale float64) *Mqtt
- type Prometheus
- type Provider
- func NewCalcFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewCombinedFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewConstFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewConvertFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewErrorFromConfig(other map[string]interface{}) (Provider, error)
- func NewGoProviderFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewHTTPProviderFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewIgnoreFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewJavascriptProviderFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewMapFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewModbusFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewModbusSunspecFromConfig(other map[string]interface{}) (Provider, error)
- func NewMqttFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewPrometheusFromConfig(other map[string]interface{}) (Provider, error)
- func NewRandomFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewSMAFromConfig(other map[string]interface{}) (Provider, error)
- func NewScriptProviderFromConfig(other map[string]interface{}) (Provider, error)
- func NewSequenceFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewSocketProviderFromConfig(other map[string]interface{}) (Provider, error)
- func NewSwitchFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- func NewWatchDogFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
- type SMA
- type Script
- func (p Script) BoolGetter() (func() (bool, error), error)
- func (p *Script) BoolSetter(param string) (func(bool) error, error)
- func (p Script) FloatGetter() (func() (float64, error), error)
- func (p Script) IntGetter() (func() (int64, error), error)
- func (p *Script) IntSetter(param string) (func(int64) error, error)
- func (p *Script) StringGetter() (func() (string, error), error)
- func (p *Script) StringSetter(param string) (func(string) error, error)
- type SetBoolProvider
- type SetBytesProvider
- type SetFloatProvider
- type SetIntProvider
- type SetStringProvider
- type Socket
- type StringProvider
- type TimeoutHandler
- func (h *TimeoutHandler) BoolGetter(p BoolProvider) (func() (bool, error), error)
- func (h *TimeoutHandler) FloatGetter(p FloatProvider) (func() (float64, error), error)
- func (h *TimeoutHandler) JsonGetter(p StringProvider) (func(any) error, error)
- func (h *TimeoutHandler) StringGetter(p StringProvider) (func() (string, error), error)
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBoolGetterFromConfig ¶
NewBoolGetterFromConfig creates a BoolGetter from config
func NewBoolSetterFromConfig ¶
func NewBoolSetterFromConfig(ctx context.Context, param string, config Config) (func(bool) error, error)
NewBoolSetterFromConfig creates a BoolSetter from config
func NewBytesSetterFromConfig ¶
func NewBytesSetterFromConfig(ctx context.Context, param string, config Config) (func([]byte) error, error)
NewBytesSetterFromConfig creates a BytesSetter from config
func NewCombinedProvider ¶
NewCombinedProvider creates provider for OpenWB status converted from MQTT topics
func NewFloatGetterFromConfig ¶
NewFloatGetterFromConfig creates a FloatGetter from config
func NewFloatSetterFromConfig ¶
func NewFloatSetterFromConfig(ctx context.Context, param string, config Config) (func(float642 float64) error, error)
NewFloatSetterFromConfig creates a FloatSetter from config
func NewIntGetterFromConfig ¶
NewIntGetterFromConfig creates a IntGetter from config
func NewIntSetterFromConfig ¶
func NewIntSetterFromConfig(ctx context.Context, param string, config Config) (func(int64) error, error)
NewIntSetterFromConfig creates a IntSetter from config
func NewStringGetterFromConfig ¶
NewStringGetterFromConfig creates a StringGetter from config
func NewStringSetterFromConfig ¶
func NewStringSetterFromConfig(ctx context.Context, param string, config Config) (func(string) error, error)
NewStringSetterFromConfig creates a StringSetter from config
func ResetCached ¶
func ResetCached()
Types ¶
type BoolProvider ¶
provider types
type FloatProvider ¶
provider types
type Getters ¶
type Getters interface { StringProvider FloatProvider IntProvider BoolProvider }
provider types
type Go ¶
type Go struct {
// contains filtered or unexported fields
}
Go implements Go request provider
func (*Go) BoolGetter ¶
BoolGetter parses bool from request
func (*Go) BoolSetter ¶
BoolSetter sends bool request
func (*Go) FloatGetter ¶
FloatGetter parses float from request
func (*Go) FloatSetter ¶
FloatSetter sends float request
func (*Go) StringGetter ¶
StringGetter parses string from request
type HTTP ¶
HTTP implements HTTP request provider
func (HTTP) BoolGetter ¶
BoolGetter parses bool from exec result. "on", "true" and 1 are considered truish.
func (*HTTP) BoolSetter ¶
BoolSetter sends bool request
func (HTTP) FloatGetter ¶
FloatGetter parses float from exec result
func (*HTTP) FloatSetter ¶
FloatSetter sends int request
func (*HTTP) StringGetter ¶
StringGetter sends string request
func (*HTTP) StringSetter ¶
StringSetter sends string request
func (*HTTP) WithHeaders ¶
WithHeaders adds request headers
type IntProvider ¶
provider types
type Javascript ¶
type Javascript struct {
// contains filtered or unexported fields
}
Javascript implements Javascript request provider
func (*Javascript) BoolGetter ¶
func (p *Javascript) BoolGetter() (func() (bool, error), error)
BoolGetter parses bool from request
func (*Javascript) BoolSetter ¶
func (p *Javascript) BoolSetter(param string) (func(bool) error, error)
BoolSetter sends bool request
func (*Javascript) FloatGetter ¶
func (p *Javascript) FloatGetter() (func() (float64, error), error)
FloatGetter parses float from request
func (*Javascript) FloatSetter ¶
func (p *Javascript) FloatSetter(param string) (func(float64) error, error)
FloatSetter sends float request
func (*Javascript) IntGetter ¶
func (p *Javascript) IntGetter() (func() (int64, error), error)
IntGetter parses int64 from request
func (*Javascript) IntSetter ¶
func (p *Javascript) IntSetter(param string) (func(int64) error, error)
IntSetter sends int request
func (*Javascript) StringGetter ¶
func (p *Javascript) StringGetter() (func() (string, error), error)
StringGetter parses string from request
func (*Javascript) StringSetter ¶
func (p *Javascript) StringSetter(param string) (func(string) error, error)
StringSetter sends string request
type Modbus ¶
type Modbus struct {
// contains filtered or unexported fields
}
Modbus implements modbus RTU and TCP access
func (*Modbus) BoolGetter ¶
BoolGetter implements BoolProvider
func (*Modbus) BoolSetter ¶
BoolSetter implements SetBoolProvider
func (*Modbus) BytesSetter ¶
BytesSetter implements SetBytesProvider
func (*Modbus) FloatGetter ¶
FloatGetter implements func() (float64, error)
func (*Modbus) FloatSetter ¶
FloatSetter implements SetFloatProvider
type ModbusSunspec ¶
type ModbusSunspec struct {
// contains filtered or unexported fields
}
ModbusSunspec implements modbus RTU and TCP access
func (*ModbusSunspec) FloatGetter ¶
func (m *ModbusSunspec) FloatGetter() (func() (f float64, err error), error)
FloatGetter executes configured modbus read operation and implements func() (float64, error)
func (*ModbusSunspec) FloatSetter ¶
func (m *ModbusSunspec) FloatSetter(_ string) (func(float64) error, error)
FloatSetter executes configured modbus write operation and implements SetFloatProvider
type Mqtt ¶
type Mqtt struct {
// contains filtered or unexported fields
}
Mqtt provider
func (Mqtt) BoolGetter ¶
BoolGetter parses bool from exec result. "on", "true" and 1 are considered truish.
func (*Mqtt) BoolSetter ¶
BoolSetter invokes script with parameter replaced by bool value
func (Mqtt) FloatGetter ¶
FloatGetter parses float from exec result
func (*Mqtt) FloatSetter ¶
FloatSetter publishes topic with parameter replaced by float value
func (*Mqtt) StringGetter ¶
StringGetter creates handler for string from MQTT topic that returns cached value
func (*Mqtt) StringSetter ¶
StringSetter invokes script with parameter replaced by string value
func (*Mqtt) WithPayload ¶
WithPayload adds payload for setters
func (*Mqtt) WithPipeline ¶
WithPipeline adds a processing pipeline
func (*Mqtt) WithRetained ¶
WithRetained adds retained flag for setters
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus provider
func NewPrometheus ¶
func (*Prometheus) FloatGetter ¶
func (p *Prometheus) FloatGetter() (func() (float64, error), error)
FloatGetter expects scalar value from query response as float
type Provider ¶
type Provider interface{}
provider types
func NewCalcFromConfig ¶
NewCalcFromConfig creates calc provider
func NewCombinedFromConfig ¶
NewCombinedFromConfig creates combined provider
func NewConstFromConfig ¶
NewConstFromConfig creates const provider
func NewConvertFromConfig ¶
NewConvertFromConfig creates type conversion provider
func NewErrorFromConfig ¶
NewErrorFromConfig creates error provider
func NewGoProviderFromConfig ¶
NewGoProviderFromConfig creates a Go provider
func NewHTTPProviderFromConfig ¶
NewHTTPProviderFromConfig creates a HTTP provider
func NewIgnoreFromConfig ¶
NewIgnoreFromConfig creates const provider
func NewJavascriptProviderFromConfig ¶
func NewJavascriptProviderFromConfig(ctx context.Context, other map[string]interface{}) (Provider, error)
NewJavascriptProviderFromConfig creates a Javascript provider
func NewMapFromConfig ¶
NewMapFromConfig creates type conversion provider
func NewModbusFromConfig ¶
NewModbusFromConfig creates Modbus plugin
func NewModbusSunspecFromConfig ¶
NewModbusSunspecFromConfig creates Modbus plugin
func NewMqttFromConfig ¶
NewMqttFromConfig creates Mqtt provider
func NewPrometheusFromConfig ¶
func NewRandomFromConfig ¶
NewRandomFromConfig creates random provider
func NewSMAFromConfig ¶
NewSMAFromConfig creates SMA provider
func NewScriptProviderFromConfig ¶
NewScriptProviderFromConfig creates a script provider.
func NewSequenceFromConfig ¶
NewSequenceFromConfig creates sequence provider
func NewSocketProviderFromConfig ¶
NewSocketProviderFromConfig creates a HTTP provider
func NewSwitchFromConfig ¶
NewSwitchFromConfig creates switch provider
type SMA ¶
type SMA struct {
// contains filtered or unexported fields
}
SMA provider
func (*SMA) FloatGetter ¶
FloatGetter creates handler for float64
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script implements shell script-based providers and setters
func NewScriptProvider ¶
func NewScriptProvider(script string, timeout time.Duration, scale float64, cache time.Duration) (*Script, error)
NewScriptProvider creates a script provider. Script execution is aborted after given timeout.
func (Script) BoolGetter ¶
BoolGetter parses bool from exec result. "on", "true" and 1 are considered truish.
func (*Script) BoolSetter ¶
BoolSetter invokes script with parameter replaced by bool value
func (Script) FloatGetter ¶
FloatGetter parses float from exec result
func (*Script) StringGetter ¶
StringGetter returns string from exec result. Only STDOUT is considered.
type SetBoolProvider ¶
provider types
type SetBytesProvider ¶
provider types
type SetFloatProvider ¶
provider types
type SetIntProvider ¶
provider types
type SetStringProvider ¶
provider types
type Socket ¶
Socket implements websocket request provider
func (Socket) BoolGetter ¶
BoolGetter parses bool from exec result. "on", "true" and 1 are considered truish.
func (Socket) FloatGetter ¶
FloatGetter parses float from exec result
type StringProvider ¶
provider types
type TimeoutHandler ¶
type TimeoutHandler struct {
// contains filtered or unexported fields
}
TimeoutHandler is a wrapper for a Getter that times out after a given duration
func NewTimeoutHandler ¶
func NewTimeoutHandler(ticker func() (string, error)) *TimeoutHandler
func (*TimeoutHandler) BoolGetter ¶
func (h *TimeoutHandler) BoolGetter(p BoolProvider) (func() (bool, error), error)
func (*TimeoutHandler) FloatGetter ¶
func (h *TimeoutHandler) FloatGetter(p FloatProvider) (func() (float64, error), error)
func (*TimeoutHandler) JsonGetter ¶
func (h *TimeoutHandler) JsonGetter(p StringProvider) (func(any) error, error)
func (*TimeoutHandler) StringGetter ¶
func (h *TimeoutHandler) StringGetter(p StringProvider) (func() (string, error), error)
Source Files ¶
- cache.go
- calc.go
- combined.go
- config.go
- const.go
- convert.go
- error.go
- getter.go
- go.go
- helper.go
- http.go
- ignore.go
- javascript.go
- map.go
- modbus.go
- mqtt.go
- mqtt_handler.go
- mqtt_timeout.go
- prometheus.go
- random.go
- script.go
- sequence.go
- sma.go
- socket.go
- sunspec.go
- sunspec_cache.go
- switch.go
- transformation.go
- watchdog.go