|
22 | 22 | CAPABILITY_WORK_MODE = "devices.capabilities.work_mode" |
23 | 23 | CAPABILITY_PROPERTY = "devices.capabilities.property" |
24 | 24 | CAPABILITY_MODE = "devices.capabilities.mode" |
| 25 | +CAPABILITY_TEMPERATURE_SETTING = "devices.capabilities.temperature_setting" |
25 | 26 |
|
26 | 27 | # Device type constants |
27 | 28 | DEVICE_TYPE_LIGHT = "devices.types.light" |
|
48 | 49 | INSTANCE_MUSIC_MODE = "musicMode" |
49 | 50 | INSTANCE_DREAMVIEW = "dreamViewToggle" |
50 | 51 | INSTANCE_TEMPERATURE = "temperature" |
| 52 | +INSTANCE_TARGET_TEMPERATURE = "targetTemperature" |
51 | 53 | INSTANCE_FAN_SPEED = "fanSpeed" |
52 | 54 | INSTANCE_PURIFIER_MODE = "purifierMode" |
53 | 55 |
|
@@ -381,26 +383,39 @@ def get_music_sensitivity_range(self) -> tuple[int, int]: |
381 | 383 | def get_temperature_range(self) -> tuple[int, int]: |
382 | 384 | """Extract temperature range from capability. |
383 | 385 |
|
| 386 | + Parses STRUCT-based temperature_setting capability where the range |
| 387 | + is nested inside the fields array under the 'temperature' field. |
| 388 | +
|
384 | 389 | Returns (min, max) tuple, defaulting to (16, 35) Celsius. |
385 | 390 | """ |
386 | 391 | for cap in self.capabilities: |
387 | | - if cap.type == CAPABILITY_RANGE and cap.instance == INSTANCE_TEMPERATURE: |
388 | | - range_data = cap.parameters.get("range", {}) |
389 | | - return ( |
390 | | - int(range_data.get("min", 16)), |
391 | | - int(range_data.get("max", 35)), |
392 | | - ) |
| 392 | + if ( |
| 393 | + cap.type == CAPABILITY_TEMPERATURE_SETTING |
| 394 | + and cap.instance == INSTANCE_TARGET_TEMPERATURE |
| 395 | + ): |
| 396 | + for f in cap.parameters.get("fields", []): |
| 397 | + if f.get("fieldName") == "temperature": |
| 398 | + range_data = f.get("range", {}) |
| 399 | + return ( |
| 400 | + int(range_data.get("min", 16)), |
| 401 | + int(range_data.get("max", 35)), |
| 402 | + ) |
393 | 403 | return (16, 35) |
394 | 404 |
|
395 | 405 | def get_fan_speed_options(self) -> list[dict[str, Any]]: |
396 | | - """Extract fan speed mode options from capability. |
| 406 | + """Extract fan speed options from work_mode capability. |
| 407 | +
|
| 408 | + Heater fan speed options are inside the STRUCT-based work_mode |
| 409 | + capability, in the 'workMode' field's options array. |
397 | 410 |
|
398 | 411 | Returns list of {"name": "Low", "value": 1} dicts. |
399 | 412 | """ |
400 | 413 | for cap in self.capabilities: |
401 | | - if cap.type == CAPABILITY_MODE and cap.instance == INSTANCE_FAN_SPEED: |
402 | | - options: list[dict[str, Any]] = cap.parameters.get("options", []) |
403 | | - return options |
| 414 | + if cap.type == CAPABILITY_WORK_MODE and cap.instance == INSTANCE_WORK_MODE: |
| 415 | + for f in cap.parameters.get("fields", []): |
| 416 | + if f.get("fieldName") == "workMode": |
| 417 | + options: list[dict[str, Any]] = f.get("options", []) |
| 418 | + return options |
404 | 419 | return [] |
405 | 420 |
|
406 | 421 | def get_purifier_mode_options(self) -> list[dict[str, Any]]: |
|
0 commit comments