diff --git a/api/actionconfig.go b/api/actionconfig.go index 0e145fde6..16bc86300 100644 --- a/api/actionconfig.go +++ b/api/actionconfig.go @@ -5,32 +5,15 @@ import ( "reflect" "strings" - "dario.cat/mergo" "github.com/fatih/structs" - "github.com/jinzhu/copier" ) // ActionConfig defines an action to take on event type ActionConfig struct { - Mode *ChargeMode `mapstructure:"mode,omitempty"` // Charge Mode - MinCurrent *float64 `mapstructure:"minCurrent,omitempty"` // Minimum Current - MaxCurrent *float64 `mapstructure:"maxCurrent,omitempty"` // Maximum Current - MinSoc_ *int `mapstructure:"minSoc,omitempty"` // Minimum Soc (deprecated) - TargetSoc *int `mapstructure:"targetSoc,omitempty"` // Target Soc - Priority *int `mapstructure:"priority,omitempty"` // Priority -} - -// 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 { - var res ActionConfig - if err := copier.Copy(&res, a); err != nil { - panic(err) - } - if err := mergo.MergeWithOverwrite(&res, m); err != nil { - panic(err) - } - return res + Mode ChargeMode `mapstructure:"mode,omitempty"` // Charge Mode + Priority int `mapstructure:"priority,omitempty"` // Priority + MinCurrent float64 `mapstructure:"minCurrent,omitempty"` // Minimum Current + MaxCurrent float64 `mapstructure:"maxCurrent,omitempty"` // Maximum Current } // String implements Stringer and returns the ActionConfig as comma-separated key:value string @@ -44,3 +27,19 @@ func (a ActionConfig) String() string { } return strings.Join(s, ", ") } + +func (a ActionConfig) GetMode() (ChargeMode, bool) { + return a.Mode, a.Mode != "" +} + +func (a ActionConfig) GetMinCurrent() (float64, bool) { + return a.MinCurrent, a.MinCurrent > 0 +} + +func (a ActionConfig) GetMaxCurrent() (float64, bool) { + return a.MaxCurrent, a.MaxCurrent > 0 +} + +func (a ActionConfig) GetPriority() (int, bool) { + return a.Priority, a.Priority > 0 +} diff --git a/api/actionconfig_test.go b/api/actionconfig_test.go deleted file mode 100644 index e2e401d65..000000000 --- a/api/actionconfig_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package api - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestMerge(t *testing.T) { - pv := ModePV - one := 1 - six := 6.0 - old := ActionConfig{ - Mode: &pv, - Priority: &one, - MinCurrent: &six, - } - - now := ModeNow - two := 2 - new := ActionConfig{ - Mode: &now, - Priority: &two, - } - - dst := old.Merge(new) - - // unmodified - assert.Equal(t, old, ActionConfig{ - Mode: &pv, - Priority: &one, - MinCurrent: &six, - }, "old modified") - - // overwritten - assert.Equal(t, dst, ActionConfig{ - Mode: &now, - MinCurrent: &six, - Priority: &two, - }, "new wrong") -} diff --git a/api/api.go b/api/api.go index 45eeeddfb..8568b12cc 100644 --- a/api/api.go +++ b/api/api.go @@ -124,8 +124,8 @@ type ChargeState interface { Status() (ChargeStatus, error) } -// CurrentLimiter provides settings charging maximum charging current -type CurrentLimiter interface { +// CurrentController provides settings charging maximum charging current +type CurrentController interface { MaxCurrent(current int64) error } @@ -144,7 +144,7 @@ type Charger interface { ChargeState Enabled() (bool, error) Enable(enable bool) error - CurrentLimiter + CurrentController } // ChargerEx provides milli-amp precision charger current control @@ -220,8 +220,14 @@ type VehiclePosition interface { Position() (float64, float64, error) } -// SocLimiter returns the vehicles charge limit +// CurrentLimiter returns the current limits +type CurrentLimiter interface { + GetMinMaxCurrent() (float64, float64, error) +} + +// SocLimiter returns the soc limit type SocLimiter interface { + // TODO rename LimitSoc TargetSoc() (float64, error) } diff --git a/assets/css/app.css b/assets/css/app.css index 043baa7b6..d1fa6fee7 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -369,6 +369,10 @@ small { background-image: url("data:image/svg+xml,"); } +.dark .form-select:disabled { + opacity: 0.5; +} + .dark .table { --bs-table-color: var(--evcc-default-text); --bs-table-border-color: var(--evcc-gray); diff --git a/assets/js/components/ChargingPlan.vue b/assets/js/components/ChargingPlan.vue index b9a3414d6..0bf749414 100644 --- a/assets/js/components/ChargingPlan.vue +++ b/assets/js/components/ChargingPlan.vue @@ -6,17 +6,26 @@ :class="disabled ? 'opacity-25' : 'opacity-100'" data-testid="charging-plan" > -

+
-

+ @@ -33,7 +42,8 @@