Skip to content

fix: thermostat power state and target temperature not synced from cloud for tofan-wk01 models#1742

Open
xianyu122 wants to merge 1 commit into
XiaoMi:mainfrom
xianyu122:fix/thermostat-sync-tofan-wk01
Open

fix: thermostat power state and target temperature not synced from cloud for tofan-wk01 models#1742
xianyu122 wants to merge 1 commit into
XiaoMi:mainfrom
xianyu122:fix/thermostat-sync-tofan-wk01

Conversation

@xianyu122

Copy link
Copy Markdown

Problem

For thermostat devices (e.g. tofan-wk01 models) connected via xiaomi_home cloud integration:

  • ✅ Preset mode (制冷/制热/送风) syncs correctly
  • ✅ Fan mode syncs correctly
  • hvac_mode (on/off) never updates — stays stuck at off
  • target_temperature never updates

Root Cause

The Thermostat class relies solely on the MIoT on property (thermostat service → Switch Status, bool format) to determine hvac_mode. However, the Xiaomi Home cloud does not push on property changes for this thermostat model — the power state is likely encoded in other fields.

Fix

Two fallback mechanisms added to Thermostat class:

1. ac-state composite field parsing

Some thermostat models push an ac-state property as a string encoding multiple state fields (e.g. P0_T25_F1). Added parsing logic to extract:

  • P: Power status (0=on, 1=off) → updates _prop_on
  • T: Target temperature → updates _prop_target_temp
  • F: Fan level → updates _prop_fan_level

2. Mode change fallback

When mode property changes but _prop_on was not updated, infer that the device is ON. This covers cases where the cloud only sends mode but not power status.

3. hvac_action property

Added to correctly report COOLING/HEATING/FAN/DRY/OFF state based on current mode.

Testing

Tested on tofan-wk01 thermostat (midea-based) with HA 2026.5.0. After patch:

  • Turning thermostat on/off from Mi Home app → hvac_mode updates immediately
  • Changing target temperature → value syncs correctly
  • hvac_action correctly reports cooling/heating/fan

See related: HA configuration using ctrl_mode: auto with Xiaomi Home cloud.

@CLAassistant

CLAassistant commented Jun 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

…oud for tofan-wk01 models

Add two fallback mechanisms to Thermostat class to handle thermostat
models (e.g. tofan-wk01) where the MIoT 'on' property is not pushed
by the Xiaomi Home cloud:

1. Parse ac-state composite field to extract power status (P: 0=on, 1=off),
   target temperature (T) and fan level (F)
2. Subscribe to mode changes as a fallback — when mode changes but
   _prop_on wasn't updated, infer the device is ON

Also adds hvac_action property to correctly report COOLING/HEATING/FAN/DRY
state based on the current mode.

Fixes: Thermostat climate entity hvac_mode stuck at 'off' and
target_temperature not updating when changed from Mi Home app.
@xianyu122
xianyu122 force-pushed the fix/thermostat-sync-tofan-wk01 branch from be82c77 to ad5628d Compare June 26, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants