Fix resetOnDisconnect overriding default vehicle properties (#4551)
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
andig 2022-09-22 21:02:52 +02:00 • committed by GitHub
parent ccaea785fc
commit ab71b6d5c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 5 deletions

View file

@ -57,6 +57,27 @@ type ActionConfig struct {
TargetSoC *int `mapstructure:"targetSoC,omitempty"` // Target SoC
}
// Merge merges all non-nil properties of the additional config into the base config.
// The receiver's config remains immutable.
func (a ActionConfig) Merge(m ActionConfig) ActionConfig {
if m.Mode != nil {
a.Mode = m.Mode
}
if m.MinCurrent != nil {
a.MinCurrent = m.MinCurrent
}
if m.MaxCurrent != nil {
a.MaxCurrent = m.MaxCurrent
}
if m.MinSoC != nil {
a.MinSoC = m.MinSoC
}
if m.TargetSoC != nil {
a.TargetSoC = m.TargetSoC
}
return a
}
// String implements Stringer and returns the ActionConfig as comma-separated key:value string
func (a ActionConfig) String() string {
var s []string