python-xiaobiu 0.2.0__py3-none-any.whl → 0.2.2__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.
- {python_xiaobiu-0.2.0.dist-info → python_xiaobiu-0.2.2.dist-info}/METADATA +83 -24
- python_xiaobiu-0.2.2.dist-info/RECORD +18 -0
- xiaobiu/__init__.py +2 -0
- xiaobiu/ac_control.py +259 -20
- xiaobiu/ac_status.py +36 -6
- xiaobiu/cli.py +37 -0
- xiaobiu/client.py +6 -2
- xiaobiu/models.py +54 -0
- python_xiaobiu-0.2.0.dist-info/RECORD +0 -18
- {python_xiaobiu-0.2.0.dist-info → python_xiaobiu-0.2.2.dist-info}/WHEEL +0 -0
- {python_xiaobiu-0.2.0.dist-info → python_xiaobiu-0.2.2.dist-info}/entry_points.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-xiaobiu
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Suning biu smart home SMS login and session client
|
|
5
5
|
Project-URL: Homepage, https://github.com/FaintGhost/python-xiaobiu
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/FaintGhost/python-xiaobiu/issues
|
|
@@ -12,9 +12,11 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Requires-Python: >=3.14
|
|
15
|
-
Requires-Dist: cryptography>=
|
|
15
|
+
Requires-Dist: cryptography>=48.0.1
|
|
16
|
+
Requires-Dist: idna>=3.15
|
|
16
17
|
Requires-Dist: pydantic>=2.0.0
|
|
17
|
-
Requires-Dist: requests>=2.
|
|
18
|
+
Requires-Dist: requests>=2.33.0
|
|
19
|
+
Requires-Dist: urllib3>=2.7.0
|
|
18
20
|
Description-Content-Type: text/markdown
|
|
19
21
|
|
|
20
22
|
# python-xiaobiu
|
|
@@ -71,12 +73,12 @@ client.turn_on(family_id=37790, device_id="000165f9b029afa2e5d8")
|
|
|
71
73
|
client.turn_off(family_id=37790, device_id="000165f9b029afa2e5d8")
|
|
72
74
|
|
|
73
75
|
# Mode
|
|
74
|
-
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.
|
|
75
|
-
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.
|
|
76
|
-
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.
|
|
77
|
-
client.set_hvac_mode(family_id=37790, device_id="...", mode=HvacMode.
|
|
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) #
|
|
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 同)
|
|
80
82
|
|
|
81
83
|
# Temperature
|
|
82
84
|
client.set_temperature(family_id=37790, device_id="...", value=24.0) # 16.0–32.0
|
|
@@ -115,19 +117,75 @@ client.get_device_panel_template(family_id=37790, device_id="...")
|
|
|
115
117
|
| Suning App | `xiaobiu` API | `C_*` field | HA climate field |
|
|
116
118
|
|------------|---------------|------------|------------------|
|
|
117
119
|
| 电源开关 | `turn_on/off` | `C_POWER` | `hvac_mode = off` when off |
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
| 一键通 | `set_hvac_mode(QUICK)` | `C_MODE=5` | `hvac_mode = auto` (map) |
|
|
120
|
+
| 制热 | `set_hvac_mode(HEAT)` | `C_MODE=1` | `hvac_mode = heat` |
|
|
121
|
+
| 制冷 | `set_hvac_mode(COOL)` | `C_MODE=2` | `hvac_mode = cool` |
|
|
122
|
+
| 除湿 | `set_hvac_mode(DRY)` | `C_MODE=3` | `hvac_mode = dry` |
|
|
123
|
+
| 送风 | `set_hvac_mode(FAN_ONLY)` | `C_MODE=4` (或 `5`) | `hvac_mode = fan_only` |
|
|
124
|
+
| 一键通/自动 | `set_hvac_mode(AUTO)` / `set_hvac_mode(QUICK)` | `C_MODE=6` | `hvac_mode = auto` |
|
|
124
125
|
| 微风/低/中/高/强风 | `set_fan_mode(SILENT/LOW/MEDIUM/HIGH/TURBO)` | `C_FANSPEED=1..5` | `fan_mode` |
|
|
125
|
-
| 上下摆风 | `set_vertical_swing(on=)` | `C_AIRVERTICAL` | `
|
|
126
|
+
| 上下摆风 | `set_vertical_swing(on=)` | `C_AIRVERTICAL` | `swing_mode` (HA 把 `swing_mode` 默认指垂直) |
|
|
126
127
|
| 左右摆风 | `set_horizontal_swing(on=)` | `C_AIRHORIZONTAL` | `swing_horizontal_mode` |
|
|
127
128
|
| ECO | `set_eco(on=)` | `C_ECO` | `preset_mode = eco` |
|
|
128
129
|
| 空气清新 | `set_fresh_air(on=)` | `C_FRESHAIR` | `preset_mode = fresh_air` |
|
|
129
130
|
| 电辅热 | `set_aux_heat(on=)` | `C_ELECHEATING` | `preset_mode = aux_heat` |
|
|
130
131
|
|
|
132
|
+
> **读/写编码不同**:上表是**写侧**(`C_MODE` 控制值)。设备**上报状态**用的是另一套 `SN_MODE` 值:
|
|
133
|
+
> `SN_MODE=1`(一键通/自动)、`2`(制冷)、`3`(制热)、`4`(送风)、`5`(除湿)。
|
|
134
|
+
> `infer_hvac_mode` 读状态时默认按 `SN_MODE` 解码;下发命令时 `set_hvac_mode` 用 `C_MODE`。
|
|
135
|
+
> 两套编码不一致(如 `C_MODE=1` 是制热,但 `SN_MODE=1` 是一键通),库内部已拆成两张表分别处理。
|
|
136
|
+
|
|
137
|
+
### `swing_mode` 集成注意事项
|
|
138
|
+
|
|
139
|
+
按 Home Assistant climate entity 惯例:
|
|
140
|
+
|
|
141
|
+
- **`swing_mode` 属性专指垂直摆风**。HA 集成作者应在 `async_set_swing_mode(swing_mode)` 里把 `"vertical"` / `"off"` 映射到 `client.set_swing_mode(SwingMode.VERTICAL)` / `SwingMode.OFF`。
|
|
142
|
+
- **`swing_horizontal_mode` 是独立属性**。`"on"` / `"off"` 映射到 `client.set_horizontal_swing(on=True/False)`。
|
|
143
|
+
- **`SwingMode.ON` 不支持**。苏宁设备物理上没有"开摆不指定方向"语义——要么 vertical 要么 horizontal,要么都开。HA 集成遇到 `swing_mode = "on"` 时应映射到 `SwingMode.BOTH`(或 `VERTICAL`)。
|
|
144
|
+
- **`set_swing_mode(SwingMode.HORIZONTAL)` 与 `set_horizontal_swing(on=True)` 设备层等价**(都把 `C_AIRHORIZONTAL` 设为 1),但**HA 集成应走 `set_horizontal_swing`** 保持与 HA 字段语义一致。`set_swing_mode(SwingMode.HORIZONTAL)` 主要给脚本/手动控制用,一次发两字段。
|
|
145
|
+
- **`set_swing_mode(SwingMode.BOTH)` 等价于 `set_vertical_swing(on=True); set_horizontal_swing(on=True)`,但只走一次网络**。HA 集成没有"BOTH"标准值,组合调用更标准。
|
|
146
|
+
|
|
147
|
+
### `hvac_action` 推断
|
|
148
|
+
|
|
149
|
+
`AirConditionerStatus.hvac_action` 由 `ac_control.infer_hvac_action` 在 `_normalize_air_conditioner_status` 时填入,推断规则:
|
|
150
|
+
|
|
151
|
+
| 条件 | 推断 |
|
|
152
|
+
|------|------|
|
|
153
|
+
| `power_on=False` 或 `hvac_mode=off` | `HvacAction.OFF` |
|
|
154
|
+
| `hvac_mode=heat` 且 `current_temp < target_temp` | `HvacAction.HEATING` |
|
|
155
|
+
| `hvac_mode=heat` 且 `current_temp >= target_temp` | `HvacAction.IDLE` |
|
|
156
|
+
| `hvac_mode=cool` 且 `current_temp > target_temp` | `HvacAction.COOLING` |
|
|
157
|
+
| `hvac_mode=cool` 且 `current_temp <= target_temp` | `HvacAction.IDLE` |
|
|
158
|
+
| `hvac_mode=dry` | `HvacAction.DRYING` |
|
|
159
|
+
| `hvac_mode=fan_only` | `HvacAction.FAN` |
|
|
160
|
+
| `hvac_mode=auto` / `heat_cool` | 根据 current vs target 二选一(heating/cooling/idle) |
|
|
161
|
+
| `power_on=None`(设备离线) | `HvacAction=None` → HA 渲染 `unavailable` |
|
|
162
|
+
|
|
163
|
+
### 动态能力表(`DeviceCapabilities`)
|
|
164
|
+
|
|
165
|
+
`client.get_device_panel_template(family_id, device_id)` 现在返回 `DeviceCapabilities`,从 `queryTemplate.do` 实时解析:
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
caps = client.get_device_panel_template(family_id=37790, device_id="000165f9b029afa2e5d8")
|
|
169
|
+
caps.hvac_modes # ["off", "cool", "heat", "dry", "fan_only", "auto", "quick"]
|
|
170
|
+
caps.fan_modes # ["auto", "silent", "low", "medium", "high", "turbo"]
|
|
171
|
+
caps.swing_modes # ["off", "vertical", "horizontal", "both"]
|
|
172
|
+
caps.preset_modes # ["none", "eco", "fresh_air", "aux_heat"]
|
|
173
|
+
caps.supports_vertical_swing # True
|
|
174
|
+
caps.supports_horizontal_swing # True
|
|
175
|
+
caps.supports_eco
|
|
176
|
+
caps.supports_fresh_air
|
|
177
|
+
caps.supports_aux_heat
|
|
178
|
+
caps.fields["C_FANSPEED"].raw_values # ["0","1","2","3","4","5"]
|
|
179
|
+
caps.fields["C_FANSPEED"].display_values # ["自动","微风","低风","中风","高风","强风"]
|
|
180
|
+
caps.fields["C_FANSPEED"].icon_urls # [6 个图标 URL]
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
HA 集成应在 `async_setup_entry` 时调一次 `get_device_panel_template` 缓存起来,**直接喂给 `hvac_modes` / `fan_modes` / `swing_modes` / `preset_modes` 属性**——不要再硬编码列表。
|
|
184
|
+
|
|
185
|
+
### `preset_mode` 自定义值
|
|
186
|
+
|
|
187
|
+
按 HA 文档,自定义 preset 是允许的("you're also allowed to add custom presets")。所以 `fresh_air` 和 `aux_heat` 不在 HA 标准列表里,但 HA 集成**可以**把它们放进 `preset_modes` 列表(中文用户友好)或直接用 `aux_heat` 这个 HA 官方名(与 `turn_aux_heat_on/off` 服务对应)。
|
|
188
|
+
|
|
131
189
|
## CLI
|
|
132
190
|
|
|
133
191
|
```bash
|
|
@@ -157,18 +215,19 @@ xiaobiucli set-fresh-air --family-id 37790 --device-id <id> --on|--off
|
|
|
157
215
|
xiaobiucli set-aux-heat --family-id 37790 --device-id <id> --on|--off
|
|
158
216
|
xiaobiucli timers --family-id 37790 --device-id <id>
|
|
159
217
|
xiaobiucli panel --family-id 37790 --device-id <id>
|
|
218
|
+
xiaobiucli raw-oper --family-id 37790 --device-id <id> --cmd C_MODE=1 [--cmd KEY=VALUE ...]
|
|
160
219
|
```
|
|
161
220
|
|
|
162
221
|
## Notes
|
|
163
222
|
|
|
164
|
-
- **`C_MODE
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
223
|
+
- **`C_MODE` / `SN_MODE` 编码不同**(2026-06-17 真机实测确认):
|
|
224
|
+
- 写侧 `C_MODE`:`1`=制热、`2`=制冷、`3`=除湿、`4`=送风、`5`=送风(同 4)、`6`=一键通(≈自动)
|
|
225
|
+
- 读侧 `SN_MODE`:`1`=一键通(自动)、`2`=制冷、`3`=制热、`4`=送风、`5`=除湿
|
|
226
|
+
- 库内部用 `C_FIELD_TO_HVAC`(写)和 `SN_FIELD_TO_HVAC`(读)两张表分别处理。
|
|
227
|
+
- **一键通 ≈ 自动**:这台设备没有独立的 AUTO 模式,`C_MODE=6`(一键通)在语义上最接近,
|
|
228
|
+
暴露为 `HvacMode.AUTO`;`HvacMode.QUICK` 也指向 `C_MODE=6`。
|
|
229
|
+
- **`C_ELECHEATING` (电辅热)** 值域已实测确认为 `0/1`。`set_aux_heat(on=True)` 在客户端
|
|
230
|
+
强制 App 的"仅制热时生效"规则(当前模式非 HEAT 时 raise `SuningError`)。
|
|
172
231
|
- **`SN_CLOUD_TIMER` writes** are not implemented in this release.
|
|
173
232
|
- **Unknown `C_MODE` values** (e.g. `7`, which neither the App nor the
|
|
174
233
|
capture expose) collapse to `hvac_mode = None` so Home Assistant can
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
xiaobiu/__init__.py,sha256=vuubbRNBH7hN-QW8_-aYQcOjj10OQp26w_7imNU9KO8,837
|
|
2
|
+
xiaobiu/ac_control.py,sha256=uQe3dE6QH13gfF6zgifZbplzfwzmMxmprmwGOTTWpUU,22510
|
|
3
|
+
xiaobiu/ac_status.py,sha256=62ecNZyeUm9SUz0NhVCVj4mcTB3KB78lLQgNNf1P4yY,14915
|
|
4
|
+
xiaobiu/app_api.py,sha256=gJLa-iq60s_YEEM00E4lMcTsBKoV60GtaaqBsWWOWio,4729
|
|
5
|
+
xiaobiu/captcha_bridge.py,sha256=l8c3HnspQt1JDM1sDKnvcM4yvf7NZosSQ7x2AlO-kEA,12920
|
|
6
|
+
xiaobiu/cli.py,sha256=rKbvt7rsV_OcNr5N62JIRhveKzyDwtu2MApSdeDj_fA,18810
|
|
7
|
+
xiaobiu/client.py,sha256=JjE1qtgIHUZsmJ6TGixY--hZ8MI_IoDm4EzxJVZJm4Y,23116
|
|
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=h6lhH0GQIgH9zUwmQLBBAY-SJBZjYr5LMxXqiRVrDOI,6223
|
|
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.2.dist-info/METADATA,sha256=0j5JMYlZGqakiz3C5kJ8FsBodnL7gVzrXevr5CZ_N0M,12632
|
|
16
|
+
python_xiaobiu-0.2.2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
17
|
+
python_xiaobiu-0.2.2.dist-info/entry_points.txt,sha256=w1z8h63RRusoSGAbbSMpNcq4qbN3HOedsMlxwuFH3U8,44
|
|
18
|
+
python_xiaobiu-0.2.2.dist-info/RECORD,,
|
xiaobiu/__init__.py
CHANGED
|
@@ -14,6 +14,7 @@ from .models import (
|
|
|
14
14
|
FamilyInfo,
|
|
15
15
|
FanSpeed,
|
|
16
16
|
HAClimatePreview,
|
|
17
|
+
HvacAction,
|
|
17
18
|
HvacMode,
|
|
18
19
|
LoginPageConfig,
|
|
19
20
|
PanelTemplate,
|
|
@@ -32,6 +33,7 @@ __all__ = [
|
|
|
32
33
|
"FamilyInfo",
|
|
33
34
|
"FanSpeed",
|
|
34
35
|
"HAClimatePreview",
|
|
36
|
+
"HvacAction",
|
|
35
37
|
"HvacMode",
|
|
36
38
|
"LoginPageConfig",
|
|
37
39
|
"PanelTemplate",
|
xiaobiu/ac_control.py
CHANGED
|
@@ -19,7 +19,10 @@ from typing import TYPE_CHECKING, Any, Mapping, Sequence
|
|
|
19
19
|
|
|
20
20
|
from .exceptions import SuningError
|
|
21
21
|
from .models import (
|
|
22
|
+
CapabilityField,
|
|
23
|
+
DeviceCapabilities,
|
|
22
24
|
FanSpeed,
|
|
25
|
+
HvacAction,
|
|
23
26
|
HvacMode,
|
|
24
27
|
PanelTemplate,
|
|
25
28
|
PresetMode,
|
|
@@ -38,15 +41,45 @@ PANEL_QUERY_URL = "https://shcss.suning.com/shcss-web/api/panel/queryTemplate.do
|
|
|
38
41
|
TEMP_MIN_C = 16.0
|
|
39
42
|
TEMP_MAX_C = 32.0
|
|
40
43
|
|
|
44
|
+
# ---------------------------------------------------------------------------
|
|
45
|
+
# Mode mapping tables
|
|
46
|
+
# ---------------------------------------------------------------------------
|
|
47
|
+
#
|
|
48
|
+
# Suning encodes the HVAC mode with *two different* value sets:
|
|
49
|
+
#
|
|
50
|
+
# * ``C_MODE`` (control) — the value you send in an ``appOper`` command.
|
|
51
|
+
# * ``SN_MODE`` (status) — the value the device reports back in its status.
|
|
52
|
+
#
|
|
53
|
+
# They are NOT the same encoding, so reads and writes need separate tables.
|
|
54
|
+
# Values below were confirmed by live-device testing (2026-06-17) plus the
|
|
55
|
+
# ``queryTemplate.do`` panel definition:
|
|
56
|
+
#
|
|
57
|
+
# C_MODE (write): 1=制热 2=制冷 3=除湿 4=送风 5=送风 6=一键通(=自动)
|
|
58
|
+
# SN_MODE (read): 1=一键通 2=制冷 3=制热 4=送风 5=除湿
|
|
59
|
+
#
|
|
60
|
+
# Note: this device has no dedicated AUTO mode; ``C_MODE=6`` (一键通) is the
|
|
61
|
+
# closest semantic match and is exposed as ``HvacMode.AUTO``. ``C_MODE=5``
|
|
62
|
+
# behaves the same as ``4`` (送风) on the tested device.
|
|
63
|
+
|
|
64
|
+
# Write side: C_MODE control value → HvacMode
|
|
41
65
|
C_FIELD_TO_HVAC: dict[str, HvacMode] = {
|
|
42
|
-
"1": HvacMode.
|
|
43
|
-
"2": HvacMode.
|
|
44
|
-
"3": HvacMode.
|
|
45
|
-
"4": HvacMode.
|
|
46
|
-
"5": HvacMode.
|
|
66
|
+
"1": HvacMode.HEAT,
|
|
67
|
+
"2": HvacMode.COOL,
|
|
68
|
+
"3": HvacMode.DRY,
|
|
69
|
+
"4": HvacMode.FAN_ONLY,
|
|
70
|
+
"5": HvacMode.FAN_ONLY,
|
|
47
71
|
"6": HvacMode.AUTO,
|
|
48
72
|
}
|
|
49
73
|
|
|
74
|
+
# Read side: SN_MODE status value → HvacMode
|
|
75
|
+
SN_FIELD_TO_HVAC: dict[str, HvacMode] = {
|
|
76
|
+
"1": HvacMode.AUTO,
|
|
77
|
+
"2": HvacMode.COOL,
|
|
78
|
+
"3": HvacMode.HEAT,
|
|
79
|
+
"4": HvacMode.FAN_ONLY,
|
|
80
|
+
"5": HvacMode.DRY,
|
|
81
|
+
}
|
|
82
|
+
|
|
50
83
|
C_FIELD_TO_FAN: dict[str, FanSpeed] = {
|
|
51
84
|
"0": FanSpeed.AUTO,
|
|
52
85
|
"1": FanSpeed.SILENT,
|
|
@@ -56,7 +89,16 @@ C_FIELD_TO_FAN: dict[str, FanSpeed] = {
|
|
|
56
89
|
"5": FanSpeed.TURBO,
|
|
57
90
|
}
|
|
58
91
|
|
|
59
|
-
|
|
92
|
+
# HvacMode → preferred C_MODE control value (first write-table hit wins).
|
|
93
|
+
# QUICK shares C_MODE=6 with AUTO on the tested device (一键通 ≈ 自动).
|
|
94
|
+
HVAC_TO_C_FIELD: dict[HvacMode, str] = {
|
|
95
|
+
HvacMode.HEAT: "1",
|
|
96
|
+
HvacMode.COOL: "2",
|
|
97
|
+
HvacMode.DRY: "3",
|
|
98
|
+
HvacMode.FAN_ONLY: "4",
|
|
99
|
+
HvacMode.AUTO: "6",
|
|
100
|
+
HvacMode.QUICK: "6",
|
|
101
|
+
}
|
|
60
102
|
FAN_TO_C_FIELD: dict[FanSpeed, str] = {speed: raw for raw, speed in C_FIELD_TO_FAN.items()}
|
|
61
103
|
|
|
62
104
|
SWING_TO_CMD: dict[SwingMode, dict[str, str]] = {
|
|
@@ -169,19 +211,33 @@ def get_device_panel_template(
|
|
|
169
211
|
model_id: str,
|
|
170
212
|
*,
|
|
171
213
|
category_id: str = "0002",
|
|
172
|
-
|
|
173
|
-
|
|
214
|
+
template_id: str = "PANEL_AC",
|
|
215
|
+
) -> DeviceCapabilities | None:
|
|
216
|
+
"""Fetch the device's :class:`DeviceCapabilities`.
|
|
174
217
|
|
|
175
218
|
Returns ``None`` on any failure (HTTP error, malformed JSON, code != 0)
|
|
176
|
-
so the caller can keep going on a partial response.
|
|
219
|
+
so the caller can keep going on a partial response. Kept the legacy
|
|
220
|
+
name for backward compatibility — the returned object's
|
|
221
|
+
:class:`DeviceCapabilities` includes a ``raw`` payload carrying the
|
|
222
|
+
unparsed template.
|
|
223
|
+
|
|
224
|
+
The panel endpoint (``queryTemplate.do``) is queried with ``modelId``
|
|
225
|
+
and ``templateId`` (confirmed from a live HAR capture). A ``userid``
|
|
226
|
+
header carrying the logged-in user's ``custno`` cookie value is sent
|
|
227
|
+
so the server returns the full template instead of a login redirect.
|
|
177
228
|
"""
|
|
178
229
|
|
|
179
|
-
query =
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
230
|
+
query = f"{PANEL_QUERY_URL}?modelId={model_id}&templateId={template_id}"
|
|
231
|
+
headers: dict[str, str] = {}
|
|
232
|
+
custno = None
|
|
233
|
+
try:
|
|
234
|
+
custno = client.session.cookies.get("custno")
|
|
235
|
+
except Exception:
|
|
236
|
+
pass
|
|
237
|
+
if custno:
|
|
238
|
+
headers["userid"] = str(custno)
|
|
183
239
|
try:
|
|
184
|
-
response = client.session.get(query, timeout=client.timeout)
|
|
240
|
+
response = client.session.get(query, timeout=client.timeout, headers=headers)
|
|
185
241
|
response.raise_for_status()
|
|
186
242
|
payload = response.json()
|
|
187
243
|
except Exception:
|
|
@@ -195,10 +251,126 @@ def get_device_panel_template(
|
|
|
195
251
|
components = parse_panel_components(containers)
|
|
196
252
|
if components is None:
|
|
197
253
|
return None
|
|
198
|
-
return
|
|
254
|
+
return build_capabilities_from_template(
|
|
199
255
|
device_id=device_id,
|
|
200
256
|
model_id=model_id,
|
|
201
|
-
|
|
257
|
+
category_id=category_id,
|
|
258
|
+
fields=components,
|
|
259
|
+
raw=data_block,
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def build_capabilities_from_template(
|
|
264
|
+
*,
|
|
265
|
+
device_id: str,
|
|
266
|
+
model_id: str,
|
|
267
|
+
category_id: str,
|
|
268
|
+
fields: list[str],
|
|
269
|
+
raw: Mapping[str, Any] | None = None,
|
|
270
|
+
) -> DeviceCapabilities:
|
|
271
|
+
"""Build a :class:`DeviceCapabilities` from a flattened field set.
|
|
272
|
+
|
|
273
|
+
``fields`` is the sorted list of ``C_*`` / ``SN_*`` keys returned by
|
|
274
|
+
:func:`parse_panel_components`. The boolean support flags are derived
|
|
275
|
+
from membership; the HA-facing ``*_modes`` lists always include
|
|
276
|
+
the standard ``off`` sentinel so the integration can render the
|
|
277
|
+
toggle.
|
|
278
|
+
"""
|
|
279
|
+
|
|
280
|
+
raw_dict = dict(raw) if raw else {}
|
|
281
|
+
keys_block = raw_dict.get("keys") or []
|
|
282
|
+
field_map: dict[str, CapabilityField] = {}
|
|
283
|
+
for key_entry in keys_block:
|
|
284
|
+
if not isinstance(key_entry, Mapping):
|
|
285
|
+
continue
|
|
286
|
+
raw_key = str(key_entry.get("key") or "")
|
|
287
|
+
if not raw_key:
|
|
288
|
+
continue
|
|
289
|
+
field_map[raw_key] = CapabilityField(
|
|
290
|
+
key=raw_key,
|
|
291
|
+
name=str(key_entry.get("name") or raw_key),
|
|
292
|
+
type=str(key_entry.get("type") or ""),
|
|
293
|
+
raw_values=[str(v) for v in (key_entry.get("k") or [])],
|
|
294
|
+
display_values=[str(v) for v in (key_entry.get("v") or [])],
|
|
295
|
+
sn_property_id=key_entry.get("snPropertyId"),
|
|
296
|
+
icon_urls=[str(u) for u in (key_entry.get("icon") or [])],
|
|
297
|
+
raw=dict(key_entry),
|
|
298
|
+
)
|
|
299
|
+
# Fallback: when the panel template lacks a ``keys`` block, seed the
|
|
300
|
+
# field map with placeholder CapabilityFields derived from the
|
|
301
|
+
# flattened field set so callers can still ask ``"C_POWER" in
|
|
302
|
+
# caps.fields``.
|
|
303
|
+
for raw_key in fields:
|
|
304
|
+
if raw_key in field_map:
|
|
305
|
+
continue
|
|
306
|
+
field_map[raw_key] = CapabilityField(
|
|
307
|
+
key=raw_key,
|
|
308
|
+
name=raw_key,
|
|
309
|
+
type="",
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
has = set(fields)
|
|
313
|
+
hvac_modes: list[str] = []
|
|
314
|
+
# Build the hvac_modes list from the C_MODE control values the panel
|
|
315
|
+
# actually advertises (its ``k`` array), mapped through the write table.
|
|
316
|
+
# ``off`` is always offered (power toggle). Unknown C_MODE values that
|
|
317
|
+
# have no HvacMode mapping are simply skipped. When the panel template
|
|
318
|
+
# lacks a ``k`` array for C_MODE (e.g. no ``raw`` was supplied), fall back
|
|
319
|
+
# to the full set of known modes so callers still get a usable list.
|
|
320
|
+
if "C_MODE" in has:
|
|
321
|
+
hvac_modes = [HvacMode.OFF.value]
|
|
322
|
+
seen: set[str] = {HvacMode.OFF.value}
|
|
323
|
+
mode_field = field_map.get("C_MODE")
|
|
324
|
+
advertised = mode_field.raw_values if mode_field is not None else []
|
|
325
|
+
if not advertised:
|
|
326
|
+
advertised = list(C_FIELD_TO_HVAC.keys())
|
|
327
|
+
for raw_val in advertised:
|
|
328
|
+
mapped = C_FIELD_TO_HVAC.get(str(raw_val).strip())
|
|
329
|
+
if mapped is not None and mapped.value not in seen:
|
|
330
|
+
hvac_modes.append(mapped.value)
|
|
331
|
+
seen.add(mapped.value)
|
|
332
|
+
fan_modes: list[str] = []
|
|
333
|
+
if "C_FANSPEED" in has:
|
|
334
|
+
fan_modes = [
|
|
335
|
+
FanSpeed.AUTO.value,
|
|
336
|
+
FanSpeed.SILENT.value,
|
|
337
|
+
FanSpeed.LOW.value,
|
|
338
|
+
FanSpeed.MEDIUM.value,
|
|
339
|
+
FanSpeed.HIGH.value,
|
|
340
|
+
FanSpeed.TURBO.value,
|
|
341
|
+
]
|
|
342
|
+
swing_modes: list[str] = []
|
|
343
|
+
if "C_AIRVERTICAL" in has or "C_AIRHORIZONTAL" in has:
|
|
344
|
+
swing_modes = [
|
|
345
|
+
SwingMode.OFF.value,
|
|
346
|
+
SwingMode.VERTICAL.value,
|
|
347
|
+
SwingMode.HORIZONTAL.value,
|
|
348
|
+
SwingMode.BOTH.value,
|
|
349
|
+
]
|
|
350
|
+
preset_modes: list[str] = [PresetMode.NONE.value]
|
|
351
|
+
if "C_ECO" in has:
|
|
352
|
+
preset_modes.append(PresetMode.ECO.value)
|
|
353
|
+
if "C_FRESHAIR" in has:
|
|
354
|
+
preset_modes.append(PresetMode.FRESH_AIR.value)
|
|
355
|
+
if "C_ELECHEATING" in has:
|
|
356
|
+
preset_modes.append(PresetMode.AUX_HEAT.value)
|
|
357
|
+
|
|
358
|
+
return DeviceCapabilities(
|
|
359
|
+
device_id=device_id,
|
|
360
|
+
model_id=model_id,
|
|
361
|
+
category_id=category_id,
|
|
362
|
+
fields=field_map,
|
|
363
|
+
hvac_modes=hvac_modes,
|
|
364
|
+
fan_modes=fan_modes,
|
|
365
|
+
swing_modes=swing_modes,
|
|
366
|
+
preset_modes=preset_modes,
|
|
367
|
+
supports_vertical_swing="C_AIRVERTICAL" in has,
|
|
368
|
+
supports_horizontal_swing="C_AIRHORIZONTAL" in has,
|
|
369
|
+
supports_eco="C_ECO" in has,
|
|
370
|
+
supports_fresh_air="C_FRESHAIR" in has,
|
|
371
|
+
supports_aux_heat="C_ELECHEATING" in has,
|
|
372
|
+
supports_target_temperature="C_TEMPERATURE" in has,
|
|
373
|
+
raw=raw_dict,
|
|
202
374
|
)
|
|
203
375
|
|
|
204
376
|
|
|
@@ -243,13 +415,30 @@ def list_device_timers(client: Any, device_id: str) -> list[Timer]:
|
|
|
243
415
|
return timers
|
|
244
416
|
|
|
245
417
|
|
|
246
|
-
def infer_hvac_mode(
|
|
418
|
+
def infer_hvac_mode(
|
|
419
|
+
*,
|
|
420
|
+
power_on: bool | None,
|
|
421
|
+
mode_raw: Any,
|
|
422
|
+
field_kind: str = "sn",
|
|
423
|
+
) -> HvacMode | None:
|
|
247
424
|
"""Translate raw status fields into a typed HVAC mode.
|
|
248
425
|
|
|
249
426
|
``power_on is False`` always wins and yields ``HvacMode.OFF``; only an
|
|
250
427
|
explicitly powered-on device is mapped to a running mode. Unknown
|
|
251
|
-
mode values
|
|
252
|
-
``
|
|
428
|
+
mode values collapse to ``None`` so the caller can render an
|
|
429
|
+
``unavailable`` preview.
|
|
430
|
+
|
|
431
|
+
``field_kind`` selects the encoding table:
|
|
432
|
+
|
|
433
|
+
* ``"sn"`` (default) — ``mode_raw`` is an ``SN_MODE`` *status* value
|
|
434
|
+
(read from the device status payload); uses :data:`SN_FIELD_TO_HVAC`.
|
|
435
|
+
* ``"c"`` — ``mode_raw`` is a ``C_MODE`` *control* value (the value
|
|
436
|
+
you would send in an ``appOper`` command); uses
|
|
437
|
+
:data:`C_FIELD_TO_HVAC`.
|
|
438
|
+
|
|
439
|
+
The two encodings differ on this device (e.g. ``C_MODE=1`` is 制热 but
|
|
440
|
+
``SN_MODE=1`` is 一键通/自动), so callers reading device status should
|
|
441
|
+
keep the default ``"sn"``.
|
|
253
442
|
"""
|
|
254
443
|
|
|
255
444
|
if power_on is False:
|
|
@@ -258,7 +447,8 @@ def infer_hvac_mode(*, power_on: bool | None, mode_raw: Any) -> HvacMode | None:
|
|
|
258
447
|
return None
|
|
259
448
|
if mode_raw is None:
|
|
260
449
|
return None
|
|
261
|
-
|
|
450
|
+
table = SN_FIELD_TO_HVAC if field_kind != "c" else C_FIELD_TO_HVAC
|
|
451
|
+
return table.get(str(mode_raw).strip())
|
|
262
452
|
|
|
263
453
|
|
|
264
454
|
def infer_fan_speed(speed_raw: Any) -> FanSpeed | None:
|
|
@@ -269,6 +459,54 @@ def infer_fan_speed(speed_raw: Any) -> FanSpeed | None:
|
|
|
269
459
|
return C_FIELD_TO_FAN.get(str(speed_raw).strip())
|
|
270
460
|
|
|
271
461
|
|
|
462
|
+
def infer_hvac_action(
|
|
463
|
+
*,
|
|
464
|
+
power_on: bool | None,
|
|
465
|
+
hvac_mode: HvacMode | str | None,
|
|
466
|
+
current_temp: float | None,
|
|
467
|
+
target_temp: float | None,
|
|
468
|
+
) -> HvacAction | None:
|
|
469
|
+
"""Infer the device's current :class:`HvacAction` from its status fields.
|
|
470
|
+
|
|
471
|
+
Power off → ``OFF``. Mode is ``DRY`` / ``FAN_ONLY`` → ``DRYING`` / ``FAN``.
|
|
472
|
+
Mode is ``HEAT`` or ``COOL`` → ``HEATING`` / ``COOLING`` if there is still
|
|
473
|
+
work to do (current temp below / above target), else ``IDLE``.
|
|
474
|
+
Mode is ``AUTO`` → behave like ``HEAT_COOL``: pick the side that has work.
|
|
475
|
+
``HEAT_COOL`` itself collapses to whichever side has work (else ``IDLE``).
|
|
476
|
+
When ``power_on`` is unknown we return ``None`` so HA can render
|
|
477
|
+
``unavailable`` rather than guess.
|
|
478
|
+
"""
|
|
479
|
+
|
|
480
|
+
if power_on is None:
|
|
481
|
+
return None
|
|
482
|
+
if power_on is False:
|
|
483
|
+
return HvacAction.OFF
|
|
484
|
+
if hvac_mode is None:
|
|
485
|
+
return HvacAction.IDLE
|
|
486
|
+
mode_value = hvac_mode.value if isinstance(hvac_mode, HvacMode) else str(hvac_mode)
|
|
487
|
+
if mode_value == HvacMode.OFF.value:
|
|
488
|
+
return HvacAction.OFF
|
|
489
|
+
if mode_value == HvacMode.DRY.value:
|
|
490
|
+
return HvacAction.DRYING
|
|
491
|
+
if mode_value == HvacMode.FAN_ONLY.value:
|
|
492
|
+
return HvacAction.FAN
|
|
493
|
+
if current_temp is None or target_temp is None:
|
|
494
|
+
return HvacAction.IDLE
|
|
495
|
+
if mode_value == HvacMode.HEAT.value:
|
|
496
|
+
return HvacAction.HEATING if current_temp < target_temp else HvacAction.IDLE
|
|
497
|
+
if mode_value == HvacMode.COOL.value:
|
|
498
|
+
return HvacAction.COOLING if current_temp > target_temp else HvacAction.IDLE
|
|
499
|
+
# AUTO and QUICK (一键通) both behave like HEAT_COOL: pick the side
|
|
500
|
+
# that has work to do.
|
|
501
|
+
if mode_value in (HvacMode.AUTO.value, HvacMode.QUICK.value, HvacMode.HEAT_COOL.value):
|
|
502
|
+
if current_temp < target_temp:
|
|
503
|
+
return HvacAction.HEATING
|
|
504
|
+
if current_temp > target_temp:
|
|
505
|
+
return HvacAction.COOLING
|
|
506
|
+
return HvacAction.IDLE
|
|
507
|
+
return HvacAction.IDLE
|
|
508
|
+
|
|
509
|
+
|
|
272
510
|
# ---------------------------------------------------------------------------
|
|
273
511
|
# High-level helpers
|
|
274
512
|
# ---------------------------------------------------------------------------
|
|
@@ -468,6 +706,7 @@ __all__ = [
|
|
|
468
706
|
"PRESET_ON_CMD",
|
|
469
707
|
"PanelTemplate",
|
|
470
708
|
"QUERY_TIMER_URL",
|
|
709
|
+
"SN_FIELD_TO_HVAC",
|
|
471
710
|
"SWING_TO_CMD",
|
|
472
711
|
"TEMP_MAX_C",
|
|
473
712
|
"TEMP_MIN_C",
|
xiaobiu/ac_status.py
CHANGED
|
@@ -23,8 +23,10 @@ from .models import (
|
|
|
23
23
|
AirConditionerStatus,
|
|
24
24
|
FamilyInfo,
|
|
25
25
|
HAClimatePreview,
|
|
26
|
+
HvacAction,
|
|
26
27
|
HvacMode,
|
|
27
28
|
)
|
|
29
|
+
from . import ac_control
|
|
28
30
|
|
|
29
31
|
MEMBER_BASE_INFO_URL = "https://shcss.suning.com/shcss-web/api/member/queryMemberBaseInfo.do"
|
|
30
32
|
FAMILY_LIST_URL = "https://itapig.suning.com/api/trade/shcss/queryAllFamily"
|
|
@@ -226,13 +228,33 @@ def _normalize_air_conditioner_status(device: dict[str, Any]) -> AirConditionerS
|
|
|
226
228
|
_coalesce(raw_status.get("SN_AIRVERTICAL"), raw_status.get("C_AIRVERTICAL"))
|
|
227
229
|
)
|
|
228
230
|
eco_enabled = _parse_bool_flag(_coalesce(raw_status.get("SN_ECO"), raw_status.get("C_ECO")))
|
|
229
|
-
purify_enabled = _parse_bool_flag(
|
|
230
|
-
|
|
231
|
+
purify_enabled = _parse_bool_flag(
|
|
232
|
+
_coalesce(raw_status.get("SN_PURIFY"), raw_status.get("C_FRESHAIR"))
|
|
233
|
+
)
|
|
234
|
+
fresh_air_enabled = _parse_bool_flag(
|
|
235
|
+
_coalesce(raw_status.get("C_FRESHAIR"), raw_status.get("SN_PURIFY"))
|
|
236
|
+
)
|
|
231
237
|
electric_heating_enabled = _parse_bool_flag(
|
|
232
238
|
_coalesce(raw_status.get("SN_ELECHEATING"), raw_status.get("C_ELECHEATING"))
|
|
233
239
|
)
|
|
234
|
-
|
|
235
|
-
|
|
240
|
+
sn_mode_raw = _coalesce(raw_status.get("SN_MODE"))
|
|
241
|
+
mode_raw = _coalesce(sn_mode_raw, raw_status.get("C_MODE"))
|
|
242
|
+
mode_field_kind = "sn" if sn_mode_raw is not None else "c"
|
|
243
|
+
hvac_mode = (
|
|
244
|
+
infer_hvac_mode(power_on=power_on, mode_raw=mode_raw, field_kind=mode_field_kind)
|
|
245
|
+
if online
|
|
246
|
+
else None
|
|
247
|
+
)
|
|
248
|
+
hvac_action = (
|
|
249
|
+
ac_control.infer_hvac_action(
|
|
250
|
+
power_on=power_on,
|
|
251
|
+
hvac_mode=hvac_mode,
|
|
252
|
+
current_temp=current_temperature,
|
|
253
|
+
target_temp=target_temperature,
|
|
254
|
+
)
|
|
255
|
+
if online
|
|
256
|
+
else None
|
|
257
|
+
)
|
|
236
258
|
|
|
237
259
|
status = AirConditionerStatus(
|
|
238
260
|
device_id=str(device.get("id")),
|
|
@@ -249,6 +271,7 @@ def _normalize_air_conditioner_status(device: dict[str, Any]) -> AirConditionerS
|
|
|
249
271
|
refresh_time=raw_status.get("refreshTime"),
|
|
250
272
|
power_on=power_on,
|
|
251
273
|
hvac_mode=hvac_mode,
|
|
274
|
+
hvac_action=hvac_action,
|
|
252
275
|
current_temperature=current_temperature,
|
|
253
276
|
target_temperature=target_temperature,
|
|
254
277
|
outdoor_temperature=outdoor_temperature,
|
|
@@ -269,12 +292,19 @@ def _normalize_air_conditioner_status(device: dict[str, Any]) -> AirConditionerS
|
|
|
269
292
|
)
|
|
270
293
|
|
|
271
294
|
|
|
272
|
-
def infer_hvac_mode(
|
|
295
|
+
def infer_hvac_mode(
|
|
296
|
+
*,
|
|
297
|
+
power_on: bool | None,
|
|
298
|
+
mode_raw: Any,
|
|
299
|
+
field_kind: str = "sn",
|
|
300
|
+
) -> HvacMode | None:
|
|
273
301
|
"""Translate raw status fields into a typed :class:`HvacMode`."""
|
|
274
302
|
|
|
275
303
|
from . import ac_control
|
|
276
304
|
|
|
277
|
-
return ac_control.infer_hvac_mode(
|
|
305
|
+
return ac_control.infer_hvac_mode(
|
|
306
|
+
power_on=power_on, mode_raw=mode_raw, field_kind=field_kind,
|
|
307
|
+
)
|
|
278
308
|
|
|
279
309
|
|
|
280
310
|
def _is_air_conditioner_device(device: dict[str, Any]) -> bool:
|
xiaobiu/cli.py
CHANGED
|
@@ -159,6 +159,21 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
159
159
|
add_shared_arguments(panel_cmd)
|
|
160
160
|
panel_cmd.add_argument("--family-id", required=True)
|
|
161
161
|
panel_cmd.add_argument("--device-id", required=True)
|
|
162
|
+
|
|
163
|
+
raw_oper = subparsers.add_parser(
|
|
164
|
+
"raw-oper",
|
|
165
|
+
help="直接下发任意 C_*/SN_* 字段到 appOper,绕开模式映射表(用于协议实测)",
|
|
166
|
+
)
|
|
167
|
+
add_shared_arguments(raw_oper)
|
|
168
|
+
raw_oper.add_argument("--family-id", required=True)
|
|
169
|
+
raw_oper.add_argument("--device-id", required=True)
|
|
170
|
+
raw_oper.add_argument(
|
|
171
|
+
"--cmd",
|
|
172
|
+
action="append",
|
|
173
|
+
required=True,
|
|
174
|
+
metavar="KEY=VALUE",
|
|
175
|
+
help="要下发的字段,可多次指定,例如 --cmd C_MODE=1 --cmd C_FANSPEED=0",
|
|
176
|
+
)
|
|
162
177
|
return parser
|
|
163
178
|
|
|
164
179
|
|
|
@@ -488,6 +503,28 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
488
503
|
template.model_dump(mode="json") if template is not None else None,
|
|
489
504
|
)
|
|
490
505
|
return 0
|
|
506
|
+
if args.command == "raw-oper":
|
|
507
|
+
cmd: dict[str, str] = {}
|
|
508
|
+
for piece in args.cmd:
|
|
509
|
+
if "=" not in piece:
|
|
510
|
+
raise SuningError(f"--cmd 必须是 KEY=VALUE 形式,收到: {piece!r}")
|
|
511
|
+
key, value = piece.split("=", 1)
|
|
512
|
+
cmd[key.strip()] = value.strip()
|
|
513
|
+
target_device, model_id = client._resolve_ac_target(
|
|
514
|
+
args.family_id, args.device_id,
|
|
515
|
+
)
|
|
516
|
+
payload = client.app_oper(target_device, model_id, cmd)
|
|
517
|
+
_print_payload(
|
|
518
|
+
{
|
|
519
|
+
"status": "ok",
|
|
520
|
+
"command": "raw-oper",
|
|
521
|
+
"device_id": target_device,
|
|
522
|
+
"model_id": model_id,
|
|
523
|
+
"cmd": cmd,
|
|
524
|
+
"response": payload,
|
|
525
|
+
},
|
|
526
|
+
)
|
|
527
|
+
return 0
|
|
491
528
|
except CaptchaRequiredError as error:
|
|
492
529
|
_print_payload(
|
|
493
530
|
{
|
xiaobiu/client.py
CHANGED
|
@@ -366,8 +366,12 @@ class SuningSmartHomeClient:
|
|
|
366
366
|
def _build_ha_climate_preview(self, status: AirConditionerStatus) -> Any:
|
|
367
367
|
return ac_status._build_ha_climate_preview(status)
|
|
368
368
|
|
|
369
|
-
def _infer_hvac_mode(
|
|
370
|
-
|
|
369
|
+
def _infer_hvac_mode(
|
|
370
|
+
self, *, power_on: bool | None, mode_raw: Any, field_kind: str = "sn",
|
|
371
|
+
) -> HvacMode | None:
|
|
372
|
+
return ac_status.infer_hvac_mode(
|
|
373
|
+
power_on=power_on, mode_raw=mode_raw, field_kind=field_kind,
|
|
374
|
+
)
|
|
371
375
|
|
|
372
376
|
# SMS-login private helpers (re-exported for the test suite).
|
|
373
377
|
def _captcha_fields(self, captcha: CaptchaSolution) -> dict[str, str]:
|
xiaobiu/models.py
CHANGED
|
@@ -98,6 +98,7 @@ class AirConditionerStatus(SuningBaseModel):
|
|
|
98
98
|
refresh_time: str | None = None
|
|
99
99
|
power_on: bool | None = None
|
|
100
100
|
hvac_mode: HvacMode | None = None
|
|
101
|
+
hvac_action: HvacAction | None = None
|
|
101
102
|
current_temperature: float | None = None
|
|
102
103
|
target_temperature: float | None = None
|
|
103
104
|
outdoor_temperature: float | None = None
|
|
@@ -146,6 +147,19 @@ class HvacMode(str, Enum):
|
|
|
146
147
|
QUICK = "quick"
|
|
147
148
|
|
|
148
149
|
|
|
150
|
+
class HvacAction(str, Enum):
|
|
151
|
+
"""What the AC is actively doing right now — mirrors HA's HVACAction enum."""
|
|
152
|
+
|
|
153
|
+
OFF = "off"
|
|
154
|
+
PREHEATING = "preheating"
|
|
155
|
+
HEATING = "heating"
|
|
156
|
+
COOLING = "cooling"
|
|
157
|
+
DRYING = "drying"
|
|
158
|
+
FAN = "fan"
|
|
159
|
+
IDLE = "idle"
|
|
160
|
+
DEFROSTING = "defrosting"
|
|
161
|
+
|
|
162
|
+
|
|
149
163
|
class FanSpeed(str, Enum):
|
|
150
164
|
AUTO = "auto"
|
|
151
165
|
SILENT = "silent"
|
|
@@ -180,3 +194,43 @@ class Timer(SuningBaseModel):
|
|
|
180
194
|
schedule: str
|
|
181
195
|
enabled: bool
|
|
182
196
|
command: dict[str, str] = Field(default_factory=dict)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class CapabilityField(SuningBaseModel):
|
|
200
|
+
"""One field advertised by the device's panel template (e.g. ``C_FANSPEED``)."""
|
|
201
|
+
|
|
202
|
+
key: str
|
|
203
|
+
name: str
|
|
204
|
+
type: str
|
|
205
|
+
raw_values: list[str] = Field(default_factory=list)
|
|
206
|
+
display_values: list[str] = Field(default_factory=list)
|
|
207
|
+
sn_property_id: str | None = None
|
|
208
|
+
icon_urls: list[str] = Field(default_factory=list)
|
|
209
|
+
raw: dict[str, Any] = Field(default_factory=dict)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class DeviceCapabilities(SuningBaseModel):
|
|
213
|
+
"""Capabilities advertised by the device's panel template.
|
|
214
|
+
|
|
215
|
+
Drives the HA climate entity's ``hvac_modes`` / ``fan_modes`` /
|
|
216
|
+
``swing_modes`` / ``preset_modes`` lists so the integration can
|
|
217
|
+
advertise only what the device actually supports.
|
|
218
|
+
"""
|
|
219
|
+
|
|
220
|
+
device_id: str
|
|
221
|
+
model_id: str
|
|
222
|
+
category_id: str
|
|
223
|
+
fields: dict[str, CapabilityField] = Field(default_factory=dict)
|
|
224
|
+
hvac_modes: list[str] = Field(default_factory=list)
|
|
225
|
+
fan_modes: list[str] = Field(default_factory=list)
|
|
226
|
+
swing_modes: list[str] = Field(default_factory=list)
|
|
227
|
+
preset_modes: list[str] = Field(default_factory=list)
|
|
228
|
+
supports_vertical_swing: bool = False
|
|
229
|
+
supports_horizontal_swing: bool = False
|
|
230
|
+
supports_eco: bool = False
|
|
231
|
+
supports_fresh_air: bool = False
|
|
232
|
+
supports_aux_heat: bool = False
|
|
233
|
+
supports_target_temperature: bool = True
|
|
234
|
+
min_target_temperature: float = 16.0
|
|
235
|
+
max_target_temperature: float = 32.0
|
|
236
|
+
raw: dict[str, Any] = Field(default_factory=dict)
|
|
@@ -1,18 +0,0 @@
|
|
|
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,,
|
|
File without changes
|
|
File without changes
|