python-xiaobiu 0.2.0__py3-none-any.whl → 0.2.1__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.1.dist-info}/METADATA +54 -2
- {python_xiaobiu-0.2.0.dist-info → python_xiaobiu-0.2.1.dist-info}/RECORD +8 -8
- xiaobiu/__init__.py +2 -0
- xiaobiu/ac_control.py +169 -5
- xiaobiu/ac_status.py +13 -0
- xiaobiu/models.py +54 -0
- {python_xiaobiu-0.2.0.dist-info → python_xiaobiu-0.2.1.dist-info}/WHEEL +0 -0
- {python_xiaobiu-0.2.0.dist-info → python_xiaobiu-0.2.1.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.1
|
|
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
|
|
@@ -122,12 +122,64 @@ client.get_device_panel_template(family_id=37790, device_id="...")
|
|
|
122
122
|
| 自动 | `set_hvac_mode(AUTO)` | `C_MODE=6` | `hvac_mode = auto` |
|
|
123
123
|
| 一键通 | `set_hvac_mode(QUICK)` | `C_MODE=5` | `hvac_mode = auto` (map) |
|
|
124
124
|
| 微风/低/中/高/强风 | `set_fan_mode(SILENT/LOW/MEDIUM/HIGH/TURBO)` | `C_FANSPEED=1..5` | `fan_mode` |
|
|
125
|
-
| 上下摆风 | `set_vertical_swing(on=)` | `C_AIRVERTICAL` | `
|
|
125
|
+
| 上下摆风 | `set_vertical_swing(on=)` | `C_AIRVERTICAL` | `swing_mode` (HA 把 `swing_mode` 默认指垂直) |
|
|
126
126
|
| 左右摆风 | `set_horizontal_swing(on=)` | `C_AIRHORIZONTAL` | `swing_horizontal_mode` |
|
|
127
127
|
| ECO | `set_eco(on=)` | `C_ECO` | `preset_mode = eco` |
|
|
128
128
|
| 空气清新 | `set_fresh_air(on=)` | `C_FRESHAIR` | `preset_mode = fresh_air` |
|
|
129
129
|
| 电辅热 | `set_aux_heat(on=)` | `C_ELECHEATING` | `preset_mode = aux_heat` |
|
|
130
130
|
|
|
131
|
+
### `swing_mode` 集成注意事项
|
|
132
|
+
|
|
133
|
+
按 Home Assistant climate entity 惯例:
|
|
134
|
+
|
|
135
|
+
- **`swing_mode` 属性专指垂直摆风**。HA 集成作者应在 `async_set_swing_mode(swing_mode)` 里把 `"vertical"` / `"off"` 映射到 `client.set_swing_mode(SwingMode.VERTICAL)` / `SwingMode.OFF`。
|
|
136
|
+
- **`swing_horizontal_mode` 是独立属性**。`"on"` / `"off"` 映射到 `client.set_horizontal_swing(on=True/False)`。
|
|
137
|
+
- **`SwingMode.ON` 不支持**。苏宁设备物理上没有"开摆不指定方向"语义——要么 vertical 要么 horizontal,要么都开。HA 集成遇到 `swing_mode = "on"` 时应映射到 `SwingMode.BOTH`(或 `VERTICAL`)。
|
|
138
|
+
- **`set_swing_mode(SwingMode.HORIZONTAL)` 与 `set_horizontal_swing(on=True)` 设备层等价**(都把 `C_AIRHORIZONTAL` 设为 1),但**HA 集成应走 `set_horizontal_swing`** 保持与 HA 字段语义一致。`set_swing_mode(SwingMode.HORIZONTAL)` 主要给脚本/手动控制用,一次发两字段。
|
|
139
|
+
- **`set_swing_mode(SwingMode.BOTH)` 等价于 `set_vertical_swing(on=True); set_horizontal_swing(on=True)`,但只走一次网络**。HA 集成没有"BOTH"标准值,组合调用更标准。
|
|
140
|
+
|
|
141
|
+
### `hvac_action` 推断
|
|
142
|
+
|
|
143
|
+
`AirConditionerStatus.hvac_action` 由 `ac_control.infer_hvac_action` 在 `_normalize_air_conditioner_status` 时填入,推断规则:
|
|
144
|
+
|
|
145
|
+
| 条件 | 推断 |
|
|
146
|
+
|------|------|
|
|
147
|
+
| `power_on=False` 或 `hvac_mode=off` | `HvacAction.OFF` |
|
|
148
|
+
| `hvac_mode=heat` 且 `current_temp < target_temp` | `HvacAction.HEATING` |
|
|
149
|
+
| `hvac_mode=heat` 且 `current_temp >= target_temp` | `HvacAction.IDLE` |
|
|
150
|
+
| `hvac_mode=cool` 且 `current_temp > target_temp` | `HvacAction.COOLING` |
|
|
151
|
+
| `hvac_mode=cool` 且 `current_temp <= target_temp` | `HvacAction.IDLE` |
|
|
152
|
+
| `hvac_mode=dry` | `HvacAction.DRYING` |
|
|
153
|
+
| `hvac_mode=fan_only` | `HvacAction.FAN` |
|
|
154
|
+
| `hvac_mode=auto` / `heat_cool` | 根据 current vs target 二选一(heating/cooling/idle) |
|
|
155
|
+
| `power_on=None`(设备离线) | `HvacAction=None` → HA 渲染 `unavailable` |
|
|
156
|
+
|
|
157
|
+
### 动态能力表(`DeviceCapabilities`)
|
|
158
|
+
|
|
159
|
+
`client.get_device_panel_template(family_id, device_id)` 现在返回 `DeviceCapabilities`,从 `queryTemplate.do` 实时解析:
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
caps = client.get_device_panel_template(family_id=37790, device_id="000165f9b029afa2e5d8")
|
|
163
|
+
caps.hvac_modes # ["off", "cool", "heat", "dry", "fan_only", "auto", "quick"]
|
|
164
|
+
caps.fan_modes # ["auto", "silent", "low", "medium", "high", "turbo"]
|
|
165
|
+
caps.swing_modes # ["off", "vertical", "horizontal", "both"]
|
|
166
|
+
caps.preset_modes # ["none", "eco", "fresh_air", "aux_heat"]
|
|
167
|
+
caps.supports_vertical_swing # True
|
|
168
|
+
caps.supports_horizontal_swing # True
|
|
169
|
+
caps.supports_eco
|
|
170
|
+
caps.supports_fresh_air
|
|
171
|
+
caps.supports_aux_heat
|
|
172
|
+
caps.fields["C_FANSPEED"].raw_values # ["0","1","2","3","4","5"]
|
|
173
|
+
caps.fields["C_FANSPEED"].display_values # ["自动","微风","低风","中风","高风","强风"]
|
|
174
|
+
caps.fields["C_FANSPEED"].icon_urls # [6 个图标 URL]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
HA 集成应在 `async_setup_entry` 时调一次 `get_device_panel_template` 缓存起来,**直接喂给 `hvac_modes` / `fan_modes` / `swing_modes` / `preset_modes` 属性**——不要再硬编码列表。
|
|
178
|
+
|
|
179
|
+
### `preset_mode` 自定义值
|
|
180
|
+
|
|
181
|
+
按 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` 服务对应)。
|
|
182
|
+
|
|
131
183
|
## CLI
|
|
132
184
|
|
|
133
185
|
```bash
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
xiaobiu/__init__.py,sha256=
|
|
2
|
-
xiaobiu/ac_control.py,sha256=
|
|
3
|
-
xiaobiu/ac_status.py,sha256=
|
|
1
|
+
xiaobiu/__init__.py,sha256=vuubbRNBH7hN-QW8_-aYQcOjj10OQp26w_7imNU9KO8,837
|
|
2
|
+
xiaobiu/ac_control.py,sha256=y1TYVcUjpssBFy8LLjK2XqKXqy5nlox2-8sbIzHTp8w,19444
|
|
3
|
+
xiaobiu/ac_status.py,sha256=DkYQxxiBDuwIJgDPpMVxkErMrdKWHCmMB0PlWZQ4XGY,14605
|
|
4
4
|
xiaobiu/app_api.py,sha256=gJLa-iq60s_YEEM00E4lMcTsBKoV60GtaaqBsWWOWio,4729
|
|
5
5
|
xiaobiu/captcha_bridge.py,sha256=l8c3HnspQt1JDM1sDKnvcM4yvf7NZosSQ7x2AlO-kEA,12920
|
|
6
6
|
xiaobiu/cli.py,sha256=eDGyv5VCOP3O4l8HCJk_XtgxLPCAOR12zuB0CYpTdQI,17599
|
|
@@ -8,11 +8,11 @@ xiaobiu/client.py,sha256=44Ay-Yr0O74UXV6BuNOJrytaVmssHwNghPVE0U1fE-I,23047
|
|
|
8
8
|
xiaobiu/crypto.py,sha256=C0Lcp2Cfy-075hv65b1RYfn6UbiHneLhp4PhUftzzOk,2424
|
|
9
9
|
xiaobiu/exceptions.py,sha256=RKaity_UctboUGeC8QE0iF0KcqfYqlVHnfOQ2yXQT7c,1036
|
|
10
10
|
xiaobiu/har_templates.py,sha256=clatrCsn4_AxlSrpy99mJVThI34bFQpQQMoM-4H9e08,5562
|
|
11
|
-
xiaobiu/models.py,sha256=
|
|
11
|
+
xiaobiu/models.py,sha256=h6lhH0GQIgH9zUwmQLBBAY-SJBZjYr5LMxXqiRVrDOI,6223
|
|
12
12
|
xiaobiu/parsers.py,sha256=5Cb90sN5rw_SNv2BukOoiLmeG9Mxegq-XGkgE8YkxvU,3046
|
|
13
13
|
xiaobiu/persistence.py,sha256=k9ZES5DyE-OkptlLLw0jnBWwGtdDxgrn0YiVhAQ1V8c,887
|
|
14
14
|
xiaobiu/sms_login.py,sha256=5zQS_lhFvADdp6BnoenvSLdOSK1hWaT35rQQ4K3Ig-w,16394
|
|
15
|
-
python_xiaobiu-0.2.
|
|
16
|
-
python_xiaobiu-0.2.
|
|
17
|
-
python_xiaobiu-0.2.
|
|
18
|
-
python_xiaobiu-0.2.
|
|
15
|
+
python_xiaobiu-0.2.1.dist-info/METADATA,sha256=md0rsQR6QsSNdz9scltusVDM2gwYSaHN_p_atxxfULY,11785
|
|
16
|
+
python_xiaobiu-0.2.1.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
17
|
+
python_xiaobiu-0.2.1.dist-info/entry_points.txt,sha256=w1z8h63RRusoSGAbbSMpNcq4qbN3HOedsMlxwuFH3U8,44
|
|
18
|
+
python_xiaobiu-0.2.1.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,
|
|
@@ -169,11 +172,14 @@ def get_device_panel_template(
|
|
|
169
172
|
model_id: str,
|
|
170
173
|
*,
|
|
171
174
|
category_id: str = "0002",
|
|
172
|
-
) ->
|
|
173
|
-
"""Fetch the
|
|
175
|
+
) -> DeviceCapabilities | None:
|
|
176
|
+
"""Fetch the device's :class:`DeviceCapabilities`.
|
|
174
177
|
|
|
175
178
|
Returns ``None`` on any failure (HTTP error, malformed JSON, code != 0)
|
|
176
|
-
so the caller can keep going on a partial response.
|
|
179
|
+
so the caller can keep going on a partial response. Kept the legacy
|
|
180
|
+
name for backward compatibility — the returned object's
|
|
181
|
+
:class:`DeviceCapabilities` includes a ``raw`` payload carrying the
|
|
182
|
+
unparsed template.
|
|
177
183
|
"""
|
|
178
184
|
|
|
179
185
|
query = (
|
|
@@ -195,10 +201,122 @@ def get_device_panel_template(
|
|
|
195
201
|
components = parse_panel_components(containers)
|
|
196
202
|
if components is None:
|
|
197
203
|
return None
|
|
198
|
-
return
|
|
204
|
+
return build_capabilities_from_template(
|
|
199
205
|
device_id=device_id,
|
|
200
206
|
model_id=model_id,
|
|
201
|
-
|
|
207
|
+
category_id=category_id,
|
|
208
|
+
fields=components,
|
|
209
|
+
raw=data_block,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def build_capabilities_from_template(
|
|
214
|
+
*,
|
|
215
|
+
device_id: str,
|
|
216
|
+
model_id: str,
|
|
217
|
+
category_id: str,
|
|
218
|
+
fields: list[str],
|
|
219
|
+
raw: Mapping[str, Any] | None = None,
|
|
220
|
+
) -> DeviceCapabilities:
|
|
221
|
+
"""Build a :class:`DeviceCapabilities` from a flattened field set.
|
|
222
|
+
|
|
223
|
+
``fields`` is the sorted list of ``C_*`` / ``SN_*`` keys returned by
|
|
224
|
+
:func:`parse_panel_components`. The boolean support flags are derived
|
|
225
|
+
from membership; the HA-facing ``*_modes`` lists always include
|
|
226
|
+
the standard ``off`` sentinel so the integration can render the
|
|
227
|
+
toggle.
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
raw_dict = dict(raw) if raw else {}
|
|
231
|
+
keys_block = raw_dict.get("keys") or []
|
|
232
|
+
field_map: dict[str, CapabilityField] = {}
|
|
233
|
+
for key_entry in keys_block:
|
|
234
|
+
if not isinstance(key_entry, Mapping):
|
|
235
|
+
continue
|
|
236
|
+
raw_key = str(key_entry.get("key") or "")
|
|
237
|
+
if not raw_key:
|
|
238
|
+
continue
|
|
239
|
+
field_map[raw_key] = CapabilityField(
|
|
240
|
+
key=raw_key,
|
|
241
|
+
name=str(key_entry.get("name") or raw_key),
|
|
242
|
+
type=str(key_entry.get("type") or ""),
|
|
243
|
+
raw_values=[str(v) for v in (key_entry.get("k") or [])],
|
|
244
|
+
display_values=[str(v) for v in (key_entry.get("v") or [])],
|
|
245
|
+
sn_property_id=key_entry.get("snPropertyId"),
|
|
246
|
+
icon_urls=[str(u) for u in (key_entry.get("icon") or [])],
|
|
247
|
+
raw=dict(key_entry),
|
|
248
|
+
)
|
|
249
|
+
# Fallback: when the panel template lacks a ``keys`` block, seed the
|
|
250
|
+
# field map with placeholder CapabilityFields derived from the
|
|
251
|
+
# flattened field set so callers can still ask ``"C_POWER" in
|
|
252
|
+
# caps.fields``.
|
|
253
|
+
for raw_key in fields:
|
|
254
|
+
if raw_key in field_map:
|
|
255
|
+
continue
|
|
256
|
+
field_map[raw_key] = CapabilityField(
|
|
257
|
+
key=raw_key,
|
|
258
|
+
name=raw_key,
|
|
259
|
+
type="",
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
has = set(fields)
|
|
263
|
+
hvac_modes: list[str] = []
|
|
264
|
+
# The device speaks a single C_MODE knob; we expose the HA-equivalent
|
|
265
|
+
# standard names. We never report HEAT_COOL because the AC has no
|
|
266
|
+
# range-control primitive — AUTO is the implicit form.
|
|
267
|
+
if "C_MODE" in has:
|
|
268
|
+
hvac_modes = [
|
|
269
|
+
HvacMode.OFF.value,
|
|
270
|
+
HvacMode.COOL.value,
|
|
271
|
+
HvacMode.HEAT.value,
|
|
272
|
+
HvacMode.DRY.value,
|
|
273
|
+
HvacMode.FAN_ONLY.value,
|
|
274
|
+
HvacMode.AUTO.value,
|
|
275
|
+
]
|
|
276
|
+
# QUICK is inferred (C_MODE=5) so we add it when the field is present.
|
|
277
|
+
hvac_modes.append(HvacMode.QUICK.value)
|
|
278
|
+
fan_modes: list[str] = []
|
|
279
|
+
if "C_FANSPEED" in has:
|
|
280
|
+
fan_modes = [
|
|
281
|
+
FanSpeed.AUTO.value,
|
|
282
|
+
FanSpeed.SILENT.value,
|
|
283
|
+
FanSpeed.LOW.value,
|
|
284
|
+
FanSpeed.MEDIUM.value,
|
|
285
|
+
FanSpeed.HIGH.value,
|
|
286
|
+
FanSpeed.TURBO.value,
|
|
287
|
+
]
|
|
288
|
+
swing_modes: list[str] = []
|
|
289
|
+
if "C_AIRVERTICAL" in has or "C_AIRHORIZONTAL" in has:
|
|
290
|
+
swing_modes = [
|
|
291
|
+
SwingMode.OFF.value,
|
|
292
|
+
SwingMode.VERTICAL.value,
|
|
293
|
+
SwingMode.HORIZONTAL.value,
|
|
294
|
+
SwingMode.BOTH.value,
|
|
295
|
+
]
|
|
296
|
+
preset_modes: list[str] = [PresetMode.NONE.value]
|
|
297
|
+
if "C_ECO" in has:
|
|
298
|
+
preset_modes.append(PresetMode.ECO.value)
|
|
299
|
+
if "C_FRESHAIR" in has:
|
|
300
|
+
preset_modes.append(PresetMode.FRESH_AIR.value)
|
|
301
|
+
if "C_ELECHEATING" in has:
|
|
302
|
+
preset_modes.append(PresetMode.AUX_HEAT.value)
|
|
303
|
+
|
|
304
|
+
return DeviceCapabilities(
|
|
305
|
+
device_id=device_id,
|
|
306
|
+
model_id=model_id,
|
|
307
|
+
category_id=category_id,
|
|
308
|
+
fields=field_map,
|
|
309
|
+
hvac_modes=hvac_modes,
|
|
310
|
+
fan_modes=fan_modes,
|
|
311
|
+
swing_modes=swing_modes,
|
|
312
|
+
preset_modes=preset_modes,
|
|
313
|
+
supports_vertical_swing="C_AIRVERTICAL" in has,
|
|
314
|
+
supports_horizontal_swing="C_AIRHORIZONTAL" in has,
|
|
315
|
+
supports_eco="C_ECO" in has,
|
|
316
|
+
supports_fresh_air="C_FRESHAIR" in has,
|
|
317
|
+
supports_aux_heat="C_ELECHEATING" in has,
|
|
318
|
+
supports_target_temperature="C_TEMPERATURE" in has,
|
|
319
|
+
raw=raw_dict,
|
|
202
320
|
)
|
|
203
321
|
|
|
204
322
|
|
|
@@ -269,6 +387,52 @@ def infer_fan_speed(speed_raw: Any) -> FanSpeed | None:
|
|
|
269
387
|
return C_FIELD_TO_FAN.get(str(speed_raw).strip())
|
|
270
388
|
|
|
271
389
|
|
|
390
|
+
def infer_hvac_action(
|
|
391
|
+
*,
|
|
392
|
+
power_on: bool | None,
|
|
393
|
+
hvac_mode: HvacMode | str | None,
|
|
394
|
+
current_temp: float | None,
|
|
395
|
+
target_temp: float | None,
|
|
396
|
+
) -> HvacAction | None:
|
|
397
|
+
"""Infer the device's current :class:`HvacAction` from its status fields.
|
|
398
|
+
|
|
399
|
+
Power off → ``OFF``. Mode is ``DRY`` / ``FAN_ONLY`` → ``DRYING`` / ``FAN``.
|
|
400
|
+
Mode is ``HEAT`` or ``COOL`` → ``HEATING`` / ``COOLING`` if there is still
|
|
401
|
+
work to do (current temp below / above target), else ``IDLE``.
|
|
402
|
+
Mode is ``AUTO`` → behave like ``HEAT_COOL``: pick the side that has work.
|
|
403
|
+
``HEAT_COOL`` itself collapses to whichever side has work (else ``IDLE``).
|
|
404
|
+
When ``power_on`` is unknown we return ``None`` so HA can render
|
|
405
|
+
``unavailable`` rather than guess.
|
|
406
|
+
"""
|
|
407
|
+
|
|
408
|
+
if power_on is None:
|
|
409
|
+
return None
|
|
410
|
+
if power_on is False:
|
|
411
|
+
return HvacAction.OFF
|
|
412
|
+
if hvac_mode is None:
|
|
413
|
+
return HvacAction.IDLE
|
|
414
|
+
mode_value = hvac_mode.value if isinstance(hvac_mode, HvacMode) else str(hvac_mode)
|
|
415
|
+
if mode_value == HvacMode.OFF.value:
|
|
416
|
+
return HvacAction.OFF
|
|
417
|
+
if mode_value == HvacMode.DRY.value:
|
|
418
|
+
return HvacAction.DRYING
|
|
419
|
+
if mode_value == HvacMode.FAN_ONLY.value:
|
|
420
|
+
return HvacAction.FAN
|
|
421
|
+
if current_temp is None or target_temp is None:
|
|
422
|
+
return HvacAction.IDLE
|
|
423
|
+
if mode_value in (HvacMode.HEAT.value, HvacMode.QUICK.value):
|
|
424
|
+
return HvacAction.HEATING if current_temp < target_temp else HvacAction.IDLE
|
|
425
|
+
if mode_value == HvacMode.COOL.value:
|
|
426
|
+
return HvacAction.COOLING if current_temp > target_temp else HvacAction.IDLE
|
|
427
|
+
if mode_value in (HvacMode.AUTO.value, HvacMode.HEAT_COOL.value):
|
|
428
|
+
if current_temp < target_temp:
|
|
429
|
+
return HvacAction.HEATING
|
|
430
|
+
if current_temp > target_temp:
|
|
431
|
+
return HvacAction.COOLING
|
|
432
|
+
return HvacAction.IDLE
|
|
433
|
+
return HvacAction.IDLE
|
|
434
|
+
|
|
435
|
+
|
|
272
436
|
# ---------------------------------------------------------------------------
|
|
273
437
|
# High-level helpers
|
|
274
438
|
# ---------------------------------------------------------------------------
|
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"
|
|
@@ -233,6 +235,16 @@ def _normalize_air_conditioner_status(device: dict[str, Any]) -> AirConditionerS
|
|
|
233
235
|
)
|
|
234
236
|
mode_raw = _coalesce(raw_status.get("SN_MODE"), raw_status.get("C_MODE"))
|
|
235
237
|
hvac_mode = infer_hvac_mode(power_on=power_on, mode_raw=mode_raw) if online else None
|
|
238
|
+
hvac_action = (
|
|
239
|
+
ac_control.infer_hvac_action(
|
|
240
|
+
power_on=power_on,
|
|
241
|
+
hvac_mode=hvac_mode,
|
|
242
|
+
current_temp=current_temperature,
|
|
243
|
+
target_temp=target_temperature,
|
|
244
|
+
)
|
|
245
|
+
if online
|
|
246
|
+
else None
|
|
247
|
+
)
|
|
236
248
|
|
|
237
249
|
status = AirConditionerStatus(
|
|
238
250
|
device_id=str(device.get("id")),
|
|
@@ -249,6 +261,7 @@ def _normalize_air_conditioner_status(device: dict[str, Any]) -> AirConditionerS
|
|
|
249
261
|
refresh_time=raw_status.get("refreshTime"),
|
|
250
262
|
power_on=power_on,
|
|
251
263
|
hvac_mode=hvac_mode,
|
|
264
|
+
hvac_action=hvac_action,
|
|
252
265
|
current_temperature=current_temperature,
|
|
253
266
|
target_temperature=target_temperature,
|
|
254
267
|
outdoor_temperature=outdoor_temperature,
|
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)
|
|
File without changes
|
|
File without changes
|