Easee: add status reason (#27789)

This commit is contained in:
Michael Heß 2026-03-01 10:39:15 +01:00 • committed by GitHub
parent 1a8e93d7c4
commit 91b9b117fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 0 deletions

View file

@ -794,6 +794,21 @@ func (c *Easee) GetPhases() (int, error) {
return phases, nil
}
var _ api.StatusReasoner = (*Easee)(nil)
// StatusReason implements the api.StatusReasoner interface
func (c *Easee) StatusReason() (api.Reason, error) {
c.mux.RLock()
defer c.mux.RUnlock()
switch c.opMode {
case easee.ModeAwaitingAuthentication:
return api.ReasonWaitingForAuthorization, nil
case easee.ModeCompleted:
return api.ReasonDisconnectRequired, nil
}
return api.ReasonUnknown, nil
}
var _ api.Identifier = (*Easee)(nil)
// Currents implements the api.PhaseCurrents interface

View file

@ -322,6 +322,31 @@ func TestEasee_waitForDynamicChargerCurrent(t *testing.T) {
}
}
func TestEasee_StatusReason(t *testing.T) {
testcases := []struct {
opMode int
expectedReason api.Reason
}{
{easee.ModeAwaitingAuthentication, api.ReasonWaitingForAuthorization},
{easee.ModeCompleted, api.ReasonDisconnectRequired},
{easee.ModeDisconnected, api.ReasonUnknown},
{easee.ModeAwaitingStart, api.ReasonUnknown},
{easee.ModeCharging, api.ReasonUnknown},
{easee.ModeReadyToCharge, api.ReasonUnknown},
{easee.ModeDeauthenticating, api.ReasonUnknown},
}
for _, tc := range testcases {
t.Logf("%+v", tc)
e := newEasee()
e.opMode = tc.opMode
reason, err := e.StatusReason()
assert.NoError(t, err)
assert.Equal(t, tc.expectedReason, reason)
}
}
func TestEasee_MaxCurrent(t *testing.T) {
testCases := []struct {
targetCurrent int64