Skip to content

Sign v1r requests through EnergyDeviceSigner - #206

Merged
Bre77 merged 2 commits into
mainfrom
fm/tfa-powerwall-one-signer
Oct 29, 2026
Merged

Bre77 merged 2 commits into
mainfrom
fm/tfa-powerwall-one-signer

Conversation

@Bre77

@Bre77 Bre77 commented Oct 29, 2026

Copy link
Copy Markdown
Member

V1rTransport now signs /tedapi/v1r requests through tesla/energy_signing.EnergyDeviceSigner with ttl=12, called in asyncio.to_thread, instead of its own copy of the signing code; it still loads the PEM itself and raises PowerwallAuthenticationError on a bad or non-RSA key, and _tlv, _build_tlv, _sign, the TLV tag constants and the signing-only imports are deleted. EnergyDeviceSigner is unchanged and its cloud default TTL stays 30 s, and the LAN and cloud envelope builders stay separate. The first commit adds tests/powerwall/test_transport_signing.py, a fixed byte vector test (fixed RSA key, envelope, DIN, clock and message UUID) that checks the whole signed RoutableMessage posted by post_v1r and verifies the signature and the 12 s expires_at; it passed against the old _sign code, and the second commit makes the signer switch with the test file unchanged and it still passes, which proves the signed bytes are identical. No other behaviour changes.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 95853f9 and 3cec873.

Files selected for processing: 2
  • tesla_fleet_api/tesla/powerwall/transport.py
  • tests/powerwall/test_transport_signing.py

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Walkthrough

V1rTransport now delegates signed-request creation to EnergyDeviceSigner instead of using its local encoding and RSA signing code. New deterministic tests check the serialized request, reply payload, message fields, expiry, and RSA signature.

Changes: Powerwall signing

Layer / File(s) Summary
Signer delegation and request validation
tesla_fleet_api/tesla/powerwall/transport.py, tests/powerwall/test_transport_signing.py
V1rTransport initializes EnergyDeviceSigner with the loaded private key and 12-second TTL, then offloads signing to a thread. Deterministic tests check the request bytes, reply payload, message fields, expiry, and RSA signature.

Priority: Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Refactor

Possibly related PRs

Merge Risk: Minimal · up to 3cec8

No merge-blocking risk is evident for the signing delegation.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: routing v1r request signing through EnergyDeviceSigner.
Description check Passed The description directly explains the signing change, preserved behavior, removed duplicate code, and added deterministic tests related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@Bre77
Bre77 merged commit 6cb3d99 into main Oct 29, 2026
7 checks passed
@Bre77
Bre77 deleted the fm/tfa-powerwall-one-signer branch October 29, 2026 22:08
@Bre77 Bre77 mentioned this pull request Oct 31, 2026
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.

1 participant