python-xiaobiu 0.2.1__tar.gz → 0.2.3__tar.gz

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.
Files changed (56) hide show
  1. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/.github/workflows/python-publish.yml +6 -1
  2. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/.gitignore +3 -0
  3. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/CHANGELOG.md +45 -0
  4. python_xiaobiu-0.2.1/README.md → python_xiaobiu-0.2.3/PKG-INFO +63 -21
  5. python_xiaobiu-0.2.1/PKG-INFO → python_xiaobiu-0.2.3/README.md +42 -40
  6. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/pyproject.toml +13 -4
  7. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/ac_control.py +208 -34
  8. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/ac_status.py +23 -6
  9. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/cli.py +37 -0
  10. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/client.py +39 -3
  11. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_ac_control.py +132 -18
  12. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_ac_status.py +204 -10
  13. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_cli.py +49 -0
  14. python_xiaobiu-0.2.3/uv.lock +370 -0
  15. python_xiaobiu-0.2.1/uv.lock +0 -367
  16. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-design/bdd-specs.md +0 -0
  17. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/_index.md +0 -0
  18. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-001-ac-enums-impl.md +0 -0
  19. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-001-ac-enums-test.md +0 -0
  20. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-002-ac-cmd-mappings-impl.md +0 -0
  21. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-002-ac-cmd-mappings-test.md +0 -0
  22. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-003-ac-app-oper-impl.md +0 -0
  23. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-003-ac-app-oper-test.md +0 -0
  24. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-004-ac-highlevel-impl.md +0 -0
  25. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-004-ac-highlevel-test.md +0 -0
  26. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-005-ac-panel-template-impl.md +0 -0
  27. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-005-ac-panel-template-test.md +0 -0
  28. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-006-ac-timers-impl.md +0 -0
  29. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-006-ac-timers-test.md +0 -0
  30. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-007-ac-state-hvac-impl.md +0 -0
  31. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-007-ac-state-hvac-test.md +0 -0
  32. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-008-cli-ac-control-impl.md +0 -0
  33. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-008-cli-ac-control-test.md +0 -0
  34. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-01-ac-control-plan/task-009-docs-readme-impl.md +0 -0
  35. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-02-ac-control-align-ha-design/bdd-specs.md +0 -0
  36. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/docs/plans/2026-06-02-ac-control-align-ha-plan/_index.md +0 -0
  37. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/__init__.py +0 -0
  38. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/app_api.py +0 -0
  39. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/captcha_bridge.py +0 -0
  40. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/crypto.py +0 -0
  41. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/exceptions.py +0 -0
  42. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/har_templates.py +0 -0
  43. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/models.py +0 -0
  44. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/parsers.py +0 -0
  45. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/persistence.py +0 -0
  46. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/src/xiaobiu/sms_login.py +0 -0
  47. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/__init__.py +0 -0
  48. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_app_api.py +0 -0
  49. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_captcha_bridge.py +0 -0
  50. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_client.py +0 -0
  51. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_crypto.py +0 -0
  52. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_har_templates.py +0 -0
  53. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_models.py +0 -0
  54. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_parsers.py +0 -0
  55. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_persistence.py +0 -0
  56. {python_xiaobiu-0.2.1 → python_xiaobiu-0.2.3}/tests/test_sms_login.py +0 -0
@@ -24,7 +24,12 @@ jobs:
24
24
 
25
25
  - uses: actions/setup-python@v5
26
26
  with:
27
- python-version: "3.x"
27
+ python-version: "3.14"
28
+
29
+ - name: Run tests
30
+ run: |
31
+ python -m pip install . pytest pytest-asyncio
32
+ python -m pytest
28
33
 
29
34
  - name: Build release distributions
30
35
  run: |
@@ -8,3 +8,6 @@ dist/
8
8
  .venv/
9
9
  *.suning-session*.json
10
10
  *.har
