diff --git a/meter/e3dc.go b/meter/e3dc.go index e122e9564..45cf414d5 100644 --- a/meter/e3dc.go +++ b/meter/e3dc.go @@ -32,15 +32,15 @@ func init() { func NewE3dcFromConfig(other map[string]interface{}) (api.Meter, error) { cc := struct { - batteryCapacity `mapstructure:",squash"` - batteryMaxACPower `mapstructure:",squash"` - Usage templates.Usage - Uri string - User string - Password string - Key string - DischargeLimit uint32 - Timeout time.Duration + batteryCapacity `mapstructure:",squash"` + pvMaxACPower `mapstructure:",squash"` + Usage templates.Usage + Uri string + User string + Password string + Key string + DischargeLimit uint32 + Timeout time.Duration }{ Timeout: request.Timeout, } @@ -67,7 +67,7 @@ func NewE3dcFromConfig(other map[string]interface{}) (api.Meter, error) { ReceiveTimeout: cc.Timeout, } - return NewE3dc(cfg, cc.Usage, cc.DischargeLimit, cc.batteryCapacity.Decorator(), cc.batteryMaxACPower.Decorator()) + return NewE3dc(cfg, cc.Usage, cc.DischargeLimit, cc.batteryCapacity.Decorator(), cc.pvMaxACPower.Decorator()) } var e3dcOnce sync.Once diff --git a/meter/meter.go b/meter/meter.go index a1e85319a..16b39134a 100644 --- a/meter/meter.go +++ b/meter/meter.go @@ -22,13 +22,15 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{} measurement.Energy `mapstructure:",squash"` // energy optional measurement.Phases `mapstructure:",squash"` // optional + // pv + pvMaxACPower `mapstructure:",squash"` + // battery - batteryCapacity `mapstructure:",squash"` - batteryMaxACPower `mapstructure:",squash"` - batterySocLimits `mapstructure:",squash"` - Soc *plugin.Config // optional - LimitSoc *plugin.Config // optional - BatteryMode *plugin.Config // optional + batteryCapacity `mapstructure:",squash"` + batterySocLimits `mapstructure:",squash"` + Soc *plugin.Config // optional + LimitSoc *plugin.Config // optional + BatteryMode *plugin.Config // optional }{ batterySocLimits: batterySocLimits{ MinSoc: 20, @@ -80,7 +82,7 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{} } } - res := m.Decorate(energyG, currentsG, voltagesG, powersG, socG, cc.batteryCapacity.Decorator(), cc.batteryMaxACPower.Decorator(), batModeS) + res := m.Decorate(energyG, currentsG, voltagesG, powersG, socG, cc.batteryCapacity.Decorator(), cc.pvMaxACPower.Decorator(), batModeS) return res, nil } diff --git a/meter/battery.go b/meter/usage_battery.go similarity index 75% rename from meter/battery.go rename to meter/usage_battery.go index 6774ad94f..2141ed3eb 100644 --- a/meter/battery.go +++ b/meter/usage_battery.go @@ -18,22 +18,6 @@ func (m *batteryCapacity) Decorator() func() float64 { } } -type batteryMaxACPower struct { - MaxACPower float64 -} - -// var _ api.MaxACPowerGetter = (*batteryMaxACPower)(nil) - -// Decorator returns the max AC power decorator -func (m *batteryMaxACPower) Decorator() func() float64 { - if m.MaxACPower == 0 { - return nil - } - return func() float64 { - return m.MaxACPower - } -} - type batterySocLimits struct { MinSoc, MaxSoc float64 } diff --git a/meter/usage_pv.go b/meter/usage_pv.go new file mode 100644 index 000000000..d578927a9 --- /dev/null +++ b/meter/usage_pv.go @@ -0,0 +1,17 @@ +package meter + +type pvMaxACPower struct { + MaxACPower float64 +} + +// var _ api.MaxACPowerGetter = (*pvMaxACPower)(nil) + +// Decorator returns the max AC power decorator +func (m *pvMaxACPower) Decorator() func() float64 { + if m.MaxACPower == 0 { + return nil + } + return func() float64 { + return m.MaxACPower + } +}