Skip to main content

ConnectLife Cloud API client library for Home Assistant integrations

Project description

ConnectLife Cloud API Client

A Python client library for the ConnectLife Cloud API, designed for Home Assistant integrations.

Features

  • Async/await support
  • Full type hints
  • Comprehensive error handling
  • Device management
  • Real-time status updates
  • Power consumption tracking
  • Self-check diagnostics

Installation

pip install connectlife-cloud

Usage

import asyncio
from connectlife_cloud import ConnectLifeCloudClient

async def main():
    client = ConnectLifeCloudClient(
        client_id="your_client_id",
        client_secret="your_client_secret"
    )
    
    try:
        # Get devices
        devices = await client.get_devices(access_token="your_token")
        print(f"Found {len(devices)} devices")
        
        # Control a device
        result = await client.control_device(
            puid="device_puid",
            properties={"power": True, "mode": "cool"},
            access_token="your_token"
        )
        print(f"Control result: {result}")
        
    finally:
        await client.close()

asyncio.run(main())

API Reference

ConnectLifeCloudClient

The main client class for interacting with the ConnectLife Cloud API.

Methods

  • get_devices(access_token): Get list of devices
  • control_device(puid, properties, access_token): Control a device
  • get_property_list(device_type_code, device_feature_code, access_token): Get device properties
  • query_static_data(puid, access_token): Query static device data
  • get_hour_power(date, puid, access_token): Get hourly power consumption
  • get_self_check(no_record, puid, access_token): Get device self-check info
  • get_devices_with_parsers(access_token): Get devices with their parsers
  • parse_device_status(device_id, status): Parse device status using appropriate parser

Mode Converter

Utilities for converting device mode descriptions (Chinese or English) to standard Home Assistant strings.

HVAC Mode Functions:

  • convert_mode_to_ha_string(mode_description): Convert HVAC mode description to HA standard string
  • get_ha_mode_string(value_map, device_value): Get HA HVAC mode string from device value map
  • find_device_value_for_ha_mode(value_map, ha_mode_string): Find device value for given HA mode (reverse lookup)

Fan Mode Functions:

  • convert_fan_mode_to_ha_string(fan_description): Convert fan mode description to HA standard string
  • get_ha_fan_mode_string(value_map, device_value): Get HA fan mode string from device value map
  • find_device_value_for_ha_fan_mode(value_map, ha_fan_mode_string): Find device value for given HA fan mode (reverse lookup)

The library handles bilingual support internally, converting Chinese descriptions (自动, 制冷, 制热, etc.) to standard English strings that can be directly used with Home Assistant enums like HVACMode("auto").

License

MIT License

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

connectlife_cloud-0.3.12.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

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

connectlife_cloud-0.3.12-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file connectlife_cloud-0.3.12.tar.gz.

File metadata

  • Download URL: connectlife_cloud-0.3.12.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for connectlife_cloud-0.3.12.tar.gz
Algorithm Hash digest
SHA256 043da967a5d81c51249b35aab7df4a4d451d463c58d989bd915045c50d229eff
MD5 65339899be7dc63dace2c7020be766d0
BLAKE2b-256 f7b80c638b5f1b4317f4adaf7ee6aa092dd34226b3192a07a8e828db1ef77b97

See more details on using hashes here.

File details

Details for the file connectlife_cloud-0.3.12-py3-none-any.whl.

File metadata

File hashes

Hashes for connectlife_cloud-0.3.12-py3-none-any.whl
Algorithm Hash digest
SHA256 9993d9c21ae6c3a9921fbbcf7ba8ee0bb6c868d510ec66c69cd263440c8dfa86
MD5 6bcb1bf886bbb2e3579fc09997e7a409
BLAKE2b-256 4141b8d99563a5f66c68694b8d5b32b42db5b231cb8cb2b4fc947401b019e42e

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