Config UI: reset lp smart cost limit (#19892)
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 / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
Michael Geers 2025-03-19 14:18:13 +01:00 • committed by GitHub
parent 49a597a5da
commit e87f4acd8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 7 deletions

View file

@ -801,13 +801,8 @@ func (lp *Loadpoint) SetSmartCostLimit(val *float64) {
if !ptrValueEqual(lp.smartCostLimit, val) {
lp.smartCostLimit = val
if val == nil {
lp.settings.SetString(keys.SmartCostLimit, "")
lp.publish(keys.SmartCostLimit, nil)
} else {
lp.settings.SetFloat(keys.SmartCostLimit, *val)
lp.publish(keys.SmartCostLimit, *val)
}
lp.settings.SetFloatPtr(keys.SmartCostLimit, val)
lp.publish(keys.SmartCostLimit, val)
}
}

View file

@ -56,6 +56,10 @@ func (s *ConfigSettings) SetFloat(key string, val float64) {
s.set(key, val)
}
func (s *ConfigSettings) SetFloatPtr(key string, val *float64) {
s.set(key, val)
}
func (s *ConfigSettings) SetTime(key string, val time.Time) {
s.set(key, val)
}

View file

@ -28,6 +28,14 @@ func (s *dbSettings) SetFloat(key string, val float64) {
db.SetFloat(s.Key+key, val)
}
func (s *dbSettings) SetFloatPtr(key string, val *float64) {
if val == nil {
db.SetString(s.Key+key, "")
} else {
db.SetFloat(s.Key+key, *val)
}
}
func (s *dbSettings) SetTime(key string, val time.Time) {
db.SetTime(s.Key+key, val)
}

View file

@ -6,6 +6,7 @@ type Settings interface {
SetString(key string, val string)
SetInt(key string, val int64)
SetFloat(key string, val float64)
SetFloatPtr(key string, val *float64)
SetTime(key string, val time.Time)
SetJson(key string, val any) error
SetBool(key string, val bool)