Revert "Loadpoint: add solar share setting (experimental)"
This reverts commit 42eb940fe8.
This commit is contained in:
parent
42eb940fe8
commit
f65c7e6540
6 changed files with 5 additions and 68 deletions
|
|
@ -34,7 +34,6 @@ const (
|
|||
SmartCostActive = "smartCostActive" // smart cost active
|
||||
SmartCostLimit = "smartCostLimit" // smart cost limit
|
||||
SmartCostNextStart = "smartCostNextStart" // smart cost next start
|
||||
SolarShare = "solarShare" // solar share
|
||||
|
||||
// effective values
|
||||
EffectivePriority = "effectivePriority" // effective priority
|
||||
|
|
|
|||
|
|
@ -127,7 +127,6 @@ type Loadpoint struct {
|
|||
limitSoc int // Session limit for soc
|
||||
limitEnergy float64 // Session limit for energy
|
||||
smartCostLimit *float64 // always charge if cost is below this value
|
||||
solarShare float64 // solar share for pv mode
|
||||
|
||||
mode api.ChargeMode
|
||||
enabled bool // Charger enabled state
|
||||
|
|
@ -1309,13 +1308,9 @@ func (lp *Loadpoint) pvMaxCurrent(mode api.ChargeMode, sitePower float64, batter
|
|||
// notes: activePhases can be 1, 2 or 3 and phaseTimer can only be active if lp current is already at minCurrent
|
||||
projectedSitePower -= Voltage * minCurrent * float64(activePhases-1)
|
||||
}
|
||||
|
||||
// lp.Disable.Threshold
|
||||
disableThreshold := (lp.GetSolarShare() - 1) * lp.EffectiveMinPower()
|
||||
|
||||
// kick off disable sequence
|
||||
if projectedSitePower >= disableThreshold {
|
||||
lp.log.DEBUG.Printf("projected site power %.0fW >= %.0fW disable threshold", projectedSitePower, disableThreshold)
|
||||
if projectedSitePower >= lp.Disable.Threshold {
|
||||
lp.log.DEBUG.Printf("projected site power %.0fW >= %.0fW disable threshold", projectedSitePower, lp.Disable.Threshold)
|
||||
|
||||
if lp.pvTimer.IsZero() {
|
||||
lp.log.DEBUG.Printf("pv disable timer start: %v", lp.GetDisableDelay())
|
||||
|
|
@ -1344,12 +1339,10 @@ func (lp *Loadpoint) pvMaxCurrent(mode api.ChargeMode, sitePower float64, batter
|
|||
}
|
||||
|
||||
if mode == api.ModePV && !lp.enabled {
|
||||
// lp.Enable.Threshold
|
||||
enableThreshold := -lp.GetSolarShare() * lp.EffectiveMinPower()
|
||||
|
||||
// kick off enable sequence
|
||||
if sitePower <= enableThreshold {
|
||||
lp.log.DEBUG.Printf("site power %.0fW <= %.0fW enable threshold", sitePower, enableThreshold)
|
||||
if (lp.Enable.Threshold == 0 && targetCurrent >= minCurrent) ||
|
||||
(lp.Enable.Threshold != 0 && sitePower <= lp.Enable.Threshold) {
|
||||
lp.log.DEBUG.Printf("site power %.0fW <= %.0fW enable threshold", sitePower, lp.Enable.Threshold)
|
||||
|
||||
if lp.pvTimer.IsZero() {
|
||||
lp.log.DEBUG.Printf("pv enable timer start: %v", lp.GetEnableDelay())
|
||||
|
|
|
|||
|
|
@ -123,9 +123,6 @@ type API interface {
|
|||
// SetSmartCostLimit sets the smart cost limit
|
||||
SetSmartCostLimit(limit *float64)
|
||||
|
||||
SetSolarShare(float64)
|
||||
GetSolarShare() float64
|
||||
|
||||
//
|
||||
// power and energy
|
||||
//
|
||||
|
|
|
|||
|
|
@ -555,28 +555,6 @@ func (lp *Loadpoint) SetSmartCostLimit(val *float64) {
|
|||
}
|
||||
}
|
||||
|
||||
// GetSolarShare gets the solar share
|
||||
func (lp *Loadpoint) GetSolarShare() float64 {
|
||||
lp.RLock()
|
||||
defer lp.RUnlock()
|
||||
return lp.solarShare
|
||||
}
|
||||
|
||||
// SetSolarShare sets the solar share
|
||||
func (lp *Loadpoint) SetSolarShare(val float64) {
|
||||
lp.Lock()
|
||||
defer lp.Unlock()
|
||||
|
||||
lp.log.DEBUG.Println("set solar share:", "%.0f", 100*val)
|
||||
|
||||
if lp.solarShare != val {
|
||||
lp.solarShare = val
|
||||
|
||||
lp.settings.SetFloat(keys.SolarShare, val)
|
||||
lp.publish(keys.SolarShare, val)
|
||||
}
|
||||
}
|
||||
|
||||
// GetCircuit returns the assigned circuit
|
||||
func (lp *Loadpoint) GetCircuit() api.Circuit {
|
||||
lp.RLock()
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ func (s *HTTPd) RegisterSiteHandlers(site site.API, valueChan chan<- util.Param)
|
|||
"residualpower": {"POST", "/residualpower/{value:-?[0-9.]+}", floatHandler(site.SetResidualPower, site.GetResidualPower)},
|
||||
"smartcost": {"POST", "/smartcostlimit/{value:-?[0-9.]+}", updateSmartCostLimit(site)},
|
||||
"smartcostdelete": {"DELETE", "/smartcostlimit", updateSmartCostLimit(site)},
|
||||
"solar": {"POST", "/solarshare/{value:[0-9]+}", updateSolarShare(site)},
|
||||
"tariff": {"GET", "/tariff/{tariff:[a-z]+}", tariffHandler(site)},
|
||||
"sessions": {"GET", "/sessions", sessionHandler},
|
||||
"updatesession": {"PUT", "/session/{id:[0-9]+}", updateSessionHandler},
|
||||
|
|
@ -182,7 +181,6 @@ func (s *HTTPd) RegisterSiteHandlers(site site.API, valueChan chan<- util.Param)
|
|||
"smartCost": {"POST", "/smartcostlimit/{value:-?[0-9.]+}", floatPtrHandler(pass(lp.SetSmartCostLimit), lp.GetSmartCostLimit)},
|
||||
"smartCostDelete": {"DELETE", "/smartcostlimit", floatPtrHandler(pass(lp.SetSmartCostLimit), lp.GetSmartCostLimit)},
|
||||
// "priority": {"POST", "/priority/{value:[0-9.]+}", floatHandler(pass(lp.SetPriority), lp.GetPriority)},
|
||||
"solar": {"POST", "/solarshare/{value:[0-9]+}", scaledIntHandler(pass(lp.SetSolarShare), lp.GetSolarShare, 100)},
|
||||
}
|
||||
|
||||
for _, r := range routes {
|
||||
|
|
|
|||
|
|
@ -150,15 +150,6 @@ func intHandler(set func(int) error, get func() int) http.HandlerFunc {
|
|||
return handler(strconv.Atoi, set, get)
|
||||
}
|
||||
|
||||
// scaledIntHandler updates int-param api
|
||||
func scaledIntHandler(set func(float64) error, get func() float64, scale float64) http.HandlerFunc {
|
||||
return intHandler(func(v int) error {
|
||||
return set(float64(v) / scale)
|
||||
}, func() int {
|
||||
return int(get() * scale)
|
||||
})
|
||||
}
|
||||
|
||||
// boolHandler updates bool-param api
|
||||
func boolHandler(set func(bool) error, get func() bool) http.HandlerFunc {
|
||||
return handler(strconv.ParseBool, set, get)
|
||||
|
|
@ -200,25 +191,6 @@ func updateSmartCostLimit(site site.API) http.HandlerFunc {
|
|||
}
|
||||
}
|
||||
|
||||
// updateSolarShare sets the solar share limit globally
|
||||
func updateSolarShare(site site.API) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
|
||||
val, err := strconv.Atoi(vars["value"])
|
||||
if err != nil {
|
||||
jsonError(w, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, lp := range site.Loadpoints() {
|
||||
lp.SetSolarShare(float64(val) / 100)
|
||||
}
|
||||
|
||||
jsonResult(w, val)
|
||||
}
|
||||
}
|
||||
|
||||
// stateHandler returns the combined state
|
||||
func stateHandler(cache *util.Cache) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue