evcc-io/meter/tasmota_decorators.go

65 lines
1.8 KiB
Go

package meter
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
import (
"reflect"
"github.com/evcc-io/evcc/api"
)
func decorateTasmota(base *Tasmota, phaseVoltages func() (float64, float64, float64, error), phaseCurrents func() (float64, float64, float64, error), phasePowers func() (float64, float64, float64, error)) api.Meter {
caps := make(map[reflect.Type]any)
if phaseVoltages != nil {
caps[reflect.TypeFor[api.PhaseVoltages]()] = &decorateTasmotaPhaseVoltagesImpl{phaseVoltages: phaseVoltages}
}
if phaseCurrents != nil {
caps[reflect.TypeFor[api.PhaseCurrents]()] = &decorateTasmotaPhaseCurrentsImpl{phaseCurrents: phaseCurrents}
}
if phasePowers != nil {
caps[reflect.TypeFor[api.PhasePowers]()] = &decorateTasmotaPhasePowersImpl{phasePowers: phasePowers}
}
if len(caps) == 0 {
return base
}
return &decorateTasmotaCapable{Tasmota: base, caps: caps}
}
type decorateTasmotaCapable struct {
*Tasmota
caps map[reflect.Type]any
}
func (d *decorateTasmotaCapable) Capability(typ reflect.Type) (any, bool) {
c, ok := d.caps[typ]
return c, ok
}
type decorateTasmotaPhaseCurrentsImpl struct {
phaseCurrents func() (float64, float64, float64, error)
}
func (impl *decorateTasmotaPhaseCurrentsImpl) Currents() (float64, float64, float64, error) {
return impl.phaseCurrents()
}
type decorateTasmotaPhasePowersImpl struct {
phasePowers func() (float64, float64, float64, error)
}
func (impl *decorateTasmotaPhasePowersImpl) Powers() (float64, float64, float64, error) {
return impl.phasePowers()
}
type decorateTasmotaPhaseVoltagesImpl struct {
phaseVoltages func() (float64, float64, float64, error)
}
func (impl *decorateTasmotaPhaseVoltagesImpl) Voltages() (float64, float64, float64, error) {
return impl.phaseVoltages()
}