This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is an unofficial Home Assistant custom integration for Rivian vehicles. It uses the rivian-python-client library to communicate with Rivian's cloud API via GraphQL subscriptions and REST endpoints.
pip install -r requirements.txt
pre-commit installruff check custom_components/
ruff format custom_components/Use VS Code devcontainer (recommended) - opens at port 8123. The devcontainer automatically:
- Installs dependencies via
.devcontainer/setup - Creates
config/directory for HA configuration - Configures debug logging for
custom_components.rivian
Entry Point (__init__.py):
- Sets up coordinators and forwards platform setup
- Creates
UserCoordinatorfirst to get vehicle list - Creates a
VehicleCoordinatorper vehicle - Creates a single
WallboxCoordinatorfor all wallboxes - Stores everything in
hass.data[DOMAIN][entry_id]
Data Coordinators (coordinator.py):
RivianDataUpdateCoordinator- Abstract base with error handling and exponential backoffUserCoordinator- Fetches user info and vehicle listVehicleCoordinator- Subscribes to real-time vehicle state updates via WebSocketChargingCoordinator- Polls charging session data (adjusts interval based on plugged-in status)DriverKeyCoordinator- Fetches driver/key enrollment dataWallboxCoordinator- Polls wallbox dataVehicleImageCoordinator- Fetches vehicle images on-demand
Entity Base Classes (entity.py):
RivianEntity- Generic baseRivianVehicleEntity- For vehicle sensors/binary sensorsRivianVehicleControlEntity- For commands (checks gear=park, zone restrictions, pairing status)RivianChargingEntity- For charging session dataRivianWallboxEntity- For wallbox data
Entity Descriptions (data_classes.py):
Custom dataclasses extending HA entity descriptions with Rivian-specific fields like field (API field name), value_lambda, on_value, etc.
Sensor Definitions (const.py):
Dictionaries SENSORS and BINARY_SENSORS keyed by vehicle type ("R1", "R1T", "R1S") containing entity descriptions.
- Vehicle state comes via WebSocket subscription (not polling)
VehicleCoordinator._process_new_data()receives updates and merges with existing data- Invalid sensor values are filtered out using
INVALID_SENSOR_STATES - Entities read values via
coordinator.get(field_name)
Remote commands require:
- 2FA enabled on Rivian account
- Bluetooth pairing (one-time, in-vehicle)
- Vehicle in "Park" gear
- Optionally restricted by Home Assistant zones
Commands flow through VehicleCoordinator.send_vehicle_command() which:
- Wakes vehicle if sleeping
- Uses enrolled phone credentials from config entry options
Each platform (sensor, binary_sensor, button, climate, cover, lock, number, select, switch, update, device_tracker, image) has its own module that:
- Defines entity descriptions specific to that platform
- Implements
async_setup_entry()to create entities - Extends the appropriate base entity class
rivian-python-client[ble]==2.0.0- Core API client (includes BLE support for pairing)homeassistant>=2025.1.0- Home Assistant core