Skip to main content

An async API client for HYXi Cloud.

Project description

hyxi-cloud-api

Security Shield PyPI version CI/CD Pipeline Python Versions OpenSSF Baseline

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.

[!NOTE] The HYXI Open API requires a separate developer account registered at open.hyxicloud.com. If your developer email is different from your main HYXI app account, you must Share your Plant from the app to your developer email address to access your data.

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_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.ControlError as e:
    print(f"Control command failed: {e}")

🔔 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"])

Subscription failures raise HyxiApiClient.SubscriptionError.

🛠️ Requirements

  • Python 3.14 or newer
  • aiohttp >= 3.13.3

🔐 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.

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

hyxi_cloud_api-1.3.0.tar.gz (59.8 kB view details)

Uploaded Source

Built Distribution

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

hyxi_cloud_api-1.3.0-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file hyxi_cloud_api-1.3.0.tar.gz.

File metadata

  • Download URL: hyxi_cloud_api-1.3.0.tar.gz
  • Upload date:
  • Size: 59.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hyxi_cloud_api-1.3.0.tar.gz
Algorithm Hash digest
SHA256 6531ee88731c24850465dcd8c128cf3de945128c9feb6817fdde8ddae95eed67
MD5 5469aefcfe8798007a5eb5f9d434a5a9
BLAKE2b-256 2cbb48ccc54cc604a7fd17d2d9655fe04419906d8ad18fa58064907ec1d37b0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyxi_cloud_api-1.3.0.tar.gz:

Publisher: ci-cd.yml on Veldkornet/hyxi-cloud-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hyxi_cloud_api-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: hyxi_cloud_api-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hyxi_cloud_api-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b8a4db9a6ea4c5fdfeaf4665b33e8c4670f3d4247d312f570a664289a4cbe81
MD5 3087fb07204123506767672441448391
BLAKE2b-256 0f47cfa710376461d36755c06620aa077ab4d83c63ca022fb56310efcd596a75

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyxi_cloud_api-1.3.0-py3-none-any.whl:

Publisher: ci-cd.yml on Veldkornet/hyxi-cloud-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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