Easee: add status reason (#27789)
This commit is contained in:
parent
1a8e93d7c4
commit
91b9b117fa
2 changed files with 40 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue