Skip to main content

A package to reading and writing data to and from Sigenergy inverters

Project description

Sigen

Unofficial package for reading and writing data to and from Sigenergy inverters via cloud APIs.

[!IMPORTANT]
This repository is only sporadically maintained. Breaking API changes will be maintained on a best efforts basis.

Collaborators are welcome, as are PRs for enhancements.

Bug reports unrelated to API changes may not get the attention you want.

Installation

pip install sigen

Usage

from sigen import Sigen

# username and password you use in the mySigen app.
# Region is Europe (eu) / Asia-Pacific (apac) /
# Middle East & Africa (eu) / Chinese Mainland (cn) / Unitest States (us)
sigen = Sigen(username="your_username", password="your_password", region="eu")

# 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


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.9.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

sigen-0.1.9-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file sigen-0.1.9.tar.gz.

File metadata

  • Download URL: sigen-0.1.9.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for sigen-0.1.9.tar.gz
Algorithm Hash digest
SHA256 eb99bc72581993e41a263345eda8c94689d7815f5be590bd953b9a67ab0e27b0
MD5 70c1b1e52d192e6ee1cafdcf254371a1
BLAKE2b-256 0b10aee5ec7927b0adaa60fb0e2cfb22bbfaa56b3a7220dabc1c767674f8b213

See more details on using hashes here.

File details

Details for the file sigen-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: sigen-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for sigen-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 95108baff90ab58e86c858d9d9dc5ad0d6111c0a265cb0a4fd60bf027b27af13
MD5 21c2b6e262f76779f7d3c3cb6b8443a7
BLAKE2b-256 7d1db2c6bcb5156c91e3680db44797703904e0c278098edd89aa4bfcf56c9cca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page