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="your_username", password="your_password")
# Read data
print(sigen.fetch_station_info())
print(sigen.get_energy_flow())
print(sigen.get_operational_mode())
# Set modes
print(sigen.set_operational_mode_sigen_ai_mode())
print(sigen.set_operational_mode_maximum_self_powered())
print(sigen.set_operational_mode_tou())
print(sigen.set_operational_fully_fed_to_grid())
Full example:
import logging
import coloredlogs
import os
from sigen import Sigen
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
# Initialize logging
coloredlogs.install(level='INFO')
sigen = Sigen(username=username, password=password)
# Fetch and log station info
logging.info("Fetching station info...")
station_info = sigen.fetch_station_info()
logging.info("Station Info:")
logging.info(f"Station ID: {station_info['stationId']}")
logging.info(f"Has PV: {station_info['hasPv']}")
logging.info(f"Has EV: {station_info['hasEv']}")
logging.info(f"On Grid: {station_info['onGrid']}")
logging.info(f"PV Capacity: {station_info['pvCapacity']} kW")
logging.info(f"Battery Capacity: {station_info['batteryCapacity']} kWh")
# Fetch and log energy flow info
logging.info("\nFetching energy flow info...")
energy_flow = sigen.get_energy_flow()
logging.info("Energy Flow Info:")
logging.info(f"PV Day Energy: {energy_flow['pvDayNrg']} kWh")
logging.info(f"PV Power: {energy_flow['pvPower']} kW")
logging.info(f"Buy/Sell Power: {energy_flow['buySellPower']} kW")
logging.info(f"EV Power: {energy_flow['evPower']} kW")
logging.info(f"AC Power: {energy_flow['acPower']} kW")
logging.info(f"Load Power: {energy_flow['loadPower']} kW")
logging.info(f"Battery Power: {energy_flow['batteryPower']} kW")
logging.info(f"Battery SOC: {energy_flow['batterySoc']}%")
# Fetch and log current operational mode
logging.info("\nFetching current operational mode...")
current_mode = sigen.get_operational_mode()
logging.info(f"Current Operational Mode: {current_mode}")
# Change operational mode (example: setting mode to 'Fully Fed to Grid')
logging.info("\nSetting operational mode to 'Fully Fed to Grid'...")
response = sigen.set_operational_mode(5)
logging.info(f"Response: {response}")
logging.info("\nFetching current operational mode...")
current_mode = sigen.get_operational_mode()
logging.info(f"Current Operational Mode: {current_mode}")
if __name__ == "__main__":
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.6.tar.gz
(5.6 kB
view details)
Built Distribution
sigen-0.1.6-py3-none-any.whl
(4.8 kB
view details)
File details
Details for the file sigen-0.1.6.tar.gz
.
File metadata
- Download URL: sigen-0.1.6.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 | c6991d37cf92124fdbe546e441497492f8f3cbee576d9f0e766a5636a825ec7e |
|
MD5 | e20f37b429f5ef2b968d3e714f76c6cb |
|
BLAKE2b-256 | a58cb592a0d6bcd5a145087e1a5f1aeaaea84cb0a26ac9d316fcfdf5f020304b |
File details
Details for the file sigen-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: sigen-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.8 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 | a1db789adbd72e2f436044619943b4c238134a33ff8cca4ff165b69c0be36222 |
|
MD5 | 0806f2e41192bed26e2a75afc7ba4b92 |
|
BLAKE2b-256 | 4d951750da023b9fcbb980a0b57c402fe37234c1238326cbb95d726663a62f70 |