Skip to content

Tesla BLE: add caching#26861

Merged
andig merged 5 commits intomasterfrom
fix/cache
Jan 21, 2026
Merged

Tesla BLE: add caching#26861
andig merged 5 commits intomasterfrom
fix/cache

Conversation

@andig
Copy link
Member

@andig andig commented Jan 21, 2026

@wimaha would that work? Wasn't sure if HTTP cache headers are already supported. If not, this will force caching and reduce number of requests.

@andig andig added infrastructure Basic functionality devices Specific device support labels Jan 21, 2026
Copy link
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 left some high level feedback:

  • Consider making the cache duration configurable via a parameter (similar to timeout) instead of hardcoding 1s in each query so different deployments can tune caching without editing the template.
  • Since the same uri and endpoints=charge_state are repeated for each query, you might want to factor this out into a shared template/partial or YAML anchor to reduce duplication and the chance of inconsistencies in future changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider making the `cache` duration configurable via a parameter (similar to `timeout`) instead of hardcoding `1s` in each query so different deployments can tune caching without editing the template.
- Since the same `uri` and `endpoints=charge_state` are repeated for each query, you might want to factor this out into a shared template/partial or YAML anchor to reduce duplication and the chance of inconsistencies in future changes.

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.

@wimaha
Copy link
Contributor

wimaha commented Jan 21, 2026

Hi, we have in-memory caching for VehicleData responses (per-endpoint, per-VIN, configurable via vehicleDataCacheTime, default 30 seconds), which reduces BLE connections. So we should not have a problem with multiple request in a short period.
But if this reduces http requests it may be a good change.

We currently don't have HTTP cache headers set for VehicleData responses.

@andig
Copy link
Member Author

andig commented Jan 21, 2026

Thank you, then this PR should reduce number of requests. If your internal caching sends headers in future we can drop this again.

@andig andig merged commit 479e5c3 into master Jan 21, 2026
7 checks passed
@andig andig deleted the fix/cache branch January 21, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devices Specific device support infrastructure Basic functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants