MCPcopy Create free account
hub / github.com/evcc-io/evcc / SetPlanEnergy

Method SetPlanEnergy

core/loadpoint_api.go:388–405  ·  view source on GitHub ↗

SetPlanEnergy sets plan target energy

(finishAt time.Time, energy float64)

Source from the content-addressed store, hash-verified

386
387// SetPlanEnergy sets plan target energy
388func (lp *Loadpoint) SetPlanEnergy(finishAt time.Time, energy float64) error {
389 lp.Lock()
390 defer lp.Unlock()
391
392 if !finishAt.IsZero() && finishAt.Before(lp.clock.Now()) {
393 return errors.New("timestamp is in the past")
394 }
395
396 lp.log.DEBUG.Printf("set plan energy: %.3gkWh @ %v", energy, finishAt.Round(time.Second).Local())
397
398 // apply immediately
399 if lp.planEnergy != energy || !lp.planTime.Equal(finishAt) {
400 lp.setPlanEnergy(finishAt, energy)
401 lp.requestUpdate()
402 }
403
404 return nil
405}
406
407// setPlanStrategy sets the plan strategy (no mutex)
408func (lp *Loadpoint) setPlanStrategy(strategy api.PlanStrategy) error {

Callers

nothing calls this directly

Calls 7

LockMethod · 0.95
UnlockMethod · 0.95
setPlanEnergyMethod · 0.95
requestUpdateMethod · 0.95
PrintfMethod · 0.80
NewMethod · 0.65
IsZeroMethod · 0.45

Tested by

no test coverage detected