python-xiaobiu 0.1.1__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-xiaobiu
3
+ Version: 0.2.0
4
+ Summary: Suning biu smart home SMS login and session client
5
+ Project-URL: Homepage, https://github.com/FaintGhost/python-xiaobiu
6
+ Project-URL: Bug Tracker, https://github.com/FaintGhost/python-xiaobiu/issues
7
+ Author-email: FaintGhost <zhang.yaowei@live.com>
8
+ License: MIT
9
+ Keywords: climate,home-assistant,smart-home,suning
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Requires-Python: >=3.14
15
+ Requires-Dist: cryptography>=44.0.0
16
+ Requires-Dist: pydantic>=2.0.0
17
+ Requires-Dist: requests>=2.28.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ # python-xiaobiu
21
+
22
+ Python client for Suning smart home SMS login and session management.
23
+
24
+ Used by the [ha-suning](https://github.com/FaintGhost/ha-suning) Home Assistant custom integration.
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ pip install python-xiaobiu
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```python
35
+ from xiaobiu import CaptchaRequiredError, SuningSmartHomeClient
36
+
37
+ client = SuningSmartHomeClient(state_path=".suning-session.json")
38
+
39
+ try:
40
+ client.send_sms_code("13800000000")
41
+ except CaptchaRequiredError as error:
42
+ print(error.risk_type, error.sms_ticket)
43
+
44
+ client.login_with_sms_code(phone_number="13800000000", sms_code="123456")
45
+ print(client.list_family_infos())
46
+ ```
47
+
48
+ ## Air Conditioner Control
49
+
50
+ Suning's "小标" App exposes a flat per-device control surface where every
51
+ button on the AC card maps to a single ``C_*`` field on the ``appOper``
52
+ endpoint. This client mirrors that surface and aligns the typed layer
53
+ with the [Home Assistant climate entity](https://developers.home-assistant.io/docs/core/entity/climate/).
54
+
55
+ ```python
56
+ from xiaobiu import (
57
+ FanSpeed,
58
+ HvacMode,
59
+ PresetMode,
60
+ SwingMode,
61
+ )
62
+
63
+ status = client.get_air_conditioner_status(
64
+ family_id=37790,
65
+ device_id="000165f9b029afa2e5d8",
66
+ )
67
+ print(status.hvac_mode) # HvacMode.{OFF,COOL,HEAT,FAN_ONLY,DRY,AUTO,QUICK} or None
68
+
69
+ # Power
70
+ client.turn_on(family_id=37790, device_id="000165f9b029afa2e5d8")
71
+ client.turn_off(family_id=37790, device_id="000165f9b029afa2e5d8")
72
+
73
+ # Mode
74
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.COOL) # 制冷
75
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.HEAT) # 制热
76
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.FAN_ONLY) # 送风
77
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.DRY) # 除湿
78
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.AUTO) # 自动
79
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.QUICK) # 一键通 (C_MODE=5, 待实测确认)
80
+
81
+ # Temperature
82
+ client.set_temperature(family_id=37790, device_id="...", value=24.0) # 16.0–32.0
83
+
84
+ # Fan (App 标签 / C_FANSPEED raw / HA fan_mode)
85
+ client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.AUTO) # 自动 / 0 / auto
86
+ client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.SILENT) # 微风 / 1 / silent
87
+ client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.LOW) # 低风 / 2 / low
88
+ client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.MEDIUM) # 中风 / 3 / medium
89
+ client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.HIGH) # 高风 / 4 / high
90
+ client.set_fan_mode(family_id=37790, device_id="...", speed=FanSpeed.TURBO) # 强风 / 5 / turbo
91
+
92
+ # Swing (vertical/horizontal can be toggled independently)
93
+ client.set_vertical_swing(family_id=37790, device_id="...", on=True) # 上下摆风 开
94
+ client.set_vertical_swing(family_id=37790, device_id="...", on=False) # 上下摆风 关
95
+ client.set_horizontal_swing(family_id=37790, device_id="...", on=True) # 左右摆风 开
96
+ client.set_horizontal_swing(family_id=37790, device_id="...", on=False) # 左右摆风 关
97
+ # HA convenience setter that writes both fields at once
98
+ client.set_swing_mode(family_id=37790, device_id="...", swing=SwingMode.BOTH)
99
+
100
+ # Presets (each is a single boolean field)
101
+ client.set_eco(family_id=37790, device_id="...", on=True) # ECO 开
102
+ client.set_eco(family_id=37790, device_id="...", on=False) # ECO 关
103
+ client.set_fresh_air(family_id=37790, device_id="...", on=True) # 空气清新 开
104
+ client.set_fresh_air(family_id=37790, device_id="...", on=False) # 空气清新 关
105
+ client.set_aux_heat(family_id=37790, device_id="...", on=True) # 电辅热 开(仅制热)
106
+ client.set_aux_heat(family_id=37790, device_id="...", on=False) # 电辅热 关
107
+
108
+ # Read side
109
+ client.list_device_timers(family_id=37790, device_id="...")
110
+ client.get_device_panel_template(family_id=37790, device_id="...")
111
+ ```
112
+
113
+ ### HA climate entity mapping
114
+
115
+ | Suning App | `xiaobiu` API | `C_*` field | HA climate field |
116
+ |------------|---------------|------------|------------------|
117
+ | 电源开关 | `turn_on/off` | `C_POWER` | `hvac_mode = off` when off |
118
+ | 制冷 | `set_hvac_mode(COOL)` | `C_MODE=1` | `hvac_mode = cool` |
119
+ | 制热 | `set_hvac_mode(HEAT)` | `C_MODE=2` | `hvac_mode = heat` |
120
+ | 送风 | `set_hvac_mode(FAN_ONLY)` | `C_MODE=3` | `hvac_mode = fan_only` |
121
+ | 除湿 | `set_hvac_mode(DRY)` | `C_MODE=4` | `hvac_mode = dry` |
122
+ | 自动 | `set_hvac_mode(AUTO)` | `C_MODE=6` | `hvac_mode = auto` |
123
+ | 一键通 | `set_hvac_mode(QUICK)` | `C_MODE=5` | `hvac_mode = auto` (map) |
124
+ | 微风/低/中/高/强风 | `set_fan_mode(SILENT/LOW/MEDIUM/HIGH/TURBO)` | `C_FANSPEED=1..5` | `fan_mode` |
125
+ | 上下摆风 | `set_vertical_swing(on=)` | `C_AIRVERTICAL` | `swing_vertical_mode` |
126
+ | 左右摆风 | `set_horizontal_swing(on=)` | `C_AIRHORIZONTAL` | `swing_horizontal_mode` |
127
+ | ECO | `set_eco(on=)` | `C_ECO` | `preset_mode = eco` |
128
+ | 空气清新 | `set_fresh_air(on=)` | `C_FRESHAIR` | `preset_mode = fresh_air` |
129
+ | 电辅热 | `set_aux_heat(on=)` | `C_ELECHEATING` | `preset_mode = aux_heat` |
130
+
131
+ ## CLI
132
+
133
+ ```bash
134
+ # Interactive login
135
+ xiaobiucli login --phone 13800000000 --state-file .suning-session.json
136
+
137
+ # Send SMS only
138
+ xiaobiucli send-sms --phone 13800000000 --state-file .suning-session.json
139
+
140
+ # Check session
141
+ xiaobiucli check --state-file .suning-session.json
142
+
143
+ # List families / devices
144
+ xiaobiucli families --state-file .suning-session.json
145
+ xiaobiucli devices --family-id 37790 --state-file .suning-session.json
146
+
147
+ # Air-conditioner control
148
+ xiaobiucli control --family-id 37790 --device-id <id> --power on|off
149
+ xiaobiucli set-mode --family-id 37790 --device-id <id> --mode off|cool|heat|fan_only|dry|auto|quick
150
+ xiaobiucli set-temperature --family-id 37790 --device-id <id> --temperature 24.0
151
+ xiaobiucli set-fan --family-id 37790 --device-id <id> --speed auto|silent|low|medium|high|turbo
152
+ xiaobiucli set-swing --family-id 37790 --device-id <id> --mode off|vertical|horizontal|both
153
+ xiaobiucli set-vertical-swing --family-id 37790 --device-id <id> --on|--off
154
+ xiaobiucli set-horizontal-swing --family-id 37790 --device-id <id> --on|--off
155
+ xiaobiucli set-eco --family-id 37790 --device-id <id> --on|--off
156
+ xiaobiucli set-fresh-air --family-id 37790 --device-id <id> --on|--off
157
+ xiaobiucli set-aux-heat --family-id 37790 --device-id <id> --on|--off
158
+ xiaobiucli timers --family-id 37790 --device-id <id>
159
+ xiaobiucli panel --family-id 37790 --device-id <id>
160
+ ```
161
+
162
+ ## Notes
163
+
164
+ - **`C_MODE=5` → `HvacMode.QUICK`** (一键通) is **inferred** — the 2026-06-01
165
+ HAR did not capture that button, and the App has no other unused mode
166
+ value in the 0–7 range. Please confirm against a live device once
167
+ and adjust if the App maps a different number to 一键通.
168
+ - **`C_ELECHEATING` (电辅热)** was surfaced by `queryTemplate.do` and
169
+ the value is inferred to be `0/1`. `set_aux_heat(on=True)` enforces
170
+ the App's "only while heating" rule at the client (raises
171
+ `SuningError` if the current mode is not HEAT).
172
+ - **`SN_CLOUD_TIMER` writes** are not implemented in this release.
173
+ - **Unknown `C_MODE` values** (e.g. `7`, which neither the App nor the
174
+ capture expose) collapse to `hvac_mode = None` so Home Assistant can
175
+ render `unavailable` rather than guessing.
176
+
177
+ ## Requirements
178
+
179
+ - Python >= 3.14
180
+ - `cryptography`, `pydantic`, `requests`
@@ -0,0 +1,18 @@
1
+ xiaobiu/__init__.py,sha256=l_yRiG0cxB1n7ypG1Z4R7jutZtRmCXXIIsB9JiBq1Dc,807
2
+ xiaobiu/ac_control.py,sha256=thz4jSHhGifQjvJcN0SdLIFldIys1nHugb67Onv4IDM,13830
3
+ xiaobiu/ac_status.py,sha256=6SFJwl6OyYKakYKv09LJ8SyjoY8hFiQe0jnme8UWVCQ,14317
4
+ xiaobiu/app_api.py,sha256=gJLa-iq60s_YEEM00E4lMcTsBKoV60GtaaqBsWWOWio,4729
5
+ xiaobiu/captcha_bridge.py,sha256=l8c3HnspQt1JDM1sDKnvcM4yvf7NZosSQ7x2AlO-kEA,12920
6
+ xiaobiu/cli.py,sha256=eDGyv5VCOP3O4l8HCJk_XtgxLPCAOR12zuB0CYpTdQI,17599
7
+ xiaobiu/client.py,sha256=44Ay-Yr0O74UXV6BuNOJrytaVmssHwNghPVE0U1fE-I,23047
8
+ xiaobiu/crypto.py,sha256=C0Lcp2Cfy-075hv65b1RYfn6UbiHneLhp4PhUftzzOk,2424
9
+ xiaobiu/exceptions.py,sha256=RKaity_UctboUGeC8QE0iF0KcqfYqlVHnfOQ2yXQT7c,1036
10
+ xiaobiu/har_templates.py,sha256=clatrCsn4_AxlSrpy99mJVThI34bFQpQQMoM-4H9e08,5562
11
+ xiaobiu/models.py,sha256=WCYHuSDujM9h3_isCMs7unFB1eYuKH8vOu6N4fJTaTc,4503
12
+ xiaobiu/parsers.py,sha256=5Cb90sN5rw_SNv2BukOoiLmeG9Mxegq-XGkgE8YkxvU,3046
13
+ xiaobiu/persistence.py,sha256=k9ZES5DyE-OkptlLLw0jnBWwGtdDxgrn0YiVhAQ1V8c,887
14
+ xiaobiu/sms_login.py,sha256=5zQS_lhFvADdp6BnoenvSLdOSK1hWaT35rQQ4K3Ig-w,16394
15
+ python_xiaobiu-0.2.0.dist-info/METADATA,sha256=vAC0o22fFkcgavTdcwsvf25kQAwwH2qhxLKy5gbW-g8,8217
16
+ python_xiaobiu-0.2.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
17
+ python_xiaobiu-0.2.0.dist-info/entry_points.txt,sha256=w1z8h63RRusoSGAbbSMpNcq4qbN3HOedsMlxwuFH3U8,44
18
+ python_xiaobiu-0.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.29.0
2
+ Generator: hatchling 1.30.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
xiaobiu/__init__.py CHANGED
@@ -12,9 +12,15 @@ from .models import (
12
12
  AuthState,
13
13
  CaptchaSolution,
14
14
  FamilyInfo,
15
+ FanSpeed,
15
16
  HAClimatePreview,
17
+ HvacMode,
16
18
  LoginPageConfig,
19
+ PanelTemplate,
20
+ PresetMode,
17
21
  SignedRequestTemplate,
22
+ SwingMode,
23
+ Timer,
18
24
  )
19
25
 
20
26
  __all__ = [
@@ -24,12 +30,18 @@ __all__ = [
24
30
  "CaptchaRequiredError",
25
31
  "CaptchaSolution",
26
32
  "FamilyInfo",
33
+ "FanSpeed",
27
34
  "HAClimatePreview",
35
+ "HvacMode",
28
36
  "LoginPageConfig",
37
+ "PanelTemplate",
38
+ "PresetMode",
29
39
  "SmsRateLimitedError",
30
40
  "SignedRequestTemplate",
31
41
  "SuningError",
32
42
  "SuningSmartHomeClient",
43
+ "SwingMode",
44
+ "Timer",
33
45
  "main",
34
46
  "parse_jsonp_or_json",
35
47
  ]