Skip to main content

Suning biu smart home SMS login and session client

Project description

python-xiaobiu

Python client for Suning smart home SMS login and session management.

Used by the ha-suning Home Assistant custom integration.

Install

pip install python-xiaobiu

Usage

from xiaobiu import CaptchaRequiredError, SuningSmartHomeClient

client = SuningSmartHomeClient(state_path=".suning-session.json")

try:
    client.send_sms_code("13800000000")
except CaptchaRequiredError as error:
    print(error.risk_type, error.sms_ticket)

client.login_with_sms_code(phone_number="13800000000", sms_code="123456")
print(client.list_family_infos())

Air Conditioner Control

Suning's "小标" App exposes a flat per-device control surface where every button on the AC card maps to a single C_* field on the appOper endpoint. This client mirrors that surface and aligns the typed layer with the Home Assistant climate entity.

from xiaobiu import (
  FanSpeed,
  HvacMode,
  PresetMode,
  SwingMode,
)

status = client.get_air_conditioner_status(
  family_id=37790,
  device_id="000165f9b029afa2e5d8",
)
print(status.hvac_mode)  # HvacMode.{OFF,COOL,HEAT,FAN_ONLY,DRY,AUTO,QUICK} or None

# Power
client.turn_on(family_id=37790, device_id="000165f9b029afa2e5d8")
client.turn_off(family_id=37790, device_id="000165f9b029afa2e5d8")

# Mode
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.COOL)   # 制冷
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.HEAT)   # 制热
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.FAN_ONLY)  # 送风
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.DRY)    # 除湿
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.AUTO)   # 自动
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.QUICK)  # 一键通 (C_MODE=5, 待实测确认)

# Temperature
client.set_temperature(family_id=37790, device_id="...", value=24.0)  # 16.0–32.0

# Fan (App 标签 / C_FANSPEED raw / HA fan_mode)
client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.AUTO)    # 自动   / 0 / auto
client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.SILENT)  # 微风   / 1 / silent
client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.LOW)     # 低风   / 2 / low
client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.MEDIUM)  # 中风   / 3 / medium
client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.HIGH)    # 高风   / 4 / high
client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.TURBO)   # 强风   / 5 / turbo

# Swing (vertical/horizontal can be toggled independently)
client.set_vertical_swing(family_id=37790, device_id="...", on=True)   # 上下摆风 开
client.set_vertical_swing(family_id=37790, device_id="...", on=False)  # 上下摆风 关
client.set_horizontal_swing(family_id=37790, device_id="...", on=True)  # 左右摆风 开
client.set_horizontal_swing(family_id=37790, device_id="...", on=False)  # 左右摆风 关
# HA convenience setter that writes both fields at once
client.set_swing_mode(family_id=37790, device_id="...", swing=SwingMode.BOTH)

# Presets (each is a single boolean field)
client.set_eco(family_id=37790, device_id="...", on=True)         # ECO 开
client.set_eco(family_id=37790, device_id="...", on=False)        # ECO 关
client.set_fresh_air(family_id=37790, device_id="...", on=True)   # 空气清新 开
client.set_fresh_air(family_id=37790, device_id="...", on=False)  # 空气清新 关
client.set_aux_heat(family_id=37790, device_id="...", on=True)    # 电辅热 开(仅制热)
client.set_aux_heat(family_id=37790, device_id="...", on=False)   # 电辅热 关

# Read side
client.list_device_timers(family_id=37790, device_id="...")
client.get_device_panel_template(family_id=37790, device_id="...")

HA climate entity mapping

Suning App xiaobiu API C_* field HA climate field
电源开关 turn_on/off C_POWER hvac_mode = off when off
制冷 set_hvac_mode(COOL) C_MODE=1 hvac_mode = cool
制热 set_hvac_mode(HEAT) C_MODE=2 hvac_mode = heat
送风 set_hvac_mode(FAN_ONLY) C_MODE=3 hvac_mode = fan_only
除湿 set_hvac_mode(DRY) C_MODE=4 hvac_mode = dry
自动 set_hvac_mode(AUTO) C_MODE=6 hvac_mode = auto
一键通 set_hvac_mode(QUICK) C_MODE=5 hvac_mode = auto (map)
微风/低/中/高/强风 set_fan_mode(SILENT/LOW/MEDIUM/HIGH/TURBO) C_FANSPEED=1..5 fan_mode
上下摆风 set_vertical_swing(on=) C_AIRVERTICAL swing_vertical_mode
左右摆风 set_horizontal_swing(on=) C_AIRHORIZONTAL swing_horizontal_mode
ECO set_eco(on=) C_ECO preset_mode = eco
空气清新 set_fresh_air(on=) C_FRESHAIR preset_mode = fresh_air
电辅热 set_aux_heat(on=) C_ELECHEATING preset_mode = aux_heat

