Skip to content

fix: add missing DetailedChargeState value; recommend against tesla-protocol dependency - #43

Merged
Bre77 merged 1 commit into
mainfrom
fm/pts-enum-names-from-protocol
Sep 2, 2026
Merged

fix: add missing DetailedChargeState value; recommend against tesla-protocol dependency#43
Bre77 merged 1 commit into
mainfrom
fm/pts-enum-names-from-protocol

Conversation

@Bre77

@Bre77 Bre77 commented Sep 2, 2026

Copy link
Copy Markdown
Member

Intent

  • Captain's ask: derive const.py's hardcoded TeslemetryEnum value tables (ShiftState, BMSState, DetailedChargeState, etc.) from tesla-protocol's proto enum descriptors, where fidelity allows.
    • Recommendation: don't adopt tesla-protocol as a dependency. This repo currently depends on nothing but aiohttp. tesla-protocol requires protobuf<8,>=6.32.0 and googleapis-common-protos - adding it would add ~4.8MB of runtime footprint (a C-extension-backed serialization library) purely to source ~40 static string lists that barely change. Home Assistant integrations (this library's main consumer) are notoriously sensitive to protobuf version pinning conflicts across dependencies, which makes the risk asymmetric to the benefit here.
    • Checked anyway: I installed tesla-protocol==1.4.0 in a scratch venv and diffed every TeslemetryEnum table in const.py against tesla_protocol.telemetry.vehicle_data_pb2's enum descriptors, stripping each table's prefix. 39 of 40 tables match byte-for-byte (including ShiftState, where the prefix-stripping is total: ShiftStateP -> P). ChargeState doesn't match the proto at all - already flagged in a code comment as a deprecated, non-real enum.
    • One real drift found: DetailedChargeState was missing Calibrating, present in the proto's DetailedChargeStateValue. Fixed by hand.
    • Added tests/test_enum_tables.py pinning the tables most likely to drift, and recorded the rationale in AGENTS.md so this isn't re-litigated from scratch next time.
Full narrative / original brief

Derive teslemetry-stream's hardcoded enum value tables from tesla-protocol where fidelity allows, per the captain's 2026-09-02 ask. The premise is that this repo does not currently depend on tesla-protocol - this would be a new dependency (plus transitive protobuf runtime) - so if the dependency cost looks disproportionate to what it replaces, the ask was to say so and stop with a recommendation instead of shipping.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AvS7kW3yp5jgSiMNuyj9cQ

Investigated deriving const.py's TeslemetryEnum value tables from the
tesla-protocol package's proto enum descriptors. Nearly every table
matches its proto enum byte-for-byte, but adopting tesla-protocol as a
runtime dependency would pull in protobuf + googleapis-common-protos -
disproportionate for sourcing ~40 static string lists, and risky for
Home Assistant consumers sensitive to protobuf version pinning. Not
adopted; see AGENTS.md for the recorded rationale.

DetailedChargeState was missing the Calibrating value present in the
proto, so that's fixed by hand, with a pinning test for the tables
most likely to drift.

Claude-Session: https://claude.ai/code/session_01AvS7kW3yp5jgSiMNuyj9cQ
@Bre77 Bre77 added the fm Opened by a Firstmate crewmate label Sep 2, 2026
@Bre77
Bre77 merged commit 2efc279 into main Sep 2, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fm Opened by a Firstmate crewmate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant