Documentation ¶
Index ¶
- func Cached[T any](g func() (T, error), cache time.Duration) func() (T, error)
- func NewBoolGetterFromConfig(config Config) (func() (bool, error), error)
- func NewBoolSetterFromConfig(param string, config Config) (func(bool) error, error)
- func NewFloatGetterFromConfig(config Config) (func() (float64, error), error)
- func NewFloatSetterFromConfig(param string, config Config) (func(float642 float64) error, error)
- func NewIntGetterFromConfig(config Config) (func() (int64, error), error)
- func NewIntSetterFromConfig(param string, config Config) (func(int64) error, error)
- func NewOpenWBStatusProviderFromConfig(other map[string]interface{}) (func() (string, error), error)
- func NewStringGetterFromConfig(config Config) (func() (string, error), error)
- func NewStringSetterFromConfig(param string, config Config) (func(string) error, error)
- func ResetCached()
- func ResettableCached[T any](g func() (T, error), cache time.Duration) *cached[T]
- func UintFromBytes(bytes []byte) (u uint64, err error)
- type Auth
- type BoolProvider
- type Cacheable
- type Config
- type FloatProvider
- type Go
- func (p *Go) BoolGetter() func() (bool, error)
- func (p *Go) BoolSetter(param string) func(bool) error
- func (p *Go) FloatGetter() func() (float64, error)
- func (p *Go) FloatSetter(param string) func(float64) error
- func (p *Go) IntGetter() func() (int64, error)
- func (p *Go) IntSetter(param string) func(int64) error
- func (p *Go) StringGetter() func() (string, error)
- func (p *Go) StringSetter(param string) func(string) error
- type HTTP
- func (p *HTTP) BoolGetter() func() (bool, error)
- func (p *HTTP) BoolSetter(param string) func(bool) error
- func (p *HTTP) FloatGetter() func() (float64, error)
- func (p *HTTP) FloatSetter(param string) func(float64) error
- func (p *HTTP) IntGetter() func() (int64, error)
- func (p *HTTP) IntSetter(param string) func(int64) error
- func (p *HTTP) StringGetter() func() (string, error)
- func (p *HTTP) StringSetter(param string) func(string) 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)
- func (p *Javascript) BoolSetter(param string) func(bool) error
- func (p *Javascript) FloatGetter() func() (float64, error)
- func (p *Javascript) FloatSetter(param string) func(float64) error
- func (p *Javascript) IntGetter() func() (int64, error)
- func (p *Javascript) IntSetter(param string) func(int64) error
- func (p *Javascript) StringGetter() func() (string, error)
- func (p *Javascript) StringSetter(param string) func(string) error
- type Modbus
- func (m *Modbus) BoolGetter() func() (bool, error)
- func (m *Modbus) BoolSetter(param string) func(bool) error
- func (m *Modbus) FloatGetter() func() (f float64, err error)
- func (m *Modbus) IntGetter() func() (int64, error)
- func (m *Modbus) IntSetter(param string) func(int64) error
- func (m *Modbus) StringGetter() func() (string, error)
- type Mqtt
- func (m *Mqtt) BoolGetter() func() (bool, error)
- func (m *Mqtt) BoolSetter(param string) func(bool) error
- func (m *Mqtt) FloatGetter() func() (float64, error)
- func (m *Mqtt) IntGetter() func() (int64, error)
- func (m *Mqtt) IntSetter(param string) func(int64) error
- func (m *Mqtt) StringGetter() func() (string, error)
- func (m *Mqtt) StringSetter(param string) func(string) 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 OpenWBStatus
- type Prometheus
- type Provider
- func NewCalcFromConfig(other map[string]interface{}) (Provider, error)
- func NewCombinedFromConfig(other map[string]interface{}) (Provider, error)
- func NewConstFromConfig(other map[string]interface{}) (Provider, error)
- func NewGoProviderFromConfig(other map[string]interface{}) (Provider, error)
- func NewHTTPProviderFromConfig(other map[string]interface{}) (Provider, error)
- func NewJavascriptProviderFromConfig(other map[string]interface{}) (Provider, error)
- func NewModbusFromConfig(other map[string]interface{}) (Provider, error)
- func NewMqttFromConfig(other map[string]interface{}) (Provider, error)
- func NewPrometheusFromConfig(other map[string]interface{}) (Provider, error)
- func NewSMAFromConfig(other map[string]interface{}) (Provider, error)
- func NewScriptProviderFromConfig(other map[string]interface{}) (Provider, error)
- func NewSocketProviderFromConfig(other map[string]interface{}) (Provider, error)
- type SMA
- type Script
- func (p *Script) BoolGetter() func() (bool, error)
- func (p *Script) BoolSetter(param string) func(bool) error
- func (p *Script) FloatGetter() func() (float64, error)
- func (p *Script) IntGetter() func() (int64, error)
- func (p *Script) IntSetter(param string) func(int64) error
- func (p *Script) StringGetter() func() (string, error)
- func (p *Script) WithJq(jq string) (*Script, error)
- func (p *Script) WithRegex(regex string) (*Script, error)
- type SetBoolProvider
- type SetFloatProvider
- type SetIntProvider
- type SetStringProvider
- type Socket
- type StringProvider
- type TimeoutHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBoolGetterFromConfig ¶
NewBoolGetterFromConfig creates a BoolGetter from config
func NewBoolSetterFromConfig ¶
NewBoolSetterFromConfig creates a BoolSetter from config
func NewFloatGetterFromConfig ¶
NewFloatGetterFromConfig creates a FloatGetter from config
func NewFloatSetterFromConfig ¶
NewFloatSetterFromConfig creates a FloatSetter from config
func NewIntGetterFromConfig ¶
NewIntGetterFromConfig creates a IntGetter from config
func NewIntSetterFromConfig ¶
NewIntSetterFromConfig creates a IntSetter from config
func NewOpenWBStatusProviderFromConfig ¶
func NewOpenWBStatusProviderFromConfig(other map[string]interface{}) (func() (string, error), error)
NewOpenWBStatusProviderFromConfig creates OpenWBStatus from given configuration
func NewStringGetterFromConfig ¶
NewStringGetterFromConfig creates a StringGetter from config
func NewStringSetterFromConfig ¶
NewStringSetterFromConfig creates a StringSetter from config
func ResetCached ¶
func ResetCached()
func ResettableCached ¶
ResettableCached wraps a getter with a cache. It returns a `Cacheable`. Instead of the cached getter, the `Get()` and `Reset()` methods are exposed.
func UintFromBytes ¶
UintFromBytes converts byte slice to bigendian uint value
Types ¶
type BoolProvider ¶
provider types
type FloatProvider ¶
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 NewHTTP ¶
func NewHTTP(log *util.Logger, method, uri string, insecure bool, scale float64, cache time.Duration) *HTTP
NewHTTP create HTTP provider
func (*HTTP) BoolGetter ¶
BoolGetter parses bool from request
func (*HTTP) BoolSetter ¶
BoolSetter sends bool request
func (*HTTP) FloatGetter ¶
FloatGetter parses float from request
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 Javascript ¶
type Javascript struct {
// contains filtered or unexported fields
}
Javascript implements Javascript request provider
func (*Javascript) BoolGetter ¶
func (p *Javascript) BoolGetter() func() (bool, error)
BoolGetter parses bool from request
func (*Javascript) BoolSetter ¶
func (p *Javascript) BoolSetter(param string) func(bool) error
BoolSetter sends bool request
func (*Javascript) FloatGetter ¶
func (p *Javascript) FloatGetter() func() (float64, error)
FloatGetter parses float from request
func (*Javascript) FloatSetter ¶
func (p *Javascript) FloatSetter(param string) func(float64) error
FloatSetter sends float request
func (*Javascript) IntGetter ¶
func (p *Javascript) IntGetter() func() (int64, error)
IntGetter parses int64 from request
func (*Javascript) IntSetter ¶
func (p *Javascript) IntSetter(param string) func(int64) error
IntSetter sends int request
func (*Javascript) StringGetter ¶
func (p *Javascript) StringGetter() func() (string, error)
StringGetter parses string from request
func (*Javascript) StringSetter ¶
func (p *Javascript) StringSetter(param string) func(string) 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 executes configured modbus read operation and implements IntProvider
func (*Modbus) BoolSetter ¶
BoolSetter executes configured modbus write operation and implements SetBoolProvider
func (*Modbus) FloatGetter ¶
FloatGetter executes configured modbus read operation and implements func() (float64, error)
func (*Modbus) IntGetter ¶
IntGetter executes configured modbus read operation and implements IntProvider
func (*Modbus) IntSetter ¶
IntSetter executes configured modbus write operation and implements SetIntProvider
func (*Modbus) StringGetter ¶
StringGetter executes configured modbus read operation and implements IntProvider
type Mqtt ¶
type Mqtt struct {
// contains filtered or unexported fields
}
Mqtt provider
func (*Mqtt) BoolGetter ¶
BoolGetter creates handler for string from MQTT topic that returns cached value
func (*Mqtt) BoolSetter ¶
BoolSetter invokes script with parameter replaced by bool value
func (*Mqtt) FloatGetter ¶
FloatGetter creates handler for float64 from MQTT topic that returns cached value
func (*Mqtt) IntGetter ¶
IntGetter creates handler for int64 from MQTT topic that returns cached 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 OpenWBStatus ¶
type OpenWBStatus struct {
// contains filtered or unexported fields
}
OpenWBStatus implements status conversion from openWB to api.Status
func NewOpenWBStatusProvider ¶
func NewOpenWBStatusProvider(plugged, charging func() (bool, error)) *OpenWBStatus
NewOpenWBStatusProvider creates provider for OpenWB status converted from MQTT topics
func (*OpenWBStatus) StringGetter ¶
func (o *OpenWBStatus) StringGetter() (string, error)
StringGetter returns string from OpenWB charging/ plugged status
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus provider
func NewPrometheus ¶
func (*Prometheus) FloatGetter ¶
func (p *Prometheus) FloatGetter() func() (float64, error)
FloatGetter expects scalar value from query response as float
func (*Prometheus) IntGetter ¶
func (p *Prometheus) IntGetter() func() (int64, error)
IntGetter expects scalar value from query response as int
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 NewGoProviderFromConfig ¶
NewGoProviderFromConfig creates a Go provider
func NewHTTPProviderFromConfig ¶
NewHTTPProviderFromConfig creates a HTTP provider
func NewJavascriptProviderFromConfig ¶
NewJavascriptProviderFromConfig creates a Javascript provider
func NewModbusFromConfig ¶
NewModbusFromConfig creates Modbus plugin
func NewMqttFromConfig ¶
NewMqttFromConfig creates Mqtt provider
func NewPrometheusFromConfig ¶
func NewSMAFromConfig ¶
NewSMAFromConfig creates SMA provider
func NewScriptProviderFromConfig ¶
NewScriptProviderFromConfig creates a script provider.
func NewSocketProviderFromConfig ¶
NewSocketProviderFromConfig creates a HTTP 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 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 string getter
func (*Socket) FloatGetter ¶
FloatGetter parses float from string getter
func (*Socket) StringGetter ¶
StringGetter sends string request
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(g func() (bool, error)) func() (bool, error)
func (*TimeoutHandler) FloatGetter ¶
func (h *TimeoutHandler) FloatGetter(g func() (float64, error)) func() (float64, error)
func (*TimeoutHandler) StringGetter ¶
func (h *TimeoutHandler) StringGetter(g func() (string, error)) func() (string, error)