Fix thermostat fan modes to respect fanModeSequence#708
Fix thermostat fan modes to respect fanModeSequence#708
Conversation
|
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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #708 +/- ##
==========================================
+ Coverage 97.63% 97.64% +0.01%
==========================================
Files 62 62
Lines 10814 10829 +15
==========================================
+ Hits 10558 10574 +16
+ Misses 256 255 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Should resolve #226 |
|
I noticed that one of the test devices was my thermostat. I can confirm this shows up properly:
But the fan mode doesn't really do anything for my specific thermostat even when switching the fan mode from "auto" to "on", it doesn't actually support fan mode independent from heat and cool. This is probably just a device-specific bug. @dmulcahey @TheJulianJES Do you have a device to test this change with? |
|
I'll have a closer look later, but I think the issue is still present in Matter: https://github.com/home-assistant/core/blob/9ddefaaacd1df9da4f5a4f673eea2348b524d0ac/homeassistant/components/matter/climate.py#L121-L159 (assuming it's even the same issue here, which it might not be...) |
|
Hi, I wanted to add a real-world data point in support of this PR. I've been running a custom ESP32-C6 Zigbee bridge that exposes a Midea split AC unit to Home Assistant via ZHA using standard clusters (Thermostat 0x0201, Fan Control 0x0202, Temperature Measurement 0x0402). The device reports With the current ZHA code:
Both of these issues are exactly what this PR addresses. I'd be happy to test a build with this change applied against my device if that would help move things forward. Thanks for working on this. |
|
The specific concern I brought above is that "fan only" support isn't reliably signaled by devices. My thermostat (and I imagine many of the others in our testing database) show up as supporting "fan only" but do not actually support it. There is, as far as I can tell, no way to tell from the ZCL alone that a device supports "fan only". We may need an opt-in mechanism via quirks, unfortunately. |
|
Added opt-in via quirks |

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).