Skip to content

Commit

Permalink
Fix charge states
Browse files Browse the repository at this point in the history
Fix states with the explanation from https://evsim.gonium.net

StatusA		Unplugged
StatusB		Plugged
StatusC		Charging
StatusD		Charging with ventilator
StatusE		Error (Kurzschluss)
StatusF		Error (Ausfall Wallbox)
  • Loading branch information
DerAndereAndi committed Apr 19, 2020
1 parent 3c0fb2b commit 4c26603
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
21 changes: 5 additions & 16 deletions charger/mcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,13 @@ func (mcc *MobileConnect) Status() (api.ChargeStatus, error) {
}

switch chargeState {
case 0:
// 0: Unplugged StatusA
case 0, 1: // 0: Unplugged, 1: Connecting
return api.StatusA, nil
case 1:
// 1: Connecting StatusB
return api.StatusB, nil
case 2:
// 2: Error StatusE
return api.StatusE, nil
case 3:
// 3: Established StatusF
case 2: // Error
return api.StatusF, nil
case 4, 6:
// 4: Paused StatusD
// 6: Finished StatusD
return api.StatusD, nil
case 5:
// 5: Active StatusC
case 3, 4, 6: // 3: Established, 4: Pausee, 6: Finished

This comment has been minimized.

Copy link
@andig

andig Apr 19, 2020

Member

Paused?

return api.StatusB, nil
case 5: // Active
return api.StatusC, nil
default:
return api.StatusNone, fmt.Errorf("properties unknown result: %d", chargeState)
Expand Down
10 changes: 5 additions & 5 deletions charger/mcc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ func TestMobileConnect_Status(t *testing.T) {
// test cases for software version 2912
{"home plug - Unexpected API response", []apiResponse{{apiChargeState, "abc"}}, api.StatusNone, true},
{"home plug - Unplugged", []apiResponse{{apiChargeState, "0\n"}}, api.StatusA, false},
{"home plug - Connecting", []apiResponse{{apiChargeState, "1\n"}}, api.StatusB, false},
{"home plug - Error", []apiResponse{{apiChargeState, "2\n"}}, api.StatusE, false},
{"home plug - Established", []apiResponse{{apiChargeState, "3\n"}}, api.StatusF, false},
{"home plug - Paused", []apiResponse{{apiChargeState, "4\n"}}, api.StatusD, false},
{"home plug - Connecting", []apiResponse{{apiChargeState, "1\n"}}, api.StatusA, false},
{"home plug - Error", []apiResponse{{apiChargeState, "2\n"}}, api.StatusF, false},
{"home plug - Established", []apiResponse{{apiChargeState, "3\n"}}, api.StatusB, false},
{"home plug - Paused", []apiResponse{{apiChargeState, "4\n"}}, api.StatusB, false},
{"home plug - Active", []apiResponse{{apiChargeState, "5\n"}}, api.StatusC, false},
{"home plug - Finished", []apiResponse{{apiChargeState, "6\n"}}, api.StatusD, false},
{"home plug - Finished", []apiResponse{{apiChargeState, "6\n"}}, api.StatusB, false},
{"home plug - Unexpected status value", []apiResponse{{apiChargeState, "10\n"}}, api.StatusNone, true},
}
for _, tt := range tests {
Expand Down

0 comments on commit 4c26603

Please sign in to comment.