11
+ .codegraph/
12
+ .reasonix/
13
+ verify_ac.py
@@ -4,6 +4,51 @@ All notable changes to `python-xiaobiu` are documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.2.3] - 2026-11-25
8
+
9
+ ### Added
10
+ - `set_device_timer()` on the client and `ac_control.set_device_timer()`:
11
+ create cloud timers with `T,<hour>,<minute>,<weekmask>`, mirroring
12
+ `TimingStepTwoActivity` from 苏宁 AI家 7.0.2.
13
+ - `build_timer_schedule()` and `encode_timer_weekdays()` helpers for the
14
+ app's odd weekday bit packing (`1` + first bit + reversed remaining six).
15
+
16
+ ### Fixed
17
+ - `list_device_timers()` enabled flag now follows the `T` / `F` prefix of
18
+ the schedule string. The cloud reports `state="1"` for enabled and
19
+ `state="0"` for disabled; the previous mapping treated `"0"` as enabled.
20
+
21
+ ### Notes
22
+ - The cloud exposes **no delete endpoint**: `clearTimer` returns 404 on
23
+ every host, and `setTimer` rejects an empty command with `1009 命令为空`.
24
+ Disabling a timer (`enabled=False`) is the only supported way to retire
25
+ one.
26
+
27
+ ## [0.2.2] - 2026-06-24
28
+
29
+ ### Added
30
+ - `raw-oper` CLI command for protocol testing with arbitrary `C_*` / `SN_*`
31
+ command fields.
32
+
33
+ ### Changed
34
+ - Split the write-side `C_MODE` and read-side `SN_MODE` mappings based on
35
+ live-device verification. One-touch mode is exposed as `auto`, while
36
+ `quick` remains a write-compatible alias.
37
+ - Panel-template requests now match the live endpoint contract and include
38
+ the logged-in user's `custno` as the `userid` header when available.
39
+ - Device capabilities now follow the mode values advertised by the panel
40
+ template instead of assuming a fixed list.
41
+ - `C_FRESHAIR` and `SN_PURIFY` are treated as aliases when normalizing status.
42
+ - Raised dependency floors to patched releases and added the test suite as a
43
+ required step in the PyPI publishing workflow.
44
+
45
+ ### Fixed
46
+ - Corrected heat, cool, dry, fan-only, and one-touch mode encoding for
47
+ control commands and status responses.
48
+ - Correctly falls back to `C_MODE` encoding when `SN_MODE` is blank.
49
+ - Prevented local protocol captures and analysis metadata from entering
50
+ source distributions.
51
+
7
52
  ## [0.2.1] - 2026-06-02
8
53
 
9
54
  ### Added
@@ -1,3 +1,24 @@
1
+ Metadata-Version: 2.5
2
+ Name: python-xiaobiu
3
+ Version: 0.2.3
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>=48.0.1
16
+ Requires-Dist: idna>=3.15
17
+ Requires-Dist: pydantic>=2.0.0
18
+ Requires-Dist: requests>=2.33.0
19
+ Requires-Dist: urllib3>=2.7.0
20
+ Description-Content-Type: text/markdown
21
+
1
22
  # python-xiaobiu
2
23
 
3
24
  Python client for Suning smart home SMS login and session management.
@@ -52,12 +73,12 @@ client.turn_on(family_id=37790, device_id="000165f9b029afa2e5d8")
52
73
  client.turn_off(family_id=37790, device_id="000165f9b029afa2e5d8")
53
74
 
54
75
  # Mode
55
- client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.COOL) # 制冷
56
- client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.HEAT) # 制热
57
- client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.FAN_ONLY) # 送风
58
- client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.DRY) # 除湿
59
- client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.AUTO) # 自动
60
- client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.QUICK) # 一键通 (C_MODE=5, 待实测确认)
76
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.HEAT) # 制热 (C_MODE=1)
77
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.COOL) # 制冷 (C_MODE=2)
78
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.DRY) # 除湿 (C_MODE=3)
79
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.FAN_ONLY) # 送风 (C_MODE=4)
80
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.AUTO) # 一键通/自动 (C_MODE=6)
81
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.QUICK) # 一键通/自动 (C_MODE=6, 与 AUTO 同)
61
82
 
62
83
  # Temperature
