Skip to main content

Interacts with Sigenergy cloud APIs to read and write data to and from inverters. For local control, use Modbus instead.

Project description

Sigen

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

Version 3.0.0 - Updated to support v3 app APIs for modes and smart loads.

[!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 default 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_mode_fully_fed_to_grid())

# Set custom modes (if available)
print(await sigen.set_operational_mode_summer_50kwh())

# Get and control smart loads
smart_loads = await sigen.get_smart_loads()
for load in smart_loads:
    print(f"Smart Load: {load['name']} - Power: {load['valueWithUnit']}")

# Control smart loads (using path value)
print(await sigen.set_smart_load_state(1, 1))  # Turn on smart load with path 1
print(await sigen.set_smart_load_state(1, 0))  # Turn off smart load with path 1

# Or use convenient dynamic methods (generated from available smart loads)
print(await sigen.enable_smart_load_immersion())   # Turn on
print(await sigen.disable_smart_load_immersion())  # Turn off

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
    # For default modes - using dynamic methods
    # logger.info("\nSetting operational mode to 'Fully Fed to Grid'...")
    # response = await sigen.set_operational_mode_fully_fed_to_grid()
    # logger.info(f"Response: {response}")
    
    # For default modes - using direct method
    # logger.info("\nSetting operational mode to TOU (value=2)...")
    # response = await sigen.set_operational_mode(2, -1)  # -1 for default modes
    # logger.info(f"Response: {response}")
    
    # For custom modes - using dynamic methods
    # logger.info("\nSetting operational mode to 'Summer 40kWh'...")
    # response = await sigen.set_operational_mode_summer_40kwh()
    # logger.info(f"Response: {response}")
    
    # For custom modes - using direct method with profile ID
    # logger.info("\nSetting operational mode to custom profile ID 4326...")
    # response = await sigen.set_operational_mode(9, 4326)  # 9 for custom modes with profile ID
    # logger.info(f"Response: {response}")
    # 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 including the new features:

2025-06-25 18:25:16 INFO Fetching station info...
2025-06-25 18:25:16 INFO Station ID: 2024052302935
2025-06-25 18:25:16 INFO Has PV: True
2025-06-25 18:25:16 INFO Has EV: False
2025-06-25 18:25:16 INFO Has AC Charger: True
2025-06-25 18:25:16 INFO On Grid: True
2025-06-25 18:25:16 INFO PV Capacity: 10.3 kW
2025-06-25 18:25:16 INFO Battery Capacity: 8.06 kWh

2025-06-25 18:25:17 INFO Fetching all available operational modes...

2025-06-25 18:25:17 INFO Default Working Modes:
2025-06-25 18:25:17 INFO   - Sigen AI Mode (value: 1)
2025-06-25 18:25:17 INFO   - Maximum Self-Powered (value: 0)
2025-06-25 18:25:17 INFO   - TOU (value: 2)
2025-06-25 18:25:17 INFO   - Fully Fed to Grid (value: 5)
2025-06-25 18:25:17 INFO   - Remote EMS Mode (value: 7)

2025-06-25 18:25:17 INFO Custom Energy Profile Items:
2025-06-25 18:25:17 INFO   - Summer 50kWh (profileId: 3126, value: 9)
2025-06-25 18:25:17 INFO   - Storm Ready (profileId: 3939, value: 9)
2025-06-25 18:25:17 INFO   - Summer 40kWh (profileId: 4326, value: 9)
2025-06-25 18:25:17 INFO   - Summer 30kWh (profileId: 4328, value: 9)

2025-06-25 18:25:17 INFO Current Operational Mode: TOU

2025-06-25 18:25:19 INFO --------- Smart Loads Functionality ---------
2025-06-25 18:25:19 INFO Fetching smart loads...
2025-06-25 18:25:19 INFO Found 1 smart loads:
2025-06-25 18:25:19 INFO   - Name: Immersion
2025-06-25 18:25:19 INFO     Path: 1
2025-06-25 18:25:19 INFO     Power: 0.00 kW
2025-06-25 18:25:19 INFO     Current state: ON
2025-06-25 18:25:19 INFO     Enable method: sigen.enable_smart_load_immersion()
2025-06-25 18:25:19 INFO     Disable method: sigen.disable_smart_load_immersion()

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sigen-3.0.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sigen-3.0.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for sigen-3.0.1.tar.gz
Algorithm Hash digest
SHA256 0fdcffac1ffa52a896ddab705bc31a615ad3dc799b245ebb0e3d2d7b0c7b361b
MD5 8d4973e2189fad1a11cc80f6877aff28
BLAKE2b-256 b4c3a06af178137b06c38dffbd400e1dff906b8dac825ef366c1ea133963a3b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sigen-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for sigen-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5a667735f9dfd901b209aa3ec96449f3f51742ef1af1f29d12baaff14317c4a
MD5 fef84940cf9afd32e317de5acf359bd2
BLAKE2b-256 015144eac770427554c66e93fa1356ce5ee6f7ec49b45d1b8f2230eb605005cd

See more details on using hashes here.

Supported by

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