Skip to main content

HYXI Cloud API

hyxi-cloud-api

PyPI Python Downloads License

Tests Coverage Security OpenSSF Scorecard


An asynchronous Python client for interacting with the HYXI Cloud API.

This library was primarily built to power the HYXI Cloud Home Assistant Integration, but it can be used in any Python 3.14 project to fetch telemetry data from HYXI solar inverters and battery systems.

📦 Installation

You can install the package directly from PyPI:

pip install hyxi-cloud-api

🚀 Quick Start

This library uses aiohttp for non-blocking network requests. You will need to provide your Developer API credentials (AK/SK), along with an active aiohttp.ClientSession.

import asyncio
import aiohttp
from hyxi_cloud_api import HyxiApiClient


async def main():
    # Replace with your actual HYXi Cloud credentials
    ACCESS_KEY = "your_access_key"
    SECRET_KEY = "your_secret_key"
    BASE_URL = "https://open.hyxicloud.com"

    async with aiohttp.ClientSession() as session:
        # 1. Initialize the client
        client = HyxiApiClient(
            access_key=ACCESS_KEY,
            secret_key=SECRET_KEY,
            base_url=BASE_URL,
            session=session,
        )

        # 2. Fetch device data
        try:
            device_data = await client.get_all_device_data()
            print("Successfully fetched HYXi data:")
            print(device_data)
        except Exception as e:
            print(f"Error communicating with HYXi Cloud: {e}")


if __name__ == "__main__":
    asyncio.run(main())

HYXI Open API base URLs vary by region. The examples in this README use the Europe endpoint by default.

Node Request Address
China https://open-cn.hyxicloud.com
Europe (default) https://open.hyxicloud.com
North America https://open-or.hyxicloud.com

🔧 Device Control

You can control inverter operating modes directly through the API. This requires a device serial number, which you can obtain from the device data response above.

async def control_example(client, device_sn):
    # Set operating mode
    await client.set_mode_self_consume(device_sn)
    await client.set_mode_self_consume_with_charging(device_sn)
    await client.set_mode_charge(device_sn, watts=3000)
    await client.set_mode_discharge(device_sn, watts=2500)
    await client.set_mode_idle(device_sn)

    # Peak shaving (close, charge, discharge, stop, hold)
    await client.set_peak_shaving(device_sn, action="charge")

    # Frequency control
    await client.set_frequency_control(device_sn, enabled=True)

Control failures raise HyxiApiClient.ControlError:

try:
    await client.set_mode_charge(device_sn, watts=3000)
except client.ControlNotForwardedError as e:
    print(f"Accepted but not forwarded to the device: {e}")
except client.ControlError as e:
    print(f"Control command failed: {e}")

HYXI only forwards its VPP control commands (controlIds 1062-1068; the set_mode_* helpers send 1062-1066) to devices the credentials are VPP-authorized for. With other credentials HYXI accepts the request but answers with a traceId of "SKIPPED" and never sends it on; the client raises ControlNotForwardedError, a subclass of ControlError, in that case, with HYXI's answer (including its requestId) in its response attribute.

Control commands are fire-and-forget; poll query_control_result with the traceId from the response to confirm the device actually applied it:

response = await client.set_mode_charge(device_sn, watts=3000)
trace_id = response["data"][0]["traceId"]

result = await client.query_control_result(trace_id)
# result["data"]["result"]: "2" (issuing), "3" (success), "6" (failure)

🔔 Subscriptions

You can subscribe a callback URL to HYXI push notifications for real-time data, alarms, and FCAS/frequency-modulation real-time data.

async def subscription_example(client):
    callback_url = "https://your-public-callback-host/hyxi/callback"
    device_sns = ["60700000000001", "60700000000002"]

    real_time = await client.subscribe_real_time_data(
        callback_url,
        device_sns,
        post_rate=60000,  # milliseconds, 5000-3600000
    )

    alarm = await client.subscribe_alarm(
        callback_url,
        device_sns,
        post_rate=60000,  # milliseconds, 5000-3600000
    )

    fcas = await client.subscribe_fm_real_time_data(
        callback_url,
        device_sns,
        post_rate=1,  # hours, 1-6
    )

    await client.cancel_subscription(real_time["data"]["subscribeCode"])

list_subscriptions() returns the subscriptions HYXI holds for your credentials; pass a device_sn to list only those associated with that device. For example, to see which of them deliver to your callback URL:

async def my_subscriptions(client, callback_url):
    return [
        sub
        for sub in await client.list_subscriptions()
        if sub.callback_url == callback_url
    ]

Each entry is a Subscription with its subscribe_code (for cancel_subscription), subscribe_type (a SubscriptionType, such as SubscriptionType.ALARM), callback_url, create_time and associated devices.

Subscription failures raise HyxiApiClient.SubscriptionError.

🛠️ Requirements

  • Python 3.14 (not yet 3.15 — the upper bound lifts once 3.15 is covered by CI)
  • aiohttp >= 3.13.5

🔐 Privacy & Debug Logging

When debug logging is enabled, this library automatically masks sensitive identifiers before writing them to the log — no manual redaction needed.

Field Behaviour
Serial numbers (deviceSn, parentSn, batSn) Hashed securely using SHA-256 (first 8 chars shown) to enable deterministic cross-device tracing without exposing the original identifier, e.g. e3b0c442
Plant IDs (plantId) Same SHA-256 hashing format
Home/site address (plantAddress) Fully redacted → [REDACTED]
IMEI (gprsImei) Same SHA-256 hashing format

Masking is deterministic, so parent/child device relationships remain traceable across log lines.

⚠️ Disclaimer

This is an unofficial, community-driven project. It is not affiliated with, endorsed by, or connected to HYXiPower in any official capacity. Use this software at your own risk.

Support

If this library is useful to you and you'd like to support its development:

Buy Me a Coffee

Metadata

Release files for hyxi-cloud-api 1.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hyxi-cloud-api 1.5.2
File Size Uploaded
hyxi_cloud_api-1.5.2.tar.gz 111.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hyxi-cloud-api 1.5.2
File Interpreter ABI Platform
hyxi_cloud_api-1.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 152.1 kB

Release files / hyxi_cloud_api-1.5.2.tar.gz

Download URL hyxi_cloud_api-1.5.2.tar.gz
Size 111.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4f30808ccbb4de0b690b4d03153e5308fea8d6f6d7daa0d9c29317aa32610816
BLAKE2b-256 checksum
How to use checksums
cf0ca63023823d8d6e383db22c050fe7c1727f0b83e5311421c68c3553628942
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / hyxi_cloud_api-1.5.2-py3-none-any.whl

Download URL hyxi_cloud_api-1.5.2-py3-none-any.whl
Size 41.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
004ccea0bec27576acf88a84d12737a46bcdb4a9eee737d4025958173efc813d
BLAKE2b-256 checksum
How to use checksums
f04207674631974c3dfa5aa0a0123c2c61bbcbc4d8ad88068d7e111efff8a854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

1.5.6

2 release files

1.5.5

2 release files

1.5.4

2 release files

1.5.3

2 release files

This release

1.5.2 This release

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.9

2 release files

1.4.8

2 release files

1.4.7

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.9

2 release files

1.3.8

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page