63
84
  client.set_temperature(family_id=37790, device_id="...", value=24.0) # 16.0–32.0
@@ -91,17 +112,31 @@ client.list_device_timers(family_id=37790, device_id="...")
91
112
  client.get_device_panel_template(family_id=37790, device_id="...")
92
113
  ```
93
114
 
115
+ ### Timers
116
+
117
+ ```python
118
+ timers = client.list_device_timers(family_id=37790, device_id="...")
119
+ client.set_device_timer(
120
+ family_id=37790, device_id="...",
121
+ hour=23, minute=0, power_on=False, name="关闭时间",
122
+ )
123
+ ```
124
+
125
+ `timer` uses the app's `T,<hour>,<minute>,<weekmask>` format. The leading
126
+ `T` / `F` is the enabled flag — pass `enabled=False` to disable an
127
+ existing schedule, because the cloud has **no delete call** (`clearTimer`
128
+ returns 404 and `setTimer` rejects an empty command).
129
+
94
130
  ### HA climate entity mapping
95
131
 
96
132
  | Suning App | `xiaobiu` API | `C_*` field | HA climate field |
97
133
  |------------|---------------|------------|------------------|
98
134
  | 电源开关 | `turn_on/off` | `C_POWER` | `hvac_mode = off` when off |
99
- | 制冷 | `set_hvac_mode(COOL)` | `C_MODE=1` | `hvac_mode = cool` |
100
- | 制热 | `set_hvac_mode(HEAT)` | `C_MODE=2` | `hvac_mode = heat` |
101
- | 送风 | `set_hvac_mode(FAN_ONLY)` | `C_MODE=3` | `hvac_mode = fan_only` |
102
- | 除湿 | `set_hvac_mode(DRY)` | `C_MODE=4` | `hvac_mode = dry` |
103
- | 自动 | `set_hvac_mode(AUTO)` | `C_MODE=6` | `hvac_mode = auto` |
104
- | 一键通 | `set_hvac_mode(QUICK)` | `C_MODE=5` | `hvac_mode = auto` (map) |
135
+ | 制热 | `set_hvac_mode(HEAT)` | `C_MODE=1` | `hvac_mode = heat` |
136
+ | 制冷 | `set_hvac_mode(COOL)` | `C_MODE=2` | `hvac_mode = cool` |
137
+ | 除湿 | `set_hvac_mode(DRY)` | `C_MODE=3` | `hvac_mode = dry` |
138
+ | 送风 | `set_hvac_mode(FAN_ONLY)` | `C_MODE=4` (或 `5`) | `hvac_mode = fan_only` |
139
+ | 一键通/自动 | `set_hvac_mode(AUTO)` / `set_hvac_mode(QUICK)` | `C_MODE=6` | `hvac_mode = auto` |
105
140
  | 微风/低/中/高/强风 | `set_fan_mode(SILENT/LOW/MEDIUM/HIGH/TURBO)` | `C_FANSPEED=1..5` | `fan_mode` |
106
141
  | 上下摆风 | `set_vertical_swing(on=)` | `C_AIRVERTICAL` | `swing_mode` (HA 把 `swing_mode` 默认指垂直) |
107
142
  | 左右摆风 | `set_horizontal_swing(on=)` | `C_AIRHORIZONTAL` | `swing_horizontal_mode` |
@@ -109,6 +144,11 @@ client.get_device_panel_template(family_id=37790, device_id="...")
109
144
  | 空气清新 | `set_fresh_air(on=)` | `C_FRESHAIR` | `preset_mode = fresh_air` |
110
145
  | 电辅热 | `set_aux_heat(on=)` | `C_ELECHEATING` | `preset_mode = aux_heat` |
111
146
 
147
+ > **读/写编码不同**:上表是**写侧**(`C_MODE` 控制值)。设备**上报状态**用的是另一套 `SN_MODE` 值:
148
+ > `SN_MODE=1`(一键通/自动)、`2`(制冷)、`3`(制热)、`4`(送风)、`5`(除湿)。
149
+ > `infer_hvac_mode` 读状态时默认按 `SN_MODE` 解码;下发命令时 `set_hvac_mode` 用 `C_MODE`。
150
+ > 两套编码不一致(如 `C_MODE=1` 是制热,但 `SN_MODE=1` 是一键通),库内部已拆成两张表分别处理。
151
+
112
152
  ### `swing_mode` 集成注意事项
113
153
 
114
154
  按 Home Assistant climate entity 惯例:
@@ -190,19 +230,21 @@ xiaobiucli set-fresh-air --family-id 37790 --device-id <id> --on|--off
190
230
  xiaobiucli set-aux-heat --family-id 37790 --device-id <id> --on|--off
191
231
  xiaobiucli timers --family-id 37790 --device-id <id>
192
232
  xiaobiucli panel --family-id 37790 --device-id <id>
233
+ xiaobiucli raw-oper --family-id 37790 --device-id <id> --cmd C_MODE=1 [--cmd KEY=VALUE ...]
193
234
  ```
