diff --git a/assets/js/components/Config/CircuitsModal.vue b/assets/js/components/Config/CircuitsModal.vue index eeaaa07bbd..78ebf26029 100644 --- a/assets/js/components/Config/CircuitsModal.vue +++ b/assets/js/components/Config/CircuitsModal.vue @@ -6,7 +6,6 @@ docs="/docs/features/loadmanagement" :defaultYaml="defaultYaml" endpoint="/config/circuits" - size="md" @changed="$emit('changed')" /> diff --git a/assets/js/components/Config/defaultYaml/circuits.yaml b/assets/js/components/Config/defaultYaml/circuits.yaml index 7538f358a1..6cdbc02ca1 100644 --- a/assets/js/components/Config/defaultYaml/circuits.yaml +++ b/assets/js/components/Config/defaultYaml/circuits.yaml @@ -1,18 +1,18 @@ # - name: main # unique name, used as reference, e.g. as parent in other circuits # title: Main Circuit # used in the UI -# maxCurrent: 63 # 63A main circuit breaker (optional) -# maxPower: 30000 # 30kW (optional) +# maxcurrent: 63 # 63A main circuit breaker (optional) +# maxpower: 30000 # 30kW (optional) # meter: grid # associated meter to monitor the power consumption (optional) # parent: # no parent, this is the root circuit # - name: garage # unique name, used as reference, e.g. to associate loadpoints # title: Garage # used in the UI -# maxCurrent: 24 # allow individual phase use up to 24A -# maxPower: 11000 # limit total power to 11kW +# maxcurrent: 24 # allow individual phase use up to 24A +# maxpower: 11000 # limit total power to 11kW # meter: garage # dedicated meter for the garage # parent: main # parent to the main circuit # - name: carport # unique name, used as reference, e.g. to associate loadpoints # title: Carport # used in the UI -# maxCurrent: 32 # 32A circuit breaker -# maxPower: # no limit, only check current +# maxcurrent: 32 # 32A circuit breaker +# maxpower: # no limit, only check current # meter: # no meter, using data from loadpoints # parent: main # parent to the main circuit diff --git a/cmd/setup.go b/cmd/setup.go index 63a2fcd44e..86e2723392 100644 --- a/cmd/setup.go +++ b/cmd/setup.go @@ -132,8 +132,15 @@ If you know what you're doing, you can run evcc ignoring the service database wi return err } -func configureCircuits(static []config.Named, names ...string) error { - children := slices.Clone(static) +func configureCircuits(conf []config.Named, names ...string) error { + // migrate settings + if settings.Exists(keys.Circuits) { + if err := settings.Yaml(keys.Circuits, new([]map[string]any), &conf); err != nil { + return err + } + } + + children := slices.Clone(conf) // TODO: check for circular references NEXT: @@ -176,52 +183,6 @@ NEXT: return fmt.Errorf("circuit is missing parent: %s", children[0].Name) } - // append devices from database - configurable, err := config.ConfigurationsByClass(templates.Circuit) - if err != nil { - return err - } - - children2 := slices.Clone(configurable) - -NEXT2: - for i, conf := range children2 { - cc := conf.Named() - - if len(names) > 0 && !slices.Contains(names, cc.Name) { - return nil - } - - if parent := cast.ToString(cc.Property("parent")); parent != "" { - if _, err := config.Circuits().ByName(parent); err != nil { - continue - } - } - - log := util.NewLogger("circuit-" + cc.Name) - instance, err := core.NewCircuitFromConfig(log, cc.Other) - if err != nil { - return fmt.Errorf("cannot create circuit '%s': %w", cc.Name, err) - } - - // ensure config has title - if instance.GetTitle() == "" { - //lint:ignore SA1019 as Title is safe on ascii - instance.SetTitle(strings.Title(cc.Name)) - } - - if err := config.Circuits().Add(config.NewConfigurableDevice(conf, instance)); err != nil { - return err - } - - children2 = slices.Delete(children2, i, i+1) - goto NEXT2 - } - - if len(children2) > 0 { - return fmt.Errorf("missing parent circuit: %s", children2[0].Named().Name) - } - var rootFound bool for _, dev := range config.Circuits().Devices() { c := dev.Instance()