An integration to control the Powervault battery
Project description
powervaultpy
A Python client library for the Powervault battery API, used primarily by the Home Assistant Powervault integration.
Supports both the cloud REST API (P4 & P5) and the local API available on legacy units (P3 & P3X).
Installation
pip install powervaultpy
Cloud API
The cloud API requires a paid API key obtained directly from Powervault. Based on the Swagger docs at https://app.swaggerhub.com/apis-docs/Powervault/PowervaultP3/.
Usage
from powervaultpy import PowerVault
client = PowerVault(api_key="your-api-key")
# Get account details
account = client.get_account()
# {"id": 123, "accountName": "..."}
# List units on the account
units = client.get_units(account["id"])
# Get details for a specific unit
unit = client.get_unit(units[0]["id"])
# Get latest telemetry data
data = client.get_data(unit["id"])
# Get telemetry for a specific period
data = client.get_data(unit["id"], period="past-hour")
# Get the current effective battery state (schedule + any active override)
state = client.get_battery_state(unit["id"])
# Override the battery state for the next 24 hours
client.set_battery_state(unit["id"], "force-charge")
Available periods for get_data
today, yesterday, past-hour, last-hour, past-day, last-day, past-week, last-week, past-month, last-month
Local API (legacy units)
Powervault legacy units expose a local HTTP API on port 5000. No API key is required. Pass the unit's IP address to the constructor — the client will then use the local API automatically for all calls.
get_units,get_unit, andget_accountare cloud-only. Calling them on a local client will raisePowerVaultApiClientError.
get_healthandget_unit_idare local-only. Calling them on a cloud client will raisePowerVaultApiClientError.
Usage
from powervaultpy import PowerVault
client = PowerVault(local_ip="192.168.1.100")
UNIT_ID = "008a2564"
# Check device health
health = client.get_health()
# {"status": "ok"}
# Get the unit ID from the device itself
uid = client.get_unit_id()
# "008a2564"
# Get latest telemetry (list of measurement records)
data = client.get_data(UNIT_ID)
# Get the current effective battery state
state = client.get_battery_state(UNIT_ID)
# Override the battery state for the next 24 hours
client.set_battery_state(UNIT_ID, "force-charge")
Local API endpoints
| Method | Local endpoint |
|---|---|
get_health |
GET /api/health |
get_unit_id |
GET /api/unit-id |
get_data |
GET /api/latest-telemetry |
get_battery_state |
GET /api/schedule + GET /api/state-override |
set_battery_state |
POST /api/state-override |
get_units |
Cloud only |
get_unit |
Cloud only |
get_account |
Cloud only |
Valid battery states
from powervaultpy import VALID_STATUSES
| State | Description |
|---|---|
normal |
Follow the configured schedule |
only-charge |
Only charge (from grid or solar) |
only-discharge |
Only discharge |
force-charge |
Force charge from grid |
force-discharge |
Force discharge to grid/home |
disable |
Disable the battery |
dormant |
Dormant mode |
Battery state override warning
⚠️ WARNING: Calling
set_battery_stateoverrides any schedule configured in the Powervault portal for the next 24 hours. Only use this if you are managing the battery state externally (e.g. via Home Assistant automations) and do not rely on the portal scheduler.
Development
pip install -e ".[dev]"
Running tests
Unit tests (no device or API key required — all mocked):
pytest tests/unit/
Integration tests — cloud API (requires API_KEY in .env):
pytest tests/integration/api/test_get_account.py
Integration tests — local API (requires LOCAL_IP and UNIT_ID in .env):
pytest tests/integration/api/test_local_api.py
.env file
API_KEY=your-cloud-api-key
LOCAL_IP=192.168.1.100
UNIT_ID=008a2564
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file powervaultpy-1.1.1.tar.gz.
File metadata
- Download URL: powervaultpy-1.1.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3da53f9c8f7a0b149a811a7e72b9002bbcbf66dd51c52c7abe80ee618d0a47a2
|
|
| MD5 |
f42f846c3a2e2c6d44c4ad95bdfe2362
|
|
| BLAKE2b-256 |
6b6df0c36390098c0fe3dfb2fe3291407c9d5069a49400093ec7b74a7d09d270
|