A package to reading and writing data to and from Sigenergy inverters
Project description
Sigen
A package to reading and writing data to and from Sigenergy inverters.
Installation
pip install sigen
Usage
from sigen import Sigen
# username and password you use in the mySigen app.
sigen = Sigen(username=username, password=password)
# Initialize the Sigen instance
await sigen.async_initialize()
# Read data
print(await sigen.fetch_station_info())
print(await sigen.get_energy_flow())
print(await sigen.get_operational_mode())
# Set modes
print(await sigen.set_operational_mode_sigen_ai_mode())
print(await sigen.set_operational_mode_maximum_self_powered())
print(await sigen.set_operational_mode_tou())
print(await sigen.set_operational_fully_fed_to_grid())
Full example:
import logging
import os
import asyncio
from sigen import Sigen
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
async def main():
# Read username and password from environment variables
username = os.getenv('SIGEN_USERNAME')
password = os.getenv('SIGEN_PASSWORD')
if not username or not password:
logging.error("Environment variables SIGEN_USERNAME and SIGEN_PASSWORD must be set")
return
sigen = Sigen(username=username, password=password)
# Initialize the Sigen instance
await sigen.async_initialize()
# Fetch and log station info
logger.info("Fetching station info...")
station_info = await sigen.fetch_station_info()
logger.info("Station Info:")
logger.info(f"Station ID: {station_info['stationId']}")
logger.info(f"Has PV: {station_info['hasPv']}")
logger.info(f"Has EV: {station_info['hasEv']}")
logger.info(f"On Grid: {station_info['onGrid']}")
logger.info(f"PV Capacity: {station_info['pvCapacity']} kW")
logger.info(f"Battery Capacity: {station_info['batteryCapacity']} kWh")
# Fetch and log energy flow info
logger.info("\nFetching energy flow info...")
energy_flow = await sigen.get_energy_flow()
logger.info("Energy Flow Info:")
logger.info(f"PV Day Energy: {energy_flow['pvDayNrg']} kWh")
logger.info(f"PV Power: {energy_flow['pvPower']} kW")
logger.info(f"Buy/Sell Power: {energy_flow['buySellPower']} kW")
logger.info(f"EV Power: {energy_flow['evPower']} kW")
logger.info(f"AC Power: {energy_flow['acPower']} kW")
logger.info(f"Load Power: {energy_flow['loadPower']} kW")
logger.info(f"Battery Power: {energy_flow['batteryPower']} kW")
logger.info(f"Battery SOC: {energy_flow['batterySoc']}%")
# Fetch and log current operational mode
logger.info("\nFetching current operational mode...")
current_mode = await sigen.get_operational_mode()
logger.info(f"Current Operational Mode: {current_mode}")
# Change operational mode (example: setting mode to 'Fully Fed to Grid')
# logger.info("\nSetting operational mode to 'Fully Fed to Grid'...")
# response = await sigen.set_operational_mode(5)
# Or set by label
# response = await sigen.set_operational_mode_sigen_ai_mode()
# response = await sigen.set_operational_mode_tou()
# response = await sigen.set_operational_mode_fully_fed_to_grid()
# response = await sigen.set_operational_mode_maximum_self_powered()
# logger.info(f"Response: {response}")
# logger.info("\nFetching current operational mode...")
# current_mode = await sigen.get_operational_mode()
# logger.info(f"Current Operational Mode: {current_mode}")
if __name__ == "__main__":
asyncio.run(main())
Example output of the above code:
2024-06-07 06:09:29 INFO Fetching station info...
2024-06-07 06:09:29 INFO Station ID: 20241231231231
2024-06-07 06:09:29 INFO Has PV: True
2024-06-07 06:09:29 INFO Has EV: False
2024-06-07 06:09:29 INFO On Grid: True
2024-06-07 06:09:29 INFO PV Capacity: 10.3 kW
2024-06-07 06:09:29 INFO Battery Capacity: 8.06 kWh
Fetching energy flow info...
2024-06-07 06:09:29 INFO PV Day Energy: 35.25 kWh
2024-06-07 06:09:29 INFO PV Power: 5.232 kW
2024-06-07 06:09:29 INFO Buy/Sell Power: 3.8 kW
2024-06-07 06:09:29 INFO EV Power: 0.0 kW
2024-06-07 06:09:29 INFO AC Power: 0.0 kW
2024-06-07 06:09:29 INFO Load Power: 0.5 kW
2024-06-07 06:09:29 INFO Battery Power: 0.932 kW
2024-06-07 06:09:29 INFO Battery SOC: 48.4%
Fetching current operational mode...
2024-06-07 06:09:29 INFO Current Operational Mode: TOU
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
sigen-0.1.7.tar.gz
(5.6 kB
view details)
Built Distribution
sigen-0.1.7-py3-none-any.whl
(5.0 kB
view details)
File details
Details for the file sigen-0.1.7.tar.gz
.
File metadata
- Download URL: sigen-0.1.7.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 040c6586e06da3a111b0c5cadfa3c1a3e1a99d753916d9dc59a2e02ff755b580 |
|
MD5 | 59e17a5dba95b0041ec618ab446b0f9b |
|
BLAKE2b-256 | 4a839a3616ce6739cd14bf934b473d405341df2490a8069f9ded37b40ca16087 |
File details
Details for the file sigen-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: sigen-0.1.7-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 139835ead92d00ad9f3db2aa016605dd75f3640698674bcd5a3ca907fcd5e548 |
|
MD5 | 141af51939361159f5fbfe7faf7be2a5 |
|
BLAKE2b-256 | e1672abe255123aa6810a7cbf22ec27637ab40b67f42ce9ffcc860571e8bd14c |