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

Method Prepare

core/loadpoint.go:676–781  ·  view source on GitHub ↗

Prepare loadpoint configuration by adding missing helper elements

(site site.API, uiChan chan<- util.Param, pushChan chan<- messenger.Event, lpChan chan<- *Loadpoint)

Source from the content-addressed store, hash-verified

674
675// Prepare loadpoint configuration by adding missing helper elements
676func (lp *Loadpoint) Prepare(site site.API, uiChan chan<- util.Param, pushChan chan<- messenger.Event, lpChan chan<- *Loadpoint) {
677 lp.site = site
678 lp.uiChan = uiChan
679 lp.pushChan = pushChan
680 lp.lpChan = lpChan
681
682 // event handlers
683 _ = lp.bus.Subscribe(evChargeStart, lp.evChargeStartHandler)
684 _ = lp.bus.Subscribe(evChargeStop, lp.evChargeStopHandler)
685 _ = lp.bus.Subscribe(evVehicleConnect, lp.evVehicleConnectHandler)
686 _ = lp.bus.Subscribe(evVehicleDisconnect, lp.evVehicleDisconnectHandler)
687 _ = lp.bus.Subscribe(evChargeCurrent, lp.evChargeCurrentHandler)
688 _ = lp.bus.Subscribe(evVehicleSoc, lp.evVehicleSocProgressHandler)
689
690 // restore settings
691 lp.restoreSettings()
692
693 // publish initial values
694 lp.publish(keys.Title, lp.GetTitle())
695 lp.publish(keys.Mode, lp.GetMode())
696 lp.publish(keys.Priority, lp.GetPriority())
697 lp.publish(keys.MinCurrent, lp.GetMinCurrent())
698 lp.publish(keys.MaxCurrent, lp.GetMaxCurrent())
699
700 lp.publish(keys.EnableThreshold, lp.Enable.Threshold)
701 lp.publish(keys.DisableThreshold, lp.Disable.Threshold)
702 lp.publish(keys.EnableDelay, lp.Enable.Delay)
703 lp.publish(keys.DisableDelay, lp.Disable.Delay)
704
705 lp.publish(keys.UI, lp.ui)
706
707 if phases := lp.getChargerPhysicalPhases(); phases != 0 {
708 if lp.phasesConfigured != phases && lp.phasesConfigured != 0 {
709 lp.log.WARN.Printf("configured phases %d do not match physical phases %d", lp.phasesConfigured, phases)
710 }
711 lp.phases = phases
712 lp.phasesConfigured = phases
713 }
714
715 lp.publish(keys.PhasesConfigured, lp.phasesConfigured)
716 lp.publish(keys.ChargerPhases1p3p, lp.hasPhaseSwitching())
717 lp.publish(keys.ChargerSinglePhase, lp.getChargerPhysicalPhases() == 1)
718 lp.publish(keys.PhasesActive, lp.ActivePhases())
719 lp.publish(keys.SmartCostLimit, lp.smartCostLimit)
720 lp.publish(keys.SmartFeedInPriorityLimit, lp.smartFeedInPriorityLimit)
721 lp.publishTimer(phaseTimer, 0, timerInactive)
722 lp.publishTimer(pvTimer, 0, timerInactive)
723
724 // charger features
725 for _, f := range api.FeatureValues() {
726 lp.publishChargerFeature(f)
727 }
728
729 // charger icon
730 if c, ok := api.Cap[api.IconDescriber](lp.charger); ok {
731 lp.publish(keys.ChargerIcon, c.Icon())
732 } else {
733 lp.publish(keys.ChargerIcon, nil)

Callers

nothing calls this directly

Calls 15

restoreSettingsMethod · 0.95
publishMethod · 0.95
GetTitleMethod · 0.95
GetModeMethod · 0.95
GetPriorityMethod · 0.95
GetMinCurrentMethod · 0.95
GetMaxCurrentMethod · 0.95
hasPhaseSwitchingMethod · 0.95
ActivePhasesMethod · 0.95
publishTimerMethod · 0.95
publishChargerFeatureMethod · 0.95

Tested by

no test coverage detected