A simple Pythonic wrapper around the ChargePoint EV Charging Network API.
I, nor this project, are in any way associated with ChargePoint. Use this project at your own risk. ChargePoint is a registered trademark of ChargePoint, Inc.
I just wanted a way to retrieve and store charging data from my ChargePoint Home Flex in a way that is easy to model and query. This project is the first step in getting that data into a more robust time series database.
- Token Caching: Automatically caches login tokens to disk to avoid re-authentication on script restarts
- Home Charger Management: Monitor and control your ChargePoint Home Flex charger
- Charging Session Management: Start, stop, and monitor charging sessions
- Dynamic Amperage Control: Adjust charge amperage limits during active charging sessions
- Account Information: Access account details, vehicles, and charging history
The library automatically caches login tokens to disk (default location: ~/.chargepoint/). This allows you to avoid re-authentication when restarting your scripts.
from python_chargepoint import ChargePoint
# First run - performs fresh login and caches token
client = ChargePoint(username="user", password="password")
print(client.user_id)
# 1234567890
# Subsequent runs - uses cached token automatically
client2 = ChargePoint(username="user", password="password") # No password prompt needed!
print(client2.user_id)
# 1234567890# Disable token caching
client = ChargePoint(username="user", password="password", use_token_cache=False)
# Use custom cache directory
client = ChargePoint(username="user", password="password", cache_dir="/path/to/cache")
# Clear token cache for current user
client.clear_token_cache()
# Clear all cached tokens
client.clear_all_token_caches()from python_chargepoint import ChargePoint
client = ChargePoint(username="user", password="password", use_token_cache=False)
print(client.user_id)
# 1234567890from python_chargepoint import ChargePoint
client = ChargePoint(username="user", password="password")
chargers = client.get_home_chargers()
print(chargers)
# [12345678]
for charger_id in chargers:
charger = client.get_home_charger_status(charger_id=charger_id)
print(charger)
# HomeChargerStatus(
# brand='CP',
# plugged_in=True,
# connected=True,
# charging_status='NOT_CHARGING',
# last_connected_at=datetime.datetime(2022, 1, 30, 15, 14, 36),
# reminder_enabled=False,
# reminder_time='21:00',
# model='CPH50-NEMA6-50-L23',
# mac_address='0024B10000012345',
# amperage_limit=25,
# possible_amperage_limits=[20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32])
### New Charger Status API
New Charger Status API
```python
from python_chargepoint import ChargePoint
client = ChargePoint(username="user", password="password")
# Get chargers using new API
chargers = client.get_home_chargers_v2()
print(chargers)
# [{'id': 12345678, 'label': 'Home Charger', 'protocolIdentifier': 'CPH50', ...}]
# Get charger status using new API (matches mobile app)
for charger in chargers:
charger_id = charger.get('id')
status = client.get_home_charger_status_v2(charger_id)
print(status)
# HomeChargerStatusV2(
# brand='CP',
# plugged_in=True,
# connected=True,
# charging_status='CHARGING_STOPPED',
# scheduled_for='00:00',
# reminder_enabled=False,
# reminder_time='21:00',
# model='CPH50-NEMA6-50-L23',
# mac_address='0024B10000012345',
# amperage_limit=15,
# possible_amperage_limits=[20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32],
# amperage_in_progress=False,
# flashlight_reset=False,
# has_utility_info=False,
# is_during_scheduled_time=True)from python_chargepoint import ChargePoint
client = ChargePoint(username="user", password="password")
charging = client.get_user_charging_status()
if charging:
print(charging)
# UserChargingStatus(
# session_id=1234567890,
# start_time=datetime.datetime(2022, 1, 30, 13, 32, 45),
# state='fully_charged',
# stations=[
# ChargePointStation(
# id=12345678,
# name='CP HOME ',
# latitude=30.0000000,
# longitude=-90.0000000)
# ])
session = client.get_charging_session(charging.session_id)
print(session)
# ChargingSession(
# session_id=1234567890,
# start_time=datetime.datetime(2022, 1, 30, 13, 32, 45),
# device_id=12345678,
# device_name='CP HOME',
# charging_state='fully_charged',
# charging_time=2426000,
# energy_kwh=4.3404,
# miles_added=15.024461538461539,
# miles_added_per_hour=0.0,
# outlet_number=1,
# port_level=2,
# power_kw=0.0,
# purpose='PERSONAL',
# currency_iso_code='USD',
# payment_completed=True,
# payment_type='none',
# pricing_spec_id=0,
# total_amount=0.67,
# api_flag=False,
# enable_stop_charging=True,
# has_charging_receipt=False,
# has_utility_info=True,
# is_home_charger=True,
# is_purpose_finalized=True,
# last_update_data_timestamp=datetime.datetime(2022, 1, 30, 15, 12, 48),
# stop_charge_supported=True,
# company_id=12345,
# company_name='CP Home',
# latitude=30.0000000,
# longitude=-90.0000000,
# address='Home Charger',
# city='City',
# state_name='State',
# country='United States',
# zipcode='12345',
# update_data=[
# ChargingSessionUpdate(
# energy_kwh=0.0,
# power_kw=0.0002,
# timestamp=datetime.datetime(2022, 1, 30, 13, 32, 57)),
# ChargingSessionUpdate(
# energy_kwh=0.0001,
# power_kw=0.1568,
# timestamp=datetime.datetime(2022, 1, 30, 13, 33, 9)),
# ChargingSessionUpdate(
# energy_kwh=0.0025,
# power_kw=3.7337,
# timestamp=datetime.datetime(2022, 1, 30, 13, 33, 12)),
# ChargingSessionUpdate(
# energy_kwh=0.0161,
# power_kw=1.3854,
# timestamp=datetime.datetime(2022, 1, 30, 13, 33, 33)),
# ...],
# update_period=300000,
# utility=PowerUtility(
# id=0,
# name='Energy Company',
# plans=[
# PowerUtilityPlan(
# code='R',
# id=12345,
# is_ev_plan=False,
# name='Residential')
# ]))from python_chargepoint import ChargePoint
client = ChargePoint(username="user", password="password")
charging = client.get_user_charging_status()
if charging:
session = client.get_charging_session(charging.session_id)
session.stop()
# If you wanted to charge again, you can start a new session.
session = client.start_charging_session(session.device_id)You can also start a new session by providing any device ID you want to start charging on.
from python_chargepoint import ChargePoint
client = ChargePoint(username="user", password="password")
home_flex_id = client.get_home_chargers()[0]
home_flex = client.get_home_charger_status(home_flex_id)
if home_flex.charging_status == "AVAILABLE":
session = client.start_charging_session(home_flex_id)from python_chargepoint import ChargePoint
client = ChargePoint(username="user", password="password")
home_flex_id = client.get_home_chargers()[0]
# Print out valid amperage values.
print(client.get_home_charger_status(home_flex_id).possible_amperage_limits)
# [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
client.set_amperage_limit(home_flex_id, 23)
print(client.get_home_charger_status(home_flex_id).amperage_limit)
# 23You can also adjust the charge amperage limit during an active charging session:
from python_chargepoint import ChargePoint
client = ChargePoint(username="user", password="password")
charging = client.get_user_charging_status()
if charging and charging.state == "in_use":
session = client.get_charging_session(charging.session_id)
# Adjust amperage limit during charging (e.g., to 32 amps)
response = session.set_charge_amperage_limit(32)
print(f"Amperage limit change status: {response.status}")
# Amperage limit change status: APPLYING
print(f"Desired value: {response.desired_value}")
# Desired value: 32Note: This functionality is typically only available when actively charging and may not be supported by all chargers.