Skip to content

Honor Bluelink EU evModeRange units when API returns miles#29729

Closed
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-bluelink-api-range-units
Closed

Honor Bluelink EU evModeRange units when API returns miles#29729
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-bluelink-api-range-units

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

Bluelink EU status responses can report EV range in miles (unit: 3), but range was previously treated as kilometers. This caused underreported range in evcc while odometer parsing remained correct.

  • Range unit handling (EU Bluelink)

    • Extended vehicle/bluelink range model to parse evModeRange.unit.
    • Updated VehicleStatus.Range() to convert miles to kilometers before returning the backend canonical distance value.
    • Kept kilometer behavior unchanged.
  • Conversion semantics

    • Added explicit constants for unit mapping (unitMiles = 3) and conversion factor (kmPerMile = 1.60934).
    • Used math.Round for stable integer conversion when normalizing miles to km.
  • Coverage for regression-prone paths

    • Added focused tests for:
      • miles → km conversion on evModeRange
      • unchanged handling for kilometer values
      • not-available behavior when range data is missing
value := dist[0].RangeByFuel.EvModeRange.Value
if dist[0].RangeByFuel.EvModeRange.Unit == unitMiles {
	return int64(math.Round(value * kmPerMile)), nil
}
return int64(value), nil

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 224.0.0.251
    • Triggering command: REDACTED, pid is -1 (packet block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue May 7, 2026 that may be closed by this pull request
2 tasks
Copilot AI and others added 2 commits May 7, 2026 18:17
Copilot AI changed the title [WIP] Fix Bluelink API range unit parsing issue Honor Bluelink EU evModeRange units when API returns miles May 7, 2026
Copilot finished work on behalf of andig May 7, 2026 18:22
Copilot AI requested a review from andig May 7, 2026 18:22
@andig andig closed this May 7, 2026
@andig andig deleted the copilot/fix-bluelink-api-range-units branch May 7, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When Bluelink API returns range as miles, evcc treats them as km

2 participants