Skip to content

Commit

Permalink
Config: remove more ui-enabled settings (#10982)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Dec 10, 2023
1 parent 1a28912 commit 3e1dcd3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 30 deletions.
20 changes: 11 additions & 9 deletions core/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,21 @@ type Site struct {
ResidualPower float64 `mapstructure:"residualPower"` // PV meter only: household usage. Grid meter: household safety margin
Meters MetersConfig // Meter references
MaxGridSupplyWhileBatteryCharging float64 `mapstructure:"maxGridSupplyWhileBatteryCharging"` // ignore battery charging if AC consumption is above this value
SmartCostLimit float64 `mapstructure:"smartCostLimit"` // always charge if cost is below this value
BatteryDischargeControl bool `mapstructure:"batteryDischargeControl"` // prevent battery discharge for fast and planned charging

// meters
gridMeter api.Meter // Grid usage meter
pvMeters []api.Meter // PV generation meters
batteryMeters []api.Meter // Battery charging meters
auxMeters []api.Meter // Auxiliary meters

// cost settings
smartCostLimit float64 // always charge if cost is below this value

// battery settings
prioritySoc float64 // prefer battery up to this Soc
bufferSoc float64 // continue charging on battery above this Soc
bufferStartSoc float64 // start charging on battery above this Soc
prioritySoc float64 // prefer battery up to this Soc
bufferSoc float64 // continue charging on battery above this Soc
bufferStartSoc float64 // start charging on battery above this Soc
batteryDischargeControl bool // prevent battery discharge for fast and planned charging

tariffs tariff.Tariffs // Tariff
loadpoints []*Loadpoint // Loadpoints
Expand Down Expand Up @@ -247,7 +249,7 @@ func (site *Site) restoreSettings() error {
}
}
if v, err := settings.Bool(keys.BatteryDischargeControl); err == nil {
site.BatteryDischargeControl = v
site.batteryDischargeControl = v
}
return nil
}
Expand Down Expand Up @@ -796,7 +798,7 @@ func (site *Site) update(lp Updater) {
site.log.ERROR.Println(err)
}

if batMode := site.GetBatteryMode(); site.BatteryDischargeControl {
if batMode := site.GetBatteryMode(); site.batteryDischargeControl {
if mode := site.determineBatteryMode(site.Loadpoints()); mode != batMode {
if err := site.updateBatteryMode(mode); err != nil {
site.log.ERROR.Println("battery mode:", err)
Expand All @@ -818,15 +820,15 @@ func (site *Site) prepare() {
site.publish(keys.BufferStartSoc, site.bufferStartSoc)
site.publish(keys.PrioritySoc, site.prioritySoc)
site.publish(keys.ResidualPower, site.ResidualPower)
site.publish(keys.SmartCostLimit, site.SmartCostLimit)
site.publish(keys.SmartCostLimit, site.smartCostLimit)
site.publish(keys.SmartCostType, nil)
site.publish(keys.SmartCostActive, false)
if tariff := site.GetTariff(PlannerTariff); tariff != nil {
site.publish(keys.SmartCostType, tariff.Type().String())
}
site.publish(keys.Currency, site.tariffs.Currency.String())

site.publish(keys.BatteryDischargeControl, site.BatteryDischargeControl)
site.publish(keys.BatteryDischargeControl, site.batteryDischargeControl)
site.publish(keys.BatteryMode, site.batteryMode.String())

if err := site.restoreSettings(); err != nil {
Expand Down
18 changes: 9 additions & 9 deletions core/site_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,24 @@ func (site *Site) SetResidualPower(power float64) error {
return nil
}

// GetSmartCostLimit returns the SmartCostLimit
// GetSmartCostLimit returns the smartCostLimit
func (site *Site) GetSmartCostLimit() float64 {
site.RLock()
defer site.RUnlock()
return site.SmartCostLimit
return site.smartCostLimit
}

// SetSmartCostLimit sets the SmartCostLimit
// SetSmartCostLimit sets the smartCostLimit
func (site *Site) SetSmartCostLimit(val float64) error {
site.Lock()
defer site.Unlock()

site.log.DEBUG.Println("set smart cost limit:", val)

if site.SmartCostLimit != val {
site.SmartCostLimit = val
settings.SetFloat(keys.SmartCostLimit, site.SmartCostLimit)
site.publish(keys.SmartCostLimit, site.SmartCostLimit)
if site.smartCostLimit != val {
site.smartCostLimit = val
settings.SetFloat(keys.SmartCostLimit, site.smartCostLimit)
site.publish(keys.SmartCostLimit, site.smartCostLimit)
}

return nil
Expand Down Expand Up @@ -216,7 +216,7 @@ func (site *Site) GetTariff(tariff string) api.Tariff {
func (site *Site) GetBatteryDischargeControl() bool {
site.Lock()
defer site.Unlock()
return site.BatteryDischargeControl
return site.batteryDischargeControl
}

// SetBatteryControl sets the battery control mode
Expand All @@ -234,7 +234,7 @@ func (site *Site) SetBatteryDischargeControl(val bool) error {
site.Lock()
defer site.Unlock()

site.BatteryDischargeControl = val
site.batteryDischargeControl = val
settings.SetBool(keys.BatteryDischargeControl, val)
site.publish(keys.BatteryDischargeControl, val)
}
Expand Down
8 changes: 1 addition & 7 deletions evcc.dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,14 @@ site:
aux:
- aux # list of auxiliary meters for adjusting grid operating point
residualPower: 0 # additional household usage margin
prioritySoc: 0 # give home battery priority up to this soc (empty to disable)
bufferSoc: 0 # continue charging on battery above soc (0 to disable)
bufferStartSoc: 0 # start charging on battery above soc (0 to disable)
maxGridSupplyWhileBatteryCharging: 0 # ignore battery charging if AC consumption is above this value
smartCostLimit: 0 # set cost limit for automatic charging in PV mode

# loadpoint describes the charger, charge meter and connected vehicle
loadpoints:
- title: Garage # display name for UI
charger: wallbe # charger
meter: charge # charge meter
mode: "off" # set default charge mode, use "off" to disable by default if charger is publicly available
# vehicle: car1 # set default vehicle (disables vehicle detection)
resetOnDisconnect: true # set defaults when vehicle disconnects
mode: "off" # default charge mode to apply when vehicle is disconnected; use "off" to disable by default if charger is publicly available
phases: 3 # electrical connection (normal charger: default 3 for 3 phase, 1p3p charger: 0 for "auto" or 1/3 for fixed phases)
minCurrent: 6 # minimum charge current (default 6A)
maxCurrent: 16 # maximum charge current (default 16A)
Expand Down
15 changes: 10 additions & 5 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,16 @@
"minItems": 1,
"uniqueItems": true
},
"smart": {
"type": "string"
"aux": {
"description": "Auxiliary meters (0 or more)",
"type": [
"string",
"array"
],
"items": {
"type": "string"
},
"uniqueItems": true
}
}
},
Expand All @@ -208,9 +216,6 @@
"mode": {
"$ref": "#/definitions/mode"
},
"resetOnDisconnect": {
"type": "boolean"
},
"charger": {
"type": "string"
},
Expand Down

0 comments on commit 3e1dcd3

Please sign in to comment.