KiaEurope: traverse JSON array indices so legacy (non-CCS2) EV range/SOC parse correctly#41
Open
MrL0 wants to merge 1 commit into
Open
KiaEurope: traverse JSON array indices so legacy (non-CCS2) EV range/SOC parse correctly#41MrL0 wants to merge 1 commit into
MrL0 wants to merge 1 commit into
Conversation
Kia EU's JSON traversal only descended dictionaries, so legacy (non-CCS2) paths indexing into arrays (evStatus.drvDistance.0.rangeByFuel.evModeRange.value) stopped at the array and read back 0, and the array-leaf targetSocList read via dict-only getChildFromJson always cast to empty. Align with the Hyundai EU sibling's array-index branch and read targetSocList via getAnyFromJson, so legacy EV range/unit and AC/DC charge targets populate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Kia EU's legacy (non-CCS2) parse paths index into JSON arrays, e.g.:
But
getAnyFromJsononly descended[String: Any]— when traversal reacheddrvDistance(an array) it returned the whole array and never applied the.0.rangeByFuel…segments. Net result for legacy (non-CCS2) Kia EU EVs:estimatedRange/driveUnitresolve to0. Separately, the legacytargetSocList(an array leaf) was read viagetChildFromJson, which only returns dictionaries, so theas? [[String: Any]]cast always failed and AC/DC charge targets were always empty.The Hyundai EU sibling already handles both correctly. This aligns Kia EU with it:
getAnyFromJsongains the array-index branch (array[index]for numeric path segments), matchingHyundaiEuropeAPIClient.getAnyFromJson.targetSocListis read viagetAnyFromJson(array leaf), matching the Hyundai EU read.The file already notes this helper duplication is intentional-but-drift-prone — happy to follow up by lifting these into a shared utility if you'd prefer.
Testing
swift test— 290 tests pass; the existing CCS2 status test is unaffected (CCS2 uses direct dict keys, not array indices). The traversal change is a verbatim port of the proven Hyundai EU implementation. Note: the suite has no legacy/non-CCS2 Kia EU status fixture to assert the fixed path end-to-end — if you have a sample payload I'm glad to add one.Drafted with AI assistance; verified locally with
swift test.