fusion-solar-py


Namefusion-solar-py JSON
Version 0.0.26 PyPI version JSON
download
home_pagehttps://github.com/jgriss/FusionSolarPy
SummaryA simply API to the Huawei Fusion Solar web interface.
upload_time2024-08-13 19:22:25
maintainerNone
docs_urlNone
authorJohannes Griss
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Test Package](https://github.com/jgriss/FusionSolarPy/actions/workflows/test.yaml/badge.svg)](https://github.com/jgriss/FusionSolarPy/actions/workflows/test.yaml)
[![PyPI version](https://badge.fury.io/py/fusion_solar_py.svg)](https://badge.fury.io/py/fusion_solar_py)

# FusionSolarPy

A very basic python client for the HuaweiFusionSolar API used to monitor
solar power plants.

This client uses the https://region01eu5.fusionsolar.huawei.com end point by default. It is
possible to change this using the `huawei_subdomain` parameter. But this has not
been tested on any other end-points.

Please report any bugs!

## Installation

Simply install from pypi using:

```bash
pip install fusion_solar_py
```

By default, libraries required for solving CAPTCHAs are not installed. To also install
these requirements, use the command:

```bash
pip install fusion_solar_py[captcha]
```

Note that these require python >= 3.8

## Usage

The basic usage centers around the `FusionSolarClient` class. It currently
only has one method to extract the current power production, the total
power production for the current day, and the total energy ever produced
by the plant.

```python
from fusion_solar_py.client import FusionSolarClient

# log into the API - with proper credentials...
client = FusionSolarClient("my_user", "my_password")

# NOTE: Depending on your region, you may need to set the
# `huawei_subdomain` parameter. This is the first part of the
# URL when you enter the FusionSolar API through your webbrowser
#
# client = FusionSolarClient("my_user", "my_password", huawei_subdomain="region01eu5")

# get the stats
stats = client.get_power_status()

# print all stats
print(f"Current power: {stats.current_power_kw} kW")
print(f"Total energy today: {stats.energy_today_kwh} kWh")
print(f"Total energy: {stats.energy_kwh} kWh")

# NOTE: Since an update of the API, this data does no longer seem
#       to be up-to-date. The most recent data only seems to be
#       available on th plant level (see below)

# log out - just in case
client.log_out()
```

It is additional possible to retrieve the data for specific
plants - in case multiple plants are available through the
account.

```python
from fusion_solar_py.client import FusionSolarClient

# log into the API - with proper credentials...
client = client = FusionSolarClient(
  "my_user",
  "my_password",
  huawei_subdomain="subdomain"
)

# if you only need an overview of the current status of
# your plant(s) you can use the get_plant_list function
plant_overview = client.get_station_list()

# get the current power of your first plant
print(f"Current power production: { plant_overview[0]['currentPowwer'] }")

# alternatively, you can get time resolved data for each plant:

# get the plant ids
plant_ids = client.get_plant_ids()

print(f"Found {len(plant_ids)} plants")

# get the basic (current) overview data for the plant
plant_overview = client.get_current_plant_data(plant_ids[0])

print(str(plant_overview))

# get the data for the first plant
plant_data = client.get_plant_stats(plant_ids[0])

# plant_data is a dict that contains the complete
# usage statistics of the current day. There is
# a helper function available to extract some
# most recent measurements
last_values = client.get_last_plant_data(plant_data)

print(f"Last production at {last_values['productPower']['time']}: {last_values['productPower']['value']}")

# In case you have a battery installed
print(f"Last battery charge at {last_values['chargePower']['time']}: {last_values['chargePower']['value']}")

# Additionally, if you have a meter installed you can get additional statistics
print(f"Total power consumption (today): {last_values['totalUsePower']} kWh")
print(f"Total produced power (today): {last_values['totalPower']} kWh")
print(f"Produced power consumed (today): {last_values['totalSelfUsePower']} kWh")
print(f"Relative amount of used power bought from grid: {last_values['buyPowerRatio']}%")

# print all optimizer stats
for x in client.get_optimizer_stats(client.get_device_ids()['Inverter']):
    print(f"{x['optName']}: {x['moStatus']} {x['runningStatus']}: {x['outputPower']} W /" +
          f" {x['inputVoltage']} V / {x['inputCurrent']} A / {x['temperature']} C")


# log out - just in case
client.log_out()
```

### New uni000 subdomains

It seems that some accounts are currently being moved to a new version of the web application. These can be recognized by the new "uni...eu5" subdomain (f.e. `uni002eu5`).

This new version apparently requires a new login procedure which is supported since version 0.0.19. Yet, it is unclear whther the Captcha solving also still works. Finally, other features may be affected as well. Therefore, in case your account was moved to a "uni..." subdomain and you experience issues, please post a respective [Issue](https://github.com/jgriss/FusionSolarPy/issues).

### Captcha solving

Sometimes, if logging in too often, the API will return a captcha. If you let your script run continuously, you shouldn't run into this issue. In case you rerun the script often, providing a captcha solver resolves this issue.

By default, the requirements to solve CAPTCHAs are not insalled. To install them, use

```bash
pip install fusion_solar_py[captcha]
```

Note that these require python >= 3.8

#### Simple usage
1. Download the weights of the captcha solver [captcha_huawei.onnx](models/captcha_huawei.onnx) and save it somewhere you can find it again.
2. Pass the path to the weights to the client in the `captcha_model_path` parameter.

```python
from fusion_solar_py.client import FusionSolarClient

client = FusionSolarClient(
    'my_user',
    'my_password',
    captcha_model_path="C:/Users/user/models/captcha_huawei.onnx"
)
```
By default, the captcha solver will use the CPU for inference, which should be fast enough (~200ms). If you want to use the GPU, please refer to the [onnx documentation](https://onnxruntime.ai/docs/execution-providers/) on how to install the necessary packages.
You can pass the device configuration via the `captcha_device` parameter.

Example:
```python
from fusion_solar_py.client import FusionSolarClient

# Using GPU if available, otherwise CPU
client = FusionSolarClient(
    'my_user',
    'my_password',
    captcha_model_path="C:/Users/user/models/captcha_huawei.onnx",
    captcha_device=['CUDAExecutionProvider', 'CPUExecutionProvider']
)
```

### Session reuse

In case you have to reestablish the connection to the API many times (e.g. for usage with Telegraf), you might want to reuse the session. This can be done by passing the `session` parameter to the client. The session needs to be a `requests.Session` object. If you don't pass a session, a new one will be created.
Reusing a session will significantly reduce the chance of getting a captcha, since the API counts logins, not hits for rate limiting.

```python
import requests
import pickle
from fusion_solar_py.client import FusionSolarClient

session = requests.Session()
client = FusionSolarClient(
    'my_user',
    'my_password',
    session=session
)

# To save the session for later use (e.g. if you have to run the script multiple times), you can use pickle and save the session to the disk
with open('session.pkl', 'wb') as f:
    pickle.dump(session, f)

# To load the session, you can use pickle again
with open('session.pkl', 'rb') as f:
    session = pickle.load(f)
```

### Keeping a session alive

The new API version seems to use explicit functions to keep a session alive. Their usage is currently only derived from the web application. In order to support these calls, two new functions were added to the library in version 0.0.23.

  * **is_session_active**: This checks, whether the session is still active and should be called around every 10 seconds.
  * **keep_alive**: Potentially, this call tells the API to no discard the session. The web app calls this end-point around every 30 seconds.

## Available plant data / stats

This is a list of variables and a (guessed) explanation of what they mean returnd from
`get_plant_stats` and as an abbreviated version by `get_last_plant_data`.

### Total values

These values are always the total (in kWh) for the current day:

  * **totalSelfUsePower**: Total kWh of the current day's production used.
  * **selfProvide**: Total kWh of the current day's production used (same as above).
  * **totalBuyPower**: Total kWh bought from the grid today.
  * **totalProductPower**: Total kWh produced by the PV today.
  * **totalUsePower**: Total kWh used today.
  * **totalOnGridPower**: Total kWh returned to the grid today.

### Ratios

Ratios are given in percent (f.e. "35.93" for a ratio of 0.3593)

  * **onGridPowerRatio**: Proportion of today's PV production returned to the grid.
  * **buyPowerRatio**: Proportion of power consumed today that was bought from the grid.
  * **selfUsePowerRatioByProduct**: Proportion of produced power used.

### Logicals

  * **existInverter**: (Boolean) Set if an inverter (ie a PV plant) is installed
  * **existCharge**: (Boolean) - Maybe true if currently charging.
  * **existMeter**: (Boolean) Set if a meter is installed.
  * **existEnergyStore**: (Boolean) - Maybe true if a storage is installed.
  * **existUsePower**: (Boolean) - Maybe true if the own power is used.

### Timecourses

These are returned as lists of values. The matching timepoints are found in the
`xAxis` list. `get_last_plant_data` returns these values as a dict with the key
`time` and `value` representing the last valid measurement (ie. not "--").

  * **selfUsePower**: Amount of energy produced by the PV used.
  * **dischargePower**: Amounf of energy discharged from the storage.
  * **chargePower**: Amount of energy charged into the storage.
  * **onGridPower**: (Probably) The amount of power returned to the grid.
  * **disGridPower**: (Probably) The amount of power taken from the grid.
  * **productPower**: Amounf of power produced by the PV.
  * **usePower**: Amount of power used.

## Available battery stats

### [get_battery_ids(plant_id)](src/fusion_solar_py/client.py#L417)

This function returns a list of battery IDs from the given plant. The returned battery ID is used for the other battery functions.

### [get_battery_basic_stats(battery_id)](src/fusion_solar_py/client.py#L433)

This function returns a `BatteryStatus` object. It takes the information from [get_battery_status(battery_id)](#get_battery_status(battery_id)) and just provides an easy wrapper, similar to [get_power_status()](src/fusion_solar_py/client.py#L325). It contains the following information:

* **`rated_capacity`**: The total capacity of the battery in kWh
* **`operating_status`**: The current operating status of the battery
* **`backup_time`**: The time the battery can run on its own (we think - our battery doesn't have this value)
* **`bus_voltage`**: The current bus voltage in V
* **`total_charged_today_kwh`**: The total amount of energy charged today in kWh
* **`total_discharged_today_kwh`**: The total amount of energy discharged today in kWh
* **`current_charge_discharge_kw`**: The current charge/discharge power in kW


### [get_battery_day_stats(battery_id)](src/fusion_solar_py/client.py#L454)

This function returns a list of dicts, where each dict is a timestamp. Each dict is 5 minutes apart. It contains **charge/discharge power** and **state of charge (SOC)**
<details>
<summary>Example output</summary>

```python
{
    '30005': {
        'pmDataList': [
            {
                'counterId': 30005,
                'counterValue': -0.262,  # Negative means discharge, positive means charge
                'dnId': 123456,  # Battery ID
                'dstOffset': 60,
                'period': 300,
                'startTime': 1694988000,  # UNIX timestamp
                'timeZoneOffset': 60
            },
            ...
        ],
        'total': int,
        'name': 'Charge/Discharge power'
    },
    '30007': {
        'pmDataList': [
            {
                'counterId': 30007,
                'counterValue': 56.0,  # SOC in %
                'dnId': 123456,  # Battery ID
                'dstOffset': 60,
                'period': 300,
                'startTime': 1694988000,  # UNIX timestamp
                'timeZoneOffset': 60
            },
            ...
        ],
        'total': int,
        'name': 'SOC'
    }
}
```
</details>

### [get_battery_module_stats(battery_id, module_id="1", signal_ids=None)](src/fusion_solar_py/client.py#L486)

This function retrieves the complete stats for the given battery module of the latest recorded time. It returns a list of dicts. For the details of the dicts, please see [signals.md](signals.md)


### [get_battery_status(battery_id)](src/fusion_solar_py/client.py#L528)

This function retrieves the current status of the battery. It returns a list of dicts. We haven't figured out the meaning of all the modes yet.

* **Battery operating status**
* **Charge/Discharge mode**
* **Rated capacity**: Probably the total capacity of the battery in kWh
* **Backup time**: Probably the time the battery can run on its own
* **Energy charged today**: The total amount of energy charged today in kWh
* **Energy discharged today**: The total amount of energy discharged today in kWh
* **Charge/Discharge power**: The current charge/discharge power in kW
* **Bus voltage**: The current bus voltage in V
* **SOC**: The current state of charge in %

<details>
  <summary>Example output</summary>

```python
[
    {
        'id': 10003,
        'latestTime': 1695047841,
        'name': 'Battery operating status',
        'realValue': '2',
        'unit': '',
        'value': 'Operating'
    },
    {
        'id': 10008,
        'latestTime': 1695047841,
        'name': 'Charge/Discharge mode',
        'realValue': '4',
        'unit': '',
        'value': 'Maximum self-consumption'
    },
    {
        'id': 10013,
        'latestTime': 1695062404,
        'name': 'Rated capacity',
        'realValue': '5.000',
        'unit': 'kWh',
        'value': '5.000'
    },
    {
        'id': 10015,
        'latestTime': 1695062404,
        'name': 'Backup time',
        'realValue': 'N/A',
        'unit': 'min',
        'value': '-'
    },
    {
        'id': 10001,
        'latestTime': 1695062404,
        'name': 'Energy charged today',
        'realValue': '3.72',
        'unit': 'kWh',
        'value': '3.72'
    },
    {
        'id': 10002,
        'latestTime': 1695062404,
        'name': 'Energy discharged today',
        'realValue': '4.83',
        'unit': 'kWh',
        'value': '4.83'
    },
    {
        'id': 10004,
        'latestTime': 1695062404,
        'name': 'Charge/Discharge power',
        'realValue': '-0.485',
        'unit': 'kW',
        'value': '-0.485'
    },
    {
        'id': 10005,
        'latestTime': 1695062404,
        'name': 'Bus voltage',
        'realValue': '766.7',
        'unit': 'V',
        'value': '766.7'
    },
    {
        'id': 10006,
        'latestTime': 1695062404,
        'name': 'SOC',
        'realValue': '31.0',
        'unit': '%',
        'value': '31.0'
    }
]
```
</details>


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jgriss/FusionSolarPy",
    "name": "fusion-solar-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Johannes Griss",
    "author_email": "johannes.griss@meduniwien.ac.at",
    "download_url": "https://files.pythonhosted.org/packages/54/eb/c020894dabbb6f60638bbe89e7a6c2f42d8b508835c48c9a04e36a119532/fusion_solar_py-0.0.26.tar.gz",
    "platform": null,
    "description": "[![Test Package](https://github.com/jgriss/FusionSolarPy/actions/workflows/test.yaml/badge.svg)](https://github.com/jgriss/FusionSolarPy/actions/workflows/test.yaml)\n[![PyPI version](https://badge.fury.io/py/fusion_solar_py.svg)](https://badge.fury.io/py/fusion_solar_py)\n\n# FusionSolarPy\n\nA very basic python client for the HuaweiFusionSolar API used to monitor\nsolar power plants.\n\nThis client uses the https://region01eu5.fusionsolar.huawei.com end point by default. It is\npossible to change this using the `huawei_subdomain` parameter. But this has not\nbeen tested on any other end-points.\n\nPlease report any bugs!\n\n## Installation\n\nSimply install from pypi using:\n\n```bash\npip install fusion_solar_py\n```\n\nBy default, libraries required for solving CAPTCHAs are not installed. To also install\nthese requirements, use the command:\n\n```bash\npip install fusion_solar_py[captcha]\n```\n\nNote that these require python >= 3.8\n\n## Usage\n\nThe basic usage centers around the `FusionSolarClient` class. It currently\nonly has one method to extract the current power production, the total\npower production for the current day, and the total energy ever produced\nby the plant.\n\n```python\nfrom fusion_solar_py.client import FusionSolarClient\n\n# log into the API - with proper credentials...\nclient = FusionSolarClient(\"my_user\", \"my_password\")\n\n# NOTE: Depending on your region, you may need to set the\n# `huawei_subdomain` parameter. This is the first part of the\n# URL when you enter the FusionSolar API through your webbrowser\n#\n# client = FusionSolarClient(\"my_user\", \"my_password\", huawei_subdomain=\"region01eu5\")\n\n# get the stats\nstats = client.get_power_status()\n\n# print all stats\nprint(f\"Current power: {stats.current_power_kw} kW\")\nprint(f\"Total energy today: {stats.energy_today_kwh} kWh\")\nprint(f\"Total energy: {stats.energy_kwh} kWh\")\n\n# NOTE: Since an update of the API, this data does no longer seem\n#       to be up-to-date. The most recent data only seems to be\n#       available on th plant level (see below)\n\n# log out - just in case\nclient.log_out()\n```\n\nIt is additional possible to retrieve the data for specific\nplants - in case multiple plants are available through the\naccount.\n\n```python\nfrom fusion_solar_py.client import FusionSolarClient\n\n# log into the API - with proper credentials...\nclient = client = FusionSolarClient(\n  \"my_user\",\n  \"my_password\",\n  huawei_subdomain=\"subdomain\"\n)\n\n# if you only need an overview of the current status of\n# your plant(s) you can use the get_plant_list function\nplant_overview = client.get_station_list()\n\n# get the current power of your first plant\nprint(f\"Current power production: { plant_overview[0]['currentPowwer'] }\")\n\n# alternatively, you can get time resolved data for each plant:\n\n# get the plant ids\nplant_ids = client.get_plant_ids()\n\nprint(f\"Found {len(plant_ids)} plants\")\n\n# get the basic (current) overview data for the plant\nplant_overview = client.get_current_plant_data(plant_ids[0])\n\nprint(str(plant_overview))\n\n# get the data for the first plant\nplant_data = client.get_plant_stats(plant_ids[0])\n\n# plant_data is a dict that contains the complete\n# usage statistics of the current day. There is\n# a helper function available to extract some\n# most recent measurements\nlast_values = client.get_last_plant_data(plant_data)\n\nprint(f\"Last production at {last_values['productPower']['time']}: {last_values['productPower']['value']}\")\n\n# In case you have a battery installed\nprint(f\"Last battery charge at {last_values['chargePower']['time']}: {last_values['chargePower']['value']}\")\n\n# Additionally, if you have a meter installed you can get additional statistics\nprint(f\"Total power consumption (today): {last_values['totalUsePower']} kWh\")\nprint(f\"Total produced power (today): {last_values['totalPower']} kWh\")\nprint(f\"Produced power consumed (today): {last_values['totalSelfUsePower']} kWh\")\nprint(f\"Relative amount of used power bought from grid: {last_values['buyPowerRatio']}%\")\n\n# print all optimizer stats\nfor x in client.get_optimizer_stats(client.get_device_ids()['Inverter']):\n    print(f\"{x['optName']}: {x['moStatus']} {x['runningStatus']}: {x['outputPower']} W /\" +\n          f\" {x['inputVoltage']} V / {x['inputCurrent']} A / {x['temperature']} C\")\n\n\n# log out - just in case\nclient.log_out()\n```\n\n### New uni000 subdomains\n\nIt seems that some accounts are currently being moved to a new version of the web application. These can be recognized by the new \"uni...eu5\" subdomain (f.e. `uni002eu5`).\n\nThis new version apparently requires a new login procedure which is supported since version 0.0.19. Yet, it is unclear whther the Captcha solving also still works. Finally, other features may be affected as well. Therefore, in case your account was moved to a \"uni...\" subdomain and you experience issues, please post a respective [Issue](https://github.com/jgriss/FusionSolarPy/issues).\n\n### Captcha solving\n\nSometimes, if logging in too often, the API will return a captcha. If you let your script run continuously, you shouldn't run into this issue. In case you rerun the script often, providing a captcha solver resolves this issue.\n\nBy default, the requirements to solve CAPTCHAs are not insalled. To install them, use\n\n```bash\npip install fusion_solar_py[captcha]\n```\n\nNote that these require python >= 3.8\n\n#### Simple usage\n1. Download the weights of the captcha solver [captcha_huawei.onnx](models/captcha_huawei.onnx) and save it somewhere you can find it again.\n2. Pass the path to the weights to the client in the `captcha_model_path` parameter.\n\n```python\nfrom fusion_solar_py.client import FusionSolarClient\n\nclient = FusionSolarClient(\n    'my_user',\n    'my_password',\n    captcha_model_path=\"C:/Users/user/models/captcha_huawei.onnx\"\n)\n```\nBy default, the captcha solver will use the CPU for inference, which should be fast enough (~200ms). If you want to use the GPU, please refer to the [onnx documentation](https://onnxruntime.ai/docs/execution-providers/) on how to install the necessary packages.\nYou can pass the device configuration via the `captcha_device` parameter.\n\nExample:\n```python\nfrom fusion_solar_py.client import FusionSolarClient\n\n# Using GPU if available, otherwise CPU\nclient = FusionSolarClient(\n    'my_user',\n    'my_password',\n    captcha_model_path=\"C:/Users/user/models/captcha_huawei.onnx\",\n    captcha_device=['CUDAExecutionProvider', 'CPUExecutionProvider']\n)\n```\n\n### Session reuse\n\nIn case you have to reestablish the connection to the API many times (e.g. for usage with Telegraf), you might want to reuse the session. This can be done by passing the `session` parameter to the client. The session needs to be a `requests.Session` object. If you don't pass a session, a new one will be created.\nReusing a session will significantly reduce the chance of getting a captcha, since the API counts logins, not hits for rate limiting.\n\n```python\nimport requests\nimport pickle\nfrom fusion_solar_py.client import FusionSolarClient\n\nsession = requests.Session()\nclient = FusionSolarClient(\n    'my_user',\n    'my_password',\n    session=session\n)\n\n# To save the session for later use (e.g. if you have to run the script multiple times), you can use pickle and save the session to the disk\nwith open('session.pkl', 'wb') as f:\n    pickle.dump(session, f)\n\n# To load the session, you can use pickle again\nwith open('session.pkl', 'rb') as f:\n    session = pickle.load(f)\n```\n\n### Keeping a session alive\n\nThe new API version seems to use explicit functions to keep a session alive. Their usage is currently only derived from the web application. In order to support these calls, two new functions were added to the library in version 0.0.23.\n\n  * **is_session_active**: This checks, whether the session is still active and should be called around every 10 seconds.\n  * **keep_alive**: Potentially, this call tells the API to no discard the session. The web app calls this end-point around every 30 seconds.\n\n## Available plant data / stats\n\nThis is a list of variables and a (guessed) explanation of what they mean returnd from\n`get_plant_stats` and as an abbreviated version by `get_last_plant_data`.\n\n### Total values\n\nThese values are always the total (in kWh) for the current day:\n\n  * **totalSelfUsePower**: Total kWh of the current day's production used.\n  * **selfProvide**: Total kWh of the current day's production used (same as above).\n  * **totalBuyPower**: Total kWh bought from the grid today.\n  * **totalProductPower**: Total kWh produced by the PV today.\n  * **totalUsePower**: Total kWh used today.\n  * **totalOnGridPower**: Total kWh returned to the grid today.\n\n### Ratios\n\nRatios are given in percent (f.e. \"35.93\" for a ratio of 0.3593)\n\n  * **onGridPowerRatio**: Proportion of today's PV production returned to the grid.\n  * **buyPowerRatio**: Proportion of power consumed today that was bought from the grid.\n  * **selfUsePowerRatioByProduct**: Proportion of produced power used.\n\n### Logicals\n\n  * **existInverter**: (Boolean) Set if an inverter (ie a PV plant) is installed\n  * **existCharge**: (Boolean) - Maybe true if currently charging.\n  * **existMeter**: (Boolean) Set if a meter is installed.\n  * **existEnergyStore**: (Boolean) - Maybe true if a storage is installed.\n  * **existUsePower**: (Boolean) - Maybe true if the own power is used.\n\n### Timecourses\n\nThese are returned as lists of values. The matching timepoints are found in the\n`xAxis` list. `get_last_plant_data` returns these values as a dict with the key\n`time` and `value` representing the last valid measurement (ie. not \"--\").\n\n  * **selfUsePower**: Amount of energy produced by the PV used.\n  * **dischargePower**: Amounf of energy discharged from the storage.\n  * **chargePower**: Amount of energy charged into the storage.\n  * **onGridPower**: (Probably) The amount of power returned to the grid.\n  * **disGridPower**: (Probably) The amount of power taken from the grid.\n  * **productPower**: Amounf of power produced by the PV.\n  * **usePower**: Amount of power used.\n\n## Available battery stats\n\n### [get_battery_ids(plant_id)](src/fusion_solar_py/client.py#L417)\n\nThis function returns a list of battery IDs from the given plant. The returned battery ID is used for the other battery functions.\n\n### [get_battery_basic_stats(battery_id)](src/fusion_solar_py/client.py#L433)\n\nThis function returns a `BatteryStatus` object. It takes the information from [get_battery_status(battery_id)](#get_battery_status(battery_id)) and just provides an easy wrapper, similar to [get_power_status()](src/fusion_solar_py/client.py#L325). It contains the following information:\n\n* **`rated_capacity`**: The total capacity of the battery in kWh\n* **`operating_status`**: The current operating status of the battery\n* **`backup_time`**: The time the battery can run on its own (we think - our battery doesn't have this value)\n* **`bus_voltage`**: The current bus voltage in V\n* **`total_charged_today_kwh`**: The total amount of energy charged today in kWh\n* **`total_discharged_today_kwh`**: The total amount of energy discharged today in kWh\n* **`current_charge_discharge_kw`**: The current charge/discharge power in kW\n\n\n### [get_battery_day_stats(battery_id)](src/fusion_solar_py/client.py#L454)\n\nThis function returns a list of dicts, where each dict is a timestamp. Each dict is 5 minutes apart. It contains **charge/discharge power** and **state of charge (SOC)**\n<details>\n<summary>Example output</summary>\n\n```python\n{\n    '30005': {\n        'pmDataList': [\n            {\n                'counterId': 30005,\n                'counterValue': -0.262,  # Negative means discharge, positive means charge\n                'dnId': 123456,  # Battery ID\n                'dstOffset': 60,\n                'period': 300,\n                'startTime': 1694988000,  # UNIX timestamp\n                'timeZoneOffset': 60\n            },\n            ...\n        ],\n        'total': int,\n        'name': 'Charge/Discharge power'\n    },\n    '30007': {\n        'pmDataList': [\n            {\n                'counterId': 30007,\n                'counterValue': 56.0,  # SOC in %\n                'dnId': 123456,  # Battery ID\n                'dstOffset': 60,\n                'period': 300,\n                'startTime': 1694988000,  # UNIX timestamp\n                'timeZoneOffset': 60\n            },\n            ...\n        ],\n        'total': int,\n        'name': 'SOC'\n    }\n}\n```\n</details>\n\n### [get_battery_module_stats(battery_id, module_id=\"1\", signal_ids=None)](src/fusion_solar_py/client.py#L486)\n\nThis function retrieves the complete stats for the given battery module of the latest recorded time. It returns a list of dicts. For the details of the dicts, please see [signals.md](signals.md)\n\n\n### [get_battery_status(battery_id)](src/fusion_solar_py/client.py#L528)\n\nThis function retrieves the current status of the battery. It returns a list of dicts. We haven't figured out the meaning of all the modes yet.\n\n* **Battery operating status**\n* **Charge/Discharge mode**\n* **Rated capacity**: Probably the total capacity of the battery in kWh\n* **Backup time**: Probably the time the battery can run on its own\n* **Energy charged today**: The total amount of energy charged today in kWh\n* **Energy discharged today**: The total amount of energy discharged today in kWh\n* **Charge/Discharge power**: The current charge/discharge power in kW\n* **Bus voltage**: The current bus voltage in V\n* **SOC**: The current state of charge in %\n\n<details>\n  <summary>Example output</summary>\n\n```python\n[\n    {\n        'id': 10003,\n        'latestTime': 1695047841,\n        'name': 'Battery operating status',\n        'realValue': '2',\n        'unit': '',\n        'value': 'Operating'\n    },\n    {\n        'id': 10008,\n        'latestTime': 1695047841,\n        'name': 'Charge/Discharge mode',\n        'realValue': '4',\n        'unit': '',\n        'value': 'Maximum self-consumption'\n    },\n    {\n        'id': 10013,\n        'latestTime': 1695062404,\n        'name': 'Rated capacity',\n        'realValue': '5.000',\n        'unit': 'kWh',\n        'value': '5.000'\n    },\n    {\n        'id': 10015,\n        'latestTime': 1695062404,\n        'name': 'Backup time',\n        'realValue': 'N/A',\n        'unit': 'min',\n        'value': '-'\n    },\n    {\n        'id': 10001,\n        'latestTime': 1695062404,\n        'name': 'Energy charged today',\n        'realValue': '3.72',\n        'unit': 'kWh',\n        'value': '3.72'\n    },\n    {\n        'id': 10002,\n        'latestTime': 1695062404,\n        'name': 'Energy discharged today',\n        'realValue': '4.83',\n        'unit': 'kWh',\n        'value': '4.83'\n    },\n    {\n        'id': 10004,\n        'latestTime': 1695062404,\n        'name': 'Charge/Discharge power',\n        'realValue': '-0.485',\n        'unit': 'kW',\n        'value': '-0.485'\n    },\n    {\n        'id': 10005,\n        'latestTime': 1695062404,\n        'name': 'Bus voltage',\n        'realValue': '766.7',\n        'unit': 'V',\n        'value': '766.7'\n    },\n    {\n        'id': 10006,\n        'latestTime': 1695062404,\n        'name': 'SOC',\n        'realValue': '31.0',\n        'unit': '%',\n        'value': '31.0'\n    }\n]\n```\n</details>\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A simply API to the Huawei Fusion Solar web interface.",
    "version": "0.0.26",
    "project_urls": {
        "Bug Tracker": "https://github.com/jgriss/FusionSolarPy/issues",
        "Homepage": "https://github.com/jgriss/FusionSolarPy"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d45ce78f44b26448ac379d1fcdfcb2307850ca94925294ad6925d6ad3628b4ee",
                "md5": "614edbf0f184021e1a3b4e6b168de393",
                "sha256": "558a5b7b1fd5ca07cbf3a99168037ddd3b8c12797c8bd4e0ddf88fe1c8a559e1"
            },
            "downloads": -1,
            "filename": "fusion_solar_py-0.0.26-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "614edbf0f184021e1a3b4e6b168de393",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 21886,
            "upload_time": "2024-08-13T19:22:24",
            "upload_time_iso_8601": "2024-08-13T19:22:24.430459Z",
            "url": "https://files.pythonhosted.org/packages/d4/5c/e78f44b26448ac379d1fcdfcb2307850ca94925294ad6925d6ad3628b4ee/fusion_solar_py-0.0.26-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54ebc020894dabbb6f60638bbe89e7a6c2f42d8b508835c48c9a04e36a119532",
                "md5": "f0fb9adcdc23deb18e350c378e1096e5",
                "sha256": "21ccfb819f96f185dcce55f5913a925e31641dd5f11e90af49aeab57a512f22d"
            },
            "downloads": -1,
            "filename": "fusion_solar_py-0.0.26.tar.gz",
            "has_sig": false,
            "md5_digest": "f0fb9adcdc23deb18e350c378e1096e5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 26828,
            "upload_time": "2024-08-13T19:22:25",
            "upload_time_iso_8601": "2024-08-13T19:22:25.831264Z",
            "url": "https://files.pythonhosted.org/packages/54/eb/c020894dabbb6f60638bbe89e7a6c2f42d8b508835c48c9a04e36a119532/fusion_solar_py-0.0.26.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-13 19:22:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jgriss",
    "github_project": "FusionSolarPy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "fusion-solar-py"
}
        
Elapsed time: 0.73779s