194
235
 
195
236
  ## Notes
196
237
 
197
- - **`C_MODE=5` → `HvacMode.QUICK`** (一键通) is **inferred** — the 2026-06-01
198
- HAR did not capture that button, and the App has no other unused mode
199
- value in the 0–7 range. Please confirm against a live device once
200
- and adjust if the App maps a different number to 一键通.
201
- - **`C_ELECHEATING` (电辅热)** was surfaced by `queryTemplate.do` and
202
- the value is inferred to be `0/1`. `set_aux_heat(on=True)` enforces
203
- the App's "only while heating" rule at the client (raises
204
- `SuningError` if the current mode is not HEAT).
205
- - **`SN_CLOUD_TIMER` writes** are not implemented in this release.
238
+ - **`C_MODE` / `SN_MODE` 编码不同**(2026-06-17 真机实测确认):
239
+ - 写侧 `C_MODE`:`1`=制热、`2`=制冷、`3`=除湿、`4`=送风、`5`=送风(同 4)、`6`=一键通(≈自动)
240
+ - 读侧 `SN_MODE`:`1`=一键通(自动)、`2`=制冷、`3`=制热、`4`=送风、`5`=除湿
241
+ - 库内部用 `C_FIELD_TO_HVAC`(写)和 `SN_FIELD_TO_HVAC`(读)两张表分别处理。
242
+ - **一键通 ≈ 自动**:这台设备没有独立的 AUTO 模式,`C_MODE=6`(一键通)在语义上最接近,
243
+ 暴露为 `HvacMode.AUTO`;`HvacMode.QUICK` 也指向 `C_MODE=6`。
244
+ - **`C_ELECHEATING` (电辅热)** 值域已实测确认为 `0/1`。`set_aux_heat(on=True)` 在客户端
245
+ 强制 App 的"仅制热时生效"规则(当前模式非 HEAT 时 raise `SuningError`)。
246
+ - **`SN_CLOUD_TIMER` writes** are not implemented; cloud timers go through
247
+ `set_device_timer` instead, and cannot be deleted (only disabled).
206
248
  - **Unknown `C_MODE` values** (e.g. `7`, which neither the App nor the
207
249
  capture expose) collapse to `hvac_mode = None` so Home Assistant can
208
250
  render `unavailable` rather than guessing.
@@ -1,22 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: python-xiaobiu
3
- Version: 0.2.1
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
1
  # python-xiaobiu
21
2
 
22
3
  Python client for Suning smart home SMS login and session management.
@@ -71,12 +52,12 @@ client.turn_on(family_id=37790, device_id="000165f9b029afa2e5d8")
71
52
  client.turn_off(family_id=37790, device_id="000165f9b029afa2e5d8")
72
53
 
73
54
  # 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, 待实测确认)
55
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.HEAT) # 制热 (C_MODE=1)
56
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.COOL) # 制冷 (C_MODE=2)
57
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.DRY) # 除湿 (C_MODE=3)
58
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.FAN_ONLY) # 送风 (C_MODE=4)
59
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.AUTO) # 一键通/自动 (C_MODE=6)
60
+ client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.QUICK) # 一键通/自动 (C_MODE=6, 与 AUTO 同)
80
61
 
