Skip to content

feat: add charging schedule API methods#184

Open
RAR wants to merge 3 commits intobretterer:mainfrom
RAR:feat/charge-current-limit
Open

feat: add charging schedule API methods#184
RAR wants to merge 3 commits intobretterer:mainfrom
RAR:feat/charge-current-limit

Conversation

@RAR
Copy link
Copy Markdown

@RAR RAR commented Apr 10, 2026

Summary

Adds two new methods to the Rivian class for managing vehicle charging schedules:

  • get_charging_schedules(vehicle_id) — Queries getVehicle to fetch the current charging schedules, returning fields: weekDays, startTime, duration, location, amperage, enabled
  • set_charging_schedules(vehicle_id, schedules) — Sends the setChargingSchedules GraphQL mutation to update the full schedule array

Why

The Rivian API exposes charge amperage control through charging schedules (the SetChargingSchedule GraphQL mutation), but the Python client has no methods for it. This has been requested in the HA integration repo (issues #153, #221, #244) to enable charge current control for energy management systems like evcc.

Implementation

Both methods follow the existing codebase patterns exactly:

  • get_charging_schedules: Read-only query using A-Sess + U-Sess headers (no CSRF, matching other query methods). Uses the getVehicle root query to access chargingSchedules on the Vehicle type, which is already defined in the gateway schema.
  • set_charging_schedules: Mutation using Csrf-Token + A-Sess + U-Sess headers (matching send_vehicle_command, enroll_phone, etc.). Sends InputChargingSchedule objects with fields: weekDays, startTime, duration, location (CoordinatesInput), amperage, enabled.

Both use inline GraphQL strings, GRAPHQL_GATEWAY endpoint, and return ClientResponse via __graphql_query — consistent with every other method in the class.

GraphQL types (from gateway.graphql schema)

input InputChargingSchedule {
  weekDays: [String!]!
  startTime: Int!
  duration: Int!
  location: CoordinatesInput!
  amperage: Int!
  enabled: Boolean!
}

type ChargingSchedule {
  startTime: Int!
  duration: Int!
  location: GeoCoordinates!
  amperage: Int!
  enabled: Boolean!
  weekDays: [String!]!
}

Test plan

  • Added test_get_charging_schedules — mocks gateway, verifies response parsing (schedule count, amperage, enabled, weekDays)
  • Added test_set_charging_schedules — mocks gateway, verifies mutation with CSRF token succeeds
  • Full test suite passes (17/17)
  • Tested end-to-end via the home-assistant-rivian integration against a real Rivian vehicle — confirmed read and write of charging schedules works correctly

🤖 Generated with Claude Code

RAR and others added 3 commits April 9, 2026 10:03
Add GraphQL query method to fetch vehicle charging schedules, supporting
the upcoming charge amperage control feature in the HA integration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Matches the convention used by all other mutations in the codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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