CLI

# Interactive login
xiaobiucli login --phone 13800000000 --state-file .suning-session.json

# Send SMS only
xiaobiucli send-sms --phone 13800000000 --state-file .suning-session.json

# Check session
xiaobiucli check --state-file .suning-session.json

# List families / devices
xiaobiucli families --state-file .suning-session.json
xiaobiucli devices --family-id 37790 --state-file .suning-session.json

# Air-conditioner control
xiaobiucli control              --family-id 37790 --device-id <id> --power on|off
xiaobiucli set-mode             --family-id 37790 --device-id <id> --mode off|cool|heat|fan_only|dry|auto|quick
xiaobiucli set-temperature      --family-id 37790 --device-id <id> --temperature 24.0
xiaobiucli set-fan              --family-id 37790 --device-id <id> --speed auto|silent|low|medium|high|turbo
xiaobiucli set-swing            --family-id 37790 --device-id <id> --mode off|vertical|horizontal|both
xiaobiucli set-vertical-swing   --family-id 37790 --device-id <id> --on|--off
xiaobiucli set-horizontal-swing --family-id 37790 --device-id <id> --on|--off
xiaobiucli set-eco              --family-id 37790 --device-id <id> --on|--off
xiaobiucli set-fresh-air        --family-id 37790 --device-id <id> --on|--off
xiaobiucli set-aux-heat         --family-id 37790 --device-id <id> --on|--off
xiaobiucli timers               --family-id 37790 --device-id <id>
xiaobiucli panel                --family-id 37790 --device-id <id>

Notes

  • C_MODE=5HvacMode.QUICK (一键通) is inferred — the 2026-06-01 HAR did not capture that button, and the App has no other unused mode value in the 0–7 range. Please confirm against a live device once and adjust if the App maps a different number to 一键通.
  • C_ELECHEATING (电辅热) was surfaced by queryTemplate.do and the value is inferred to be 0/1. set_aux_heat(on=True) enforces the App's "only while heating" rule at the client (raises SuningError if the current mode is not HEAT).
  • SN_CLOUD_TIMER writes are not implemented in this release.
  • Unknown C_MODE values (e.g. 7, which neither the App nor the capture expose) collapse to hvac_mode = None so Home Assistant can render unavailable rather than guessing.

Requirements

  • Python >= 3.14
  • cryptography, pydantic, requests

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

python_xiaobiu-0.2.0.tar.gz (89.1 kB view details)

Uploaded Source

Built Distribution

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

python_xiaobiu-0.2.0-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file python_xiaobiu-0.2.0.tar.gz.

File metadata

  • Download URL: python_xiaobiu-0.2.0.tar.gz
  • Upload date:
  • Size: 89.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for python_xiaobiu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c18b48e0426814d8c9f6d6d70360d28db3e37158818c0072f1336f8afef21797
MD5 e3e1134c468bb8212826a3be575dcfaa
BLAKE2b-256 87db22e7fcdf812f8599461e723c015195abd1d03a53e4720225d934351fd2dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_xiaobiu-0.2.0.tar.gz:

Publisher: python-publish.yml on FaintGhost/python-xiaobiu

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

File details

Details for the file python_xiaobiu-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: python_xiaobiu-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for python_xiaobiu-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b0eee4d0e9f058283fd2a4f17e66fb0e0ba8d1320f96d2c0d1e0bf7d2e6bbe4
MD5 542eba1f8d5866da0ec5912e79cd1e27
BLAKE2b-256 2b6d593dc260c56e943a62eee89450344df68855da45765e9f68d871a7595ea3

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_xiaobiu-0.2.0-py3-none-any.whl:

Publisher: python-publish.yml on FaintGhost/python-xiaobiu

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