Fix thermostat fan modes to respect fanModeSequence#708
Open
Fix thermostat fan modes to respect fanModeSequence#708
Conversation
puddly
reviewed
Mar 12, 2026
Contributor
|
To regenerate device diagnostics files (to see what this change would affect in real devices), run the following: python -m tools.regenerate_diagnosticsIt looks like four devices (in the testing DB) change their exposed fan modes. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #708 +/- ##
==========================================
- Coverage 97.51% 97.50% -0.01%
==========================================
Files 62 62
Lines 10946 10960 +14
==========================================
+ Hits 10674 10687 +13
- Misses 272 273 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Author
|
Should resolve #226 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Thermostatentity to read thefan_mode_sequenceattribute from the ZCL Fan Control cluster (0x0202) instead of hardcoding fan modes to[auto, on]. Devices now correctly expose Low, Medium, High, and Auto fan speeds based on the ZCL spec (Table 6-20).fan_modegetter to read the actualfan_modeattribute from the Fan Control cluster handler instead of guessing from the thermostat'srunning_statebitmap.async_set_fan_modeto map all supported fan mode strings (low, medium, high, on, auto) to their correspondingFanModeZCL enum values.HVACMode.FAN_ONLYas an available HVAC mode when a Fan Control cluster is present on the endpoint, sinceSEQ_OF_OPERATION(derived fromcontrolSequenceOfOperation) never includes it per ZCL spec.Problem
The
Thermostatentity hardcodes fan modes to[auto, on]and completely ignores thefan_mode_sequenceattribute (attribute 0x0001) from the Fan Control cluster. Per ZCL 8 (Table 6-20),FanModeSequenceTypedefines which fan modes a device supports:Devices reporting e.g.
fan_mode_sequence = 0x02(Low/Medium/High/Auto) were stuck with only Auto/On in the UI.Additionally, the thermostat never exposes
HVACMode.FAN_ONLYeven when the device supportsSystemMode.Fan_only(0x07). The mappingsHVAC_MODE_2_SYSTEMandSYSTEM_MODE_2_HVACalready handleFAN_ONLY <-> Fan_only, buthvac_modesderives its list solely fromSEQ_OF_OPERATIONwhich never includes it, sincecontrolSequenceOfOperationonly covers cooling/heating per the ZCL spec.Changes
zha/application/platforms/climate/const.pyFanModefrom zigpySEQ_FAN_MODESdict mappingfan_mode_sequencevalues (0x00–0x04) to fan mode string listsFAN_MODE_TO_ZCLdict mapping fan mode strings toFanModeenum valuesZCL_TO_FAN_MODEreverse mapping dictzha/application/platforms/climate/__init__.pyfan_modes: Readfan_mode_sequencefrom the fan cluster handler, look up modes viaSEQ_FAN_MODES, fall back to[on, auto]for unknown sequencesfan_mode: Read actualfan_modeattribute from the fan cluster handler, map back viaZCL_TO_FAN_MODE, fall back torunning_stateheuristic when unavailableasync_set_fan_mode: UseFAN_MODE_TO_ZCLmapping instead of hardcodedOn/Autobranchhvac_modes: AppendHVACMode.FAN_ONLYwhen a fan cluster handler is presentBackwards compatibility
fan_mode_sequence = 0x04still get[on, auto](unchanged)fan_mode_sequencevalues fall back to[on, auto]HVAC_MODE_2_SYSTEM,SYSTEM_MODE_2_HVAC, orasync_set_hvac_modeTest plan
fan_mode_sequence = 0x02exposes: Low, Medium, High, Autofan_mode_sequence = 0x04(or unknown) exposes: On, Auto (backwards compatible)FanMode.Low(0x01) to the deviceFanMode.High(0x03) to the devicefan_modeattribute from the Fan Control clusterSystemMode.Fan_only(0x07) to the thermostatAffected devices
Any thermostat with a Fan Control cluster (0x0202) that reports
fan_mode_sequence != 0x04, such as Tuya HVAC thermostats with cooling/heating/fan modes (e.g._TZE204_mpbki2zm).