// NewWarpFromConfig creates a new configurable charger
NewWarpFromConfig creates a new configurable charger
// NewWarpFromConfig creates a new configurable charger
func NewWarpFromConfig(other map[string]interface{}) (api.Charger, error) {
	cc := struct {
		mqtt.Config `mapstructure:",squash"`
		Topic       string
		Timeout     time.Duration
		UseMeter    interface{}
	}{
		Topic:   warp.RootTopic,
		Timeout: warp.Timeout,
	}
	if err := util.DecodeOther(other, &cc); err != nil {
		return nil, err
	}
	wb, err := NewWarp(cc.Config, cc.Topic, cc.Timeout)
	if err != nil {
		return nil, err
	}
	if cc.UseMeter != nil {
		util.NewLogger("warp").WARN.Println("usemeter is deprecated and will be removed in a future release")
	}
	isPro := wb.isPro()
	var currentPower func() (float64, error)
	var totalEnergy func() (float64, error)
	if isPro || wb.hasMeter() {
		currentPower = wb.currentPower
		totalEnergy = wb.totalEnergy
	}
	var currents func() (float64, float64, float64, error)
	if isPro {
		currents = wb.currents
	}
	return decorateWarp(wb, currentPower, totalEnergy, currents), err
}
func NewWarpFromConfig ( other map [ string ] interface { } ) ( api . Charger , error ) { cc := struct { mqtt . Config `mapstructure:",squash"` Topic string Timeout time . Duration UseMeter interface { } } { Topic : warp . RootTopic , Timeout : warp . Timeout , } if err := util . DecodeOther ( other , & cc ) ; err != nil { return nil , err } wb , err := NewWarp ( cc . Config , cc . Topic , cc . Timeout ) if err != nil { return nil , err } if cc . UseMeter != nil { util . NewLogger ( " " ) . WARN . Println ( " " ) } isPro := wb . isPro ( ) var currentPower func ( ) ( float64 , error ) var totalEnergy func ( ) ( float64 , error ) if isPro || wb . hasMeter ( ) { currentPower = wb . currentPower totalEnergy = wb . totalEnergy } var currents func ( ) ( float64 , float64 , float64 , error ) if isPro { currents = wb . currents } return decorateWarp ( wb , currentPower , totalEnergy , currents ) , err }
NewWarpFromConfig creates a new configurable charger
NewWarpFromConfig creates a new configurable charger
// TODO remove