Python library for Homevolt EMS devices.
Get real-time data from your Homevolt Energy Management System, including:
- Voltage, current, and power measurements
- Battery state of charge and temperature
- Grid, solar, and load sensor data
- Schedule information
Control your battery with:
- Immediate battery control (charge, discharge, idle)
- Scheduled battery operations
- Local mode management
- Parameter configuration
pip install homevoltThis repository supports a standard uv development workflow.
uv sync --devThat creates a local environment with the package and development tools installed.
Common commands:
uv run pre-commit run --all-files
uv run ruff check .
uv run mypy homevolt
uv run pytestimport asyncio
import aiohttp
import homevolt
async def main():
async with aiohttp.ClientSession() as session:
homevolt_connection = homevolt.Homevolt(
host="192.168.1.100",
password="optional_password",
websession=session,
)
await homevolt_connection.update_info()
print(f"Device ID: {homevolt_connection.unique_id}")
print(f"Current Power: {homevolt_connection.sensors['Power'].value} W")
print(f"Battery SOC: {homevolt_connection.sensors['Battery State of Charge'].value * 100}%")
# Access all sensors
for sensor_name, sensor in homevolt_connection.sensors.items():
print(f"{sensor_name}: {sensor.value} ({sensor.type.value})")
# Access device metadata
for device_id, metadata in homevolt_connection.device_metadata.items():
print(f"{device_id}: {metadata.name} ({metadata.model})")
await homevolt_connection.close_connection()
if __name__ == "__main__":
asyncio.run(main())import asyncio
import aiohttp
import homevolt
async def main():
async with aiohttp.ClientSession() as session:
async with homevolt.Homevolt(
host="192.168.1.100",
password="optional_password",
websession=session,
) as homevolt_connection:
await homevolt_connection.update_info()
print(f"Device ID: {homevolt_connection.unique_id}")
print(f"Available sensors: {list(homevolt_connection.sensors.keys())}")
if __name__ == "__main__":
asyncio.run(main())import asyncio
import aiohttp
import homevolt
async def main():
async with aiohttp.ClientSession() as session:
async with homevolt.Homevolt(
host="192.168.1.100",
password="optional_password",
websession=session,
) as homevolt_connection:
await homevolt_connection.update_info()
# Enable local mode to prevent remote schedule overrides
await homevolt_connection.enable_local_mode()
# Charge battery immediately (up to 3000W, stop at 90% SOC)
await homevolt_connection.charge_battery(max_power=3000, max_soc=90)
# Or use the full control method
await homevolt_connection.set_battery_mode(
mode=1, # Inverter Charge
max_charge=3000,
max_soc=90,
)
# Schedule night charging (11 PM - 7 AM)
from datetime import datetime, timedelta
tonight = datetime.now().replace(hour=23, minute=0, second=0)
tomorrow = (tonight + timedelta(days=1)).replace(hour=7, minute=0, second=0)
await homevolt_connection.add_schedule(
mode=1, # Inverter Charge
from_time=tonight.isoformat(),
to_time=tomorrow.isoformat(),
max_charge=3000,
max_soc=80,
)
# Set battery to idle
await homevolt_connection.set_battery_idle()
# Discharge during peak hours
await homevolt_connection.discharge_battery(max_power=2500, min_soc=30)
if __name__ == "__main__":
asyncio.run(main())The following modes are available for battery control:
0: Idle - Battery standby (no charge/discharge)1: Inverter Charge - Charge battery via inverter from grid/solar2: Inverter Discharge - Discharge battery via inverter to home/grid3: Grid Charge - Charge from grid with power setpoint4: Grid Discharge - Discharge to grid with power setpoint5: Grid Charge/Discharge - Bidirectional grid control6: Frequency Reserve - Frequency regulation service mode7: Solar Charge - Charge from solar production only8: Solar Charge/Discharge - Solar-based grid management9: Full Solar Export - Export all solar production
Main class for connecting to a Homevolt device.
Initialize a Homevolt connection.
host(str): Hostname or IP address of the Homevolt devicepassword(str, optional): Password for authenticationwebsession(aiohttp.ClientSession, optional): HTTP session. If not provided, one will be created.
unique_id(str | None): Device unique identifiersensors(dict[str, Sensor]): Dictionary of sensor readingsdevice_metadata(dict[str, DeviceMetadata]): Dictionary of device metadatacurrent_schedule(dict | None): Current schedule information
async update_info(): Fetch and update all device informationasync fetch_ems_data(): Fetch EMS data specificallyasync fetch_schedule_data(): Fetch schedule data specificallyasync close_connection(): Close the connection and clean up resources
Immediate Control:
async set_battery_mode(mode, **kwargs): Set immediate battery control modeasync charge_battery(**kwargs): Charge battery using inverterasync discharge_battery(**kwargs): Discharge battery using inverterasync set_battery_idle(**kwargs): Set battery to idle modeasync charge_from_grid(**kwargs): Charge from grid with power setpointasync discharge_to_grid(**kwargs): Discharge to grid with power setpointasync charge_from_solar(**kwargs): Charge from solar only
Scheduled Control:
async add_schedule(mode, **kwargs): Add a scheduled battery control entryasync delete_schedule(schedule_id): Delete a schedule by IDasync clear_all_schedules(): Clear all schedules
Configuration:
async enable_local_mode(): Enable local mode (prevents remote overrides)async disable_local_mode(): Disable local mode (allows remote overrides)async set_parameter(key, value): Set a device parameterasync get_parameter(key): Get a device parameter value
value(float | str | None): Sensor valuetype(SensorType): Type of sensordevice_identifier(str): Device identifier for grouping sensors
name(str): Device namemodel(str): Device model
Enumeration of sensor types:
VOLTAGECURRENTPOWERENERGY_INCREASINGENERGY_TOTALFREQUENCYTEMPERATUREPERCENTAGESIGNAL_STRENGTHCOUNTTEXTSCHEDULE_TYPE
HomevoltError: Base exception for all Homevolt errorsHomevoltConnectionError: Connection or network errorsHomevoltAuthenticationError: Authentication failuresHomevoltDataError: Data parsing errors
GPL-3.0