81
62
  # Temperature
82
63
  client.set_temperature(family_id=37790, device_id="...", value=24.0) # 16.0–32.0
@@ -110,17 +91,31 @@ client.list_device_timers(family_id=37790, device_id="...")
110
91
  client.get_device_panel_template(family_id=37790, device_id="...")
111
92
  ```
112
93
 
94
+ ### Timers
95
+
96
+ ```python
97
+ timers = client.list_device_timers(family_id=37790, device_id="...")
98
+ client.set_device_timer(
99
+ family_id=37790, device_id="...",
100
+ hour=23, minute=0, power_on=False, name="关闭时间",
101
+ )
102
+ ```
103
+
104
+ `timer` uses the app's `T,<hour>,<minute>,<weekmask>` format. The leading
105
+ `T` / `F` is the enabled flag — pass `enabled=False` to disable an
106
+ existing schedule, because the cloud has **no delete call** (`clearTimer`
107
+ returns 404 and `setTimer` rejects an empty command).
108
+
113
109
  ### HA climate entity mapping
114
110
 
115
111
  | Suning App | `xiaobiu` API | `C_*` field | HA climate field |
116
112
  |------------|---------------|------------|------------------|
117
113
  | 电源开关 | `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) |
114
+ | 制热 | `set_hvac_mode(HEAT)` | `C_MODE=1` | `hvac_mode = heat` |
115
+ | 制冷 | `set_hvac_mode(COOL)` | `C_MODE=2` | `hvac_mode = cool` |
116
+ | 除湿 | `set_hvac_mode(DRY)` | `C_MODE=3` | `hvac_mode = dry` |
117
+ | 送风 | `set_hvac_mode(FAN_ONLY)` | `C_MODE=4` (或 `5`) | `hvac_mode = fan_only` |
118
+ | 一键通/自动 | `set_hvac_mode(AUTO)` / `set_hvac_mode(QUICK)` | `C_MODE=6` | `hvac_mode = auto` |
124
119
  | 微风/低/中/高/强风 | `set_fan_mode(SILENT/LOW/MEDIUM/HIGH/TURBO)` | `C_FANSPEED=1..5` | `fan_mode` |
125
120
  | 上下摆风 | `set_vertical_swing(on=)` | `C_AIRVERTICAL` | `swing_mode` (HA 把 `swing_mode` 默认指垂直) |
126
121
  | 左右摆风 | `set_horizontal_swing(on=)` | `C_AIRHORIZONTAL` | `swing_horizontal_mode` |
@@ -128,6 +123,11 @@ client.get_device_panel_template(family_id=37790, device_id="...")
128
123
  | 空气清新 | `set_fresh_air(on=)` | `C_FRESHAIR` | `preset_mode = fresh_air` |
129
124
  | 电辅热 | `set_aux_heat(on=)` | `C_ELECHEATING` | `preset_mode = aux_heat` |
130
125
 
126
+ > **读/写编码不同**:上表是**写侧**(`C_MODE` 控制值)。设备**上报状态**用的是另一套 `SN_MODE` 值:
127
+ > `SN_MODE=1`(一键通/自动)、`2`(制冷)、`3`(制热)、`4`(送风)、`5`(除湿)。
128
+ > `infer_hvac_mode` 读状态时默认按 `SN_MODE` 解码;下发命令时 `set_hvac_mode` 用 `C_MODE`。
129
+ > 两套编码不一致(如 `C_MODE=1` 是制热,但 `SN_MODE=1` 是一键通),库内部已拆成两张表分别处理。
130
+
131
131
  ### `swing_mode` 集成注意事项
132
132
 
133
133
  按 Home Assistant climate entity 惯例:
@@ -209,19 +209,21 @@ xiaobiucli set-fresh-air --family-id 37790 --device-id <id> --on|--off
209
209
  xiaobiucli set-aux-heat --family-id 37790 --device-id <id> --on|--off
210
210
  xiaobiucli timers --family-id 37790 --device-id <id>
211
211
  xiaobiucli panel --family-id 37790 --device-id <id>
212
+ xiaobiucli raw-oper --family-id 37790 --device-id <id> --cmd C_MODE=1 [--cmd KEY=VALUE ...]
212
213
  ```
213
214
 
214
215
  ## Notes
215
216
 
216
- - **`C_MODE=5` → `HvacMode.QUICK`** (一键通) is **inferred** — the 2026-06-01
217
- HAR did not capture that button, and the App has no other unused mode
218
- value in the 0–7 range. Please confirm against a live device once
219
- and adjust if the App maps a different number to 一键通.
220
- - **`C_ELECHEATING` (电辅热)** was surfaced by `queryTemplate.do` and
221
- the value is inferred to be `0/1`. `set_aux_heat(on=True)` enforces
222
- the App's "only while heating" rule at the client (raises
223
- `SuningError` if the current mode is not HEAT).
224
- - **`SN_CLOUD_TIMER` writes** are not implemented in this release.
217
+ - **`C_MODE` / `SN_MODE` 编码不同**(2026-06-17 真机实测确认):
218
+ - 写侧 `C_MODE`:`1`=制热、`2`=制冷、`3`=除湿、`4`=送风、`5`=送风(同 4)、`6`=一键通(≈自动)
219
+ - 读侧 `SN_MODE`:`1`=一键通(自动)、`2`=制冷、`3`=制热、`4`=送风、`5`=除湿
220
+ - 库内部用 `C_FIELD_TO_HVAC`(写)和 `SN_FIELD_TO_HVAC`(读)两张表分别处理。
221
+ - **一键通 ≈ 自动**:这台设备没有独立的 AUTO 模式,`C_MODE=6`(一键通)在语义上最接近,
222
+ 暴露为 `HvacMode.AUTO`;`HvacMode.QUICK` 也指向 `C_MODE=6`。
223
+ - **`C_ELECHEATING` (电辅热)** 值域已实测确认为 `0/1`。`set_aux_heat(on=True)` 在客户端
224
+ 强制 App 的"仅制热时生效"规则(当前模式非 HEAT 时 raise `SuningError`)。
225
+ - **`SN_CLOUD_TIMER` writes** are not implemented; cloud timers go through
226
+ `set_device_timer` instead, and cannot be deleted (only disabled).
225
227
  - **Unknown `C_MODE` values** (e.g. `7`, which neither the App nor the
226
228
  capture expose) collapse to `hvac_mode = None` so Home Assistant can
227
229
  render `unavailable` rather than guessing.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-xiaobiu"
3
- version = "0.2.1"
3
+ version = "0.2.3"
4
4
  description = "Suning biu smart home SMS login and session client"
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -16,9 +16,11 @@ classifiers = [
16
16
  ]
17
17
  requires-python = ">=3.14"
18
18
  dependencies = [
19
- "cryptography>=44.0.0",
19
+ "cryptography>=48.0.1",
20
+ "idna>=3.15",
20
21
  "pydantic>=2.0.0",
21
- "requests>=2.28.0",
22
+ "requests>=2.33.0",
23
+ "urllib3>=2.7.0",
22
24
  ]
23
25
 
24
26
  [project.urls]
@@ -30,7 +32,7 @@ xiaobiucli = "xiaobiu:main"
30
32
 
31
33
  [dependency-groups]
32
34
  dev = [
33
- "pytest>=8.0.0",
35
+ "pytest>=9.0.3",
34
36
  "pytest-asyncio>=0.23.0",
35
37
  ]
36
38
 
@@ -41,5 +43,12 @@ build-backend = "hatchling.build"
41
43
  [tool.hatch.build.targets.wheel]
42
44
  packages = ["src/xiaobiu"]
43
45
 
46
+ [tool.hatch.build]
47
+ exclude = [
48
+ "/.codegraph",
49
+ "/.reasonix",
50
+ "/verify_ac.py",
51
+ ]
52
+
44
53
  [tool.pytest.ini_options]
45
54
  asyncio_mode = "auto"