Switch sockets: end session when loadpoint disabled (#11170)

This commit is contained in:
andig 2023-12-22 19:33:43 +01:00 • committed by GitHub
parent 9eaf420061
commit f45ff4ee4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View file

@ -840,6 +840,8 @@ func (c *Easee) updateSmartCharging() {
}
}
var _ loadpoint.Controller = (*Easee)(nil)
// LoadpointControl implements loadpoint.Controller
func (c *Easee) LoadpointControl(lp loadpoint.API) {
c.lp = lp

View file

@ -493,6 +493,8 @@ func (c *OCPP) phases1p3p(phases int) error {
// return "", errors.New("not implemented")
// }
var _ loadpoint.Controller = (*OCPP)(nil)
// LoadpointControl implements loadpoint.Controller
func (c *OCPP) LoadpointControl(lp loadpoint.API) {
c.lp = lp

View file

@ -1,6 +1,9 @@
package charger
import "github.com/evcc-io/evcc/api"
import (
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/core/loadpoint"
)
// switchSocket implements the api.Charger Status and CurrentPower methods
// using basic generic switch socket functions
@ -9,6 +12,7 @@ type switchSocket struct {
enabled func() (bool, error)
currentPower func() (float64, error)
standbypower float64
lp loadpoint.API
}
func NewSwitchSocket(
@ -27,6 +31,10 @@ func NewSwitchSocket(
// Status calculates a generic switches status
func (c *switchSocket) Status() (api.ChargeStatus, error) {
if c.lp != nil && c.lp.GetMode() == api.ModeOff {
return api.StatusA, nil
}
res := api.StatusB
// static mode
@ -83,3 +91,10 @@ func (c *switchSocket) CurrentPower() (float64, error) {
return power, err
}
var _ loadpoint.Controller = (*switchSocket)(nil)
// LoadpointControl implements loadpoint.Controller
func (c *switchSocket) LoadpointControl(lp loadpoint.API) {
c.lp = lp
}