Skip to content

Toyota: fall back to evRange when evRangeWithAc is unusable#30347

Merged
andig merged 6 commits into
masterfrom
copilot/fix-toyota-api-issue
May 31, 2026
Merged

Toyota: fall back to evRange when evRangeWithAc is unusable#30347
andig merged 6 commits into
masterfrom
copilot/fix-toyota-api-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

Toyota status responses can now omit a usable evRangeWithAc, which caused range parsing to fail with unsupported unit type. This updates the Toyota provider to keep using the AC-adjusted range when valid, but fall back to the standard EV range when that field is missing or malformed.

  • Provider fallback

    • Keep evRangeWithAc as the preferred source.
    • Fall back to evRange if evRangeWithAc cannot be converted.
    • Return the fallback conversion error when both range fields are unusable.
  • Regression coverage

    • Add focused Toyota provider tests for:
      • normal evRangeWithAc handling
      • fallback when evRangeWithAc is absent/empty
      • error propagation when neither range field is usable
rng, err := res.Payload.EvRangeWithAc.ValueInKilometers()
if err == nil {
	return rng, nil
}

fallback, fallbackErr := res.Payload.EvRange.ValueInKilometers()
if fallbackErr == nil {
	return fallback, nil
}

return 0, fallbackErr

Copilot AI linked an issue May 30, 2026 that may be closed by this pull request
2 tasks
Copilot AI changed the title [WIP] Fix Toyota API interface not working Toyota: fall back to evRange when evRangeWithAc is unusable May 30, 2026
Copilot finished work on behalf of andig May 30, 2026 07:22
Copilot AI requested a review from andig May 30, 2026 07:22
@andig andig marked this pull request as ready for review May 31, 2026 07:06
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@andig andig added the vehicles Specific vehicle support label May 31, 2026
Comment thread vehicle/toyota/provider.go Outdated
@andig andig merged commit 791bfae into master May 31, 2026
7 checks passed
@andig andig deleted the copilot/fix-toyota-api-issue branch May 31, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vehicles Specific vehicle support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toyota API no properly workiing anymore

2 participants