chore: refactor battery controller

This commit is contained in:
andig 2025-02-03 13:52:07 +01:00
parent 4a92b8c81e
commit 5b62e78311
2 changed files with 3 additions and 8 deletions

View file

@ -30,10 +30,3 @@ func (m *battery) LimitController(socG func() (float64, error), limitSocS func(f
}
}
}
// ModeController returns an api.BatteryController decorator
func (m *battery) ModeController(modeS func(int64) error) func(api.BatteryMode) error {
return func(mode api.BatteryMode) error {
return modeS(int64(mode))
}
}

View file

@ -77,7 +77,9 @@ func NewConfigurableFromConfig(ctx context.Context, other map[string]interface{}
return nil, fmt.Errorf("battery mode: %w", err)
}
batModeS = cc.battery.ModeController(modeS)
batModeS = func(mode api.BatteryMode) error {
return modeS(int64(mode))
}
}
res := m.Decorate(energyG, currentsG, voltagesG, powersG, socG, cc.capacity.Decorator(), cc.maxpower.Decorator(), batModeS)