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

Method SetMode

core/loadpoint_api.go:160–190  ·  view source on GitHub ↗

SetMode sets loadpoint charge mode

(mode api.ChargeMode)

Source from the content-addressed store, hash-verified

158
159// SetMode sets loadpoint charge mode
160func (lp *Loadpoint) SetMode(mode api.ChargeMode) {
161 lp.Lock()
162 defer lp.Unlock()
163
164 if _, err := api.ChargeModeString(mode.String()); err != nil {
165 lp.log.ERROR.Printf("invalid charge mode: %s", string(mode))
166 return
167 }
168
169 lp.log.DEBUG.Printf("set charge mode: %s", string(mode))
170
171 // apply immediately
172 if lp.mode != mode {
173 lp.setMode(mode)
174
175 lp.batteryBoost = boostDisabled
176 lp.publish(keys.BatteryBoost, false)
177
178 // reset timers
179 switch mode {
180 case api.ModeNow, api.ModeOff:
181 lp.resetPhaseTimer()
182 lp.resetPVTimer()
183 lp.setPlanActive(false)
184 case api.ModeMinPV:
185 lp.resetPVTimer()
186 }
187
188 lp.requestUpdate()
189 }
190}
191
192// GetDefaultMode returns the default charge mode
193func (lp *Loadpoint) GetDefaultMode() api.ChargeMode {

Callers 2

defaultModeMethod · 0.95
setActiveVehicleMethod · 0.95

Calls 11

LockMethod · 0.95
UnlockMethod · 0.95
setModeMethod · 0.95
publishMethod · 0.95
resetPhaseTimerMethod · 0.95
resetPVTimerMethod · 0.95
setPlanActiveMethod · 0.95
requestUpdateMethod · 0.95
ChargeModeStringFunction · 0.92
PrintfMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected