eg4_python
is a Python library that provides both async and sync methods to interact with the EG4 Inverter cloud API. It handles login, data retrieval, and session management efficiently — ideal for integration with Home Assistant, MCP, automation platforms, or custom monitoring solutions.
✅ Asynchronous and synchronous support (via asyncio
and sync wrappers)
✅ Automatic re-authentication on session expiry (401 errors)
✅ Modular structure for future expandability
✅ Supports DISCOVERING multiple inverters from a single account
pip install eg4_python
git clone https://github.com/yourusername/eg4_python.git
cd eg4_python
pip install -e .[dev] # For development and testing
You can look at the "test" function in client.py
import asyncio
from eg4_python import EG4InverterAPI
async def main():
api = EG4InverterAPI(username="username", password="password", base_url="https://monitor.eg4electronics.com")
await api.login(ignore_ssl=True)
# Display Inverters
for index, inverter in enumerate(api.get_inverters()):
print(f"Inverter {index}: {inverter}")
print("Selecting Inverter 0")
api.set_selected_inverter(inverterIndex=0)
# Fetch Runtime Data
runtime_data = await api.get_inverter_runtime_async()
print("Runtime Data:", runtime_data)
# Fetch Energy Data
energy_data = await api.get_inverter_energy_async()
print("Energy Data:", energy_data)
# Fetch Battery Data
battery_data = await api.get_inverter_battery_async()
print("Battery Data:", battery_data)
await api.close()
asyncio.run(main())
Create a .env
file:
USERNAME=your_username
PASSWORD=your_password
SERIAL_NUMBER=
PLANT_ID=
BASE_URL=https://monitor.eg4electronics.com
import os
from dotenv import load_dotenv
load_dotenv()
USERNAME = os.getenv("USERNAME")
PASSWORD = os.getenv("PASSWORD")
async def login()
– Handles login and saves the JSESSIONID cookie. Accepts ignore_ssl=[true|false]async def close()
– Gracefully closes the HTTP session.
get_inverters()
- list the inverters associated with the account, after loginset_selected_inverter(inverterIndex=index)
- Selects an inverter from the list of invertersset_selected_inverter(plantId=plantId, serialNum=serialNum)
- Explicitly sets the selected inverter
async def get_inverter_runtime_async()
– Retrieves inverter runtime data.async def get_inverter_energy_async()
– Retrieves inverter energy data.async def get_inverter_battery_async()
– Retrieves battery data, including individual battery units.
async def read_settings_async()
– reads parameters.async def write_settings_async()
– writes a parameter value.
get_inverter_runtime()
get_inverter_energy()
get_inverter_battery()
read_settings()
write_settings()
Ensure you have development dependencies installed:
pip install -e .[dev]
Then run the test suite:
pytest tests/
- ✅ Initial EG4 API implementation
- ✅ Async/Sync support
- ✅ Setting inverter values
- 🔜 ...Full Home Assistant Integration
- 🔜 ...You tell me
This project is licensed under the APACHE License.
Contributions are welcome! Please open issues, suggest improvements, or submit pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/awesome-feature
) - Commit your changes (
git commit -m 'Add an awesome feature'
) - Push to the branch (
git push origin feature/awesome-feature
) - Open a Pull Request
Garreth Jeremiah
GitHub Profile
Special thanks to DAB Ultimate beer!