func NewConfigurableFromConfig(other map[string]interface{}) (api.Meter, error) {
	cc := struct {
		Power    provider.Config
		Energy   *provider.Config  // optional
		SoC      *provider.Config  // optional
		Currents []provider.Config // optional
	}{}

	if err := util.DecodeOther(other, &cc); err != nil {
		return nil, err
	}

	for k, v := range map[string]string{"power": cc.Power.PluginType()} {
		if v == "" {
			return nil, fmt.Errorf("missing plugin configuration: %s", k)
		}
	}

	power, err := provider.NewFloatGetterFromConfig(cc.Power)
	if err != nil {
		return nil, fmt.Errorf("power: %w", err)
	}

	m, _ := NewConfigurable(power)

	// decorate Meter with MeterEnergy
	if cc.Energy != nil {
		m.totalEnergyG, err = provider.NewFloatGetterFromConfig(*cc.Energy)
		if err != nil {
			return nil, fmt.Errorf("energy: %w", err)
		}
	}

	// decorate Meter with MeterCurrent
	if len(cc.Currents) > 0 {
		if len(cc.Currents) != 3 {
			return nil, errors.New("need 3 currents")
		}

		for idx, cc := range cc.Currents {
			c, err := provider.NewFloatGetterFromConfig(cc)
			if err != nil {
				return nil, fmt.Errorf("currents[%d]: %w", idx, err)
			}

			m.currentsG = append(m.currentsG, c)
		}
	}

	// decorate Meter with BatterySoC
	if cc.SoC != nil {
		m.batterySoCG, err = provider.NewFloatGetterFromConfig(*cc.SoC)
		if err != nil {
			return nil, fmt.Errorf("battery: %w", err)
		}
	}

	res := m.Decorate(m.totalEnergyG, m.currentsG, m.batterySoCG)

	return res, nil
}
// NewConfigurableFromConfig creates api.Meter from config
NewConfigurableFromConfig creates api.Meter from config
// NewConfigurableFromConfig creates api . Meter from config
func NewConfigurableFromConfig(other map[string]interface{}) (api.Meter, error) {
	cc := struct {
		Power    provider.Config
		Energy   *provider.Config  
		SoC      *provider.Config  
		Currents []provider.Config 
	}{}
	if err := util.DecodeOther(other, &cc); err != nil {
		return nil, err
	}
	for k, v := range map[string]string{"power": cc.Power.PluginType()} {
		if v == "" {
			return nil, fmt.Errorf("missing plugin configuration: %s", k)
		}
	}
	power, err := provider.NewFloatGetterFromConfig(cc.Power)
	if err != nil {
		return nil, fmt.Errorf("power: %w", err)
	}
	m, _ := NewConfigurable(power)
	if cc.Energy != nil {
		m.totalEnergyG, err = provider.NewFloatGetterFromConfig(*cc.Energy)
		if err != nil {
			return nil, fmt.Errorf("energy: %w", err)
		}
	}
	if len(cc.Currents) > 0 {
		if len(cc.Currents) != 3 {
			return nil, errors.New("need 3 currents")
		}
		for idx, cc := range cc.Currents {
			c, err := provider.NewFloatGetterFromConfig(cc)
			if err != nil {
				return nil, fmt.Errorf("currents[%d]: %w", idx, err)
			}
			m.currentsG = append(m.currentsG, c)
		}
	}
	if cc.SoC != nil {
		m.batterySoCG, err = provider.NewFloatGetterFromConfig(*cc.SoC)
		if err != nil {
			return nil, fmt.Errorf("battery: %w", err)
		}
	}
	res := m.Decorate(m.totalEnergyG, m.currentsG, m.batterySoCG)
	return res, nil
}
func NewConfigurableFromConfig ( other map [ string ] interface { } ) ( api . Meter , error ) { cc := struct { Power provider . Config Energy * provider . Config SoC * provider . Config Currents [ ] provider . Config } { } if err := util . DecodeOther ( other , & cc ) ; err != nil { return nil , err } for k , v := range map [ string ] string { " " : cc . Power . PluginType ( ) } { if v == " " { return nil , fmt . Errorf ( " " , k ) } } power , err := provider . NewFloatGetterFromConfig ( cc . Power ) if err != nil { return nil , fmt . Errorf ( " " , err ) } m , _ := NewConfigurable ( power ) if cc . Energy != nil { m . totalEnergyG , err = provider . NewFloatGetterFromConfig ( * cc . Energy ) if err != nil { return nil , fmt . Errorf ( " " , err ) } } if len ( cc . Currents ) > 0 { if len ( cc . Currents ) != 3 { return nil , errors . New ( " " ) } for idx , cc := range cc . Currents { c , err := provider . NewFloatGetterFromConfig ( cc ) if err != nil { return nil , fmt . Errorf ( " " , idx , err ) } m . currentsG = append ( m . currentsG , c ) } } if cc . SoC != nil { m . batterySoCG , err = provider . NewFloatGetterFromConfig ( * cc . SoC ) if err != nil { return nil , fmt . Errorf ( " " , err ) } } res := m . Decorate ( m . totalEnergyG , m . currentsG , m . batterySoCG ) return res , nil }
NewConfigurableFromConfig creates api.Meter from config
NewConfigurableFromConfig creates api . Meter from config
// optional // optional // optional // decorate Meter with MeterEnergy // decorate Meter with MeterCurrent // decorate Meter with BatterySoC