Improve Tuya HVACMode handling#158042
Conversation
|
Hey there @tuya, @zlinoliver, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
| 'last_reported': <ANY>, | ||
| 'last_updated': <ANY>, | ||
| 'state': 'off', | ||
| 'state': 'unknown', |
There was a problem hiding this comment.
5ls2jw49hpczwqng does not expose switch or mode wrapper.
| 'last_reported': <ANY>, | ||
| 'last_updated': <ANY>, | ||
| 'state': 'off', | ||
| 'state': 'unknown', |
There was a problem hiding this comment.
B0eP8qYAdpUo4yR9 does not expose switch or mode wrapper.
| 'last_reported': <ANY>, | ||
| 'last_updated': <ANY>, | ||
| 'state': 'off', | ||
| 'state': 'unknown', |
There was a problem hiding this comment.
d7woucobqi8ncacf does not expose switch or mode wrapper.
There was a problem hiding this comment.
Pull request overview
This PR improves HVAC mode handling for Tuya climate entities by returning None instead of OFF in cases where the device state is truly unknown. Previously, the integration would incorrectly return HVACMode.OFF for devices with no control mechanism (neither switch nor mode wrapper) or when the mode wrapper returned an invalid/unmapped value.
Key changes:
- Returns
Nonewhen both switch and mode wrappers are missing (instead ofOFF) - Returns
Nonewhen mode value doesn't map to a valid HVAC mode (instead of falling back toswitch_only_hvac_mode) - Updates return type annotation to
HVACMode | Noneto reflect the new behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| homeassistant/components/tuya/climate.py | Refactored hvac_mode property to properly return None for unknown states; updated return type to HVACMode | None; improved logic clarity by explicitly checking for None wrapper before reading status |
| tests/components/tuya/snapshots/test_climate.ambr | Updated test snapshots for devices with no switch/mode wrappers - correctly changed state from 'off' to 'unknown' for three climate entities |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Proposed change
Related to #157876 / #158258 / #158452
None(previously returned OFF)None(previously returned defaultswitch_only_hvac_mode)Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: