From 162d7c7ccd5c8bb79b4575923e5a795c1da1685d Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 23 Mar 2025 12:13:20 +0100 Subject: [PATCH] Heatpump: allow fine control (#20040) --- charger/evsewifi.go | 12 ++++++------ charger/heatpump.go | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/charger/evsewifi.go b/charger/evsewifi.go index ba988146d..131a81f25 100644 --- a/charger/evsewifi.go +++ b/charger/evsewifi.go @@ -95,10 +95,10 @@ func NewEVSEWifiFromConfig(other map[string]interface{}) (api.Charger, error) { voltages = wb.voltages } - // decorate Charger with MaxCurrentEx - var maxCurrentEx func(float64) error + // decorate Charger with MaxCurrentMillis + var maxCurrentMillis func(float64) error if wb.hires { - maxCurrentEx = wb.maxCurrentEx + maxCurrentMillis = wb.maxCurrentMillis wb.current = 100 * wb.current } @@ -108,7 +108,7 @@ func NewEVSEWifiFromConfig(other map[string]interface{}) (api.Charger, error) { identify = wb.identify } - return decorateEVSE(wb, currentPower, totalEnergy, currents, voltages, maxCurrentEx, identify), nil + return decorateEVSE(wb, currentPower, totalEnergy, currents, voltages, maxCurrentMillis, identify), nil } // NewEVSEWifi creates EVSEWifi charger @@ -208,8 +208,8 @@ func (wb *EVSEWifi) MaxCurrent(current int64) error { return err } -// maxCurrentEx implements the api.ChargerEx interface -func (wb *EVSEWifi) maxCurrentEx(current float64) error { +// maxCurrentMillis implements the api.ChargerEx interface +func (wb *EVSEWifi) maxCurrentMillis(current float64) error { wb.current = int64(100 * current) uri := fmt.Sprintf("%s/setCurrent?current=%d", wb.uri, wb.current) return wb.get(uri) diff --git a/charger/heatpump.go b/charger/heatpump.go index 9b5790fac..08f2fd14d 100644 --- a/charger/heatpump.go +++ b/charger/heatpump.go @@ -148,11 +148,13 @@ func (wb *Heatpump) Enable(enable bool) error { // MaxCurrent implements the api.Charger interface func (wb *Heatpump) MaxCurrent(current int64) error { - return wb.MaxCurrentEx(float64(current)) + return wb.MaxCurrentMillis(float64(current)) } +var _ api.ChargerEx = (*Heatpump)(nil) + // MaxCurrent implements the api.Charger interface -func (wb *Heatpump) MaxCurrentEx(current float64) error { +func (wb *Heatpump) MaxCurrentMillis(current float64) error { phases := 1 if wb.lp != nil { phases = wb.lp.GetPhases()