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

Function planHandler

server/http_loadpoint_handler.go:32–53  ·  view source on GitHub ↗

planHandler returns the current plan

(lp loadpoint.API)

Source from the content-addressed store, hash-verified

30
31// planHandler returns the current plan
32func planHandler(lp loadpoint.API) http.HandlerFunc {
33 return func(w http.ResponseWriter, r *http.Request) {
34 maxPower := lp.EffectiveMaxPower()
35 planTime := lp.EffectivePlanTime()
36 id := lp.EffectivePlanId()
37
38 goal, _ := lp.GetPlanGoal()
39 requiredDuration := lp.GetPlanRequiredDuration(goal, maxPower)
40 strategy := lp.EffectivePlanStrategy()
41 plan := lp.GetPlan(planTime, requiredDuration, strategy.Precondition, strategy.Continuous)
42
43 res := PlanResponse{
44 PlanId: id,
45 PlanTime: planTime,
46 Duration: int64(requiredDuration.Seconds()),
47 Plan: plan,
48 Power: maxPower,
49 }
50
51 jsonWrite(w, res)
52 }
53}
54
55// staticPlanPreviewHandler returns a plan preview for given parameters
56func staticPlanPreviewHandler(lp loadpoint.API) http.HandlerFunc {

Callers 1

RegisterSiteHandlersMethod · 0.85

Calls 8

jsonWriteFunction · 0.70
EffectiveMaxPowerMethod · 0.65
EffectivePlanTimeMethod · 0.65
EffectivePlanIdMethod · 0.65
GetPlanGoalMethod · 0.65
EffectivePlanStrategyMethod · 0.65
GetPlanMethod · 0.65

Tested by

no test coverage detected