SetPlanEnergy sets plan target energy
(finishAt time.Time, energy float64)
| 386 | |
| 387 | // SetPlanEnergy sets plan target energy |
| 388 | func (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) |
| 408 | func (lp *Loadpoint) setPlanStrategy(strategy api.PlanStrategy) error { |
nothing calls this directly
no test coverage detected