From 400b6c6585cd0c3d79dd961c131a18f79db8a152 Mon Sep 17 00:00:00 2001 From: Bleialf Date: Fri, 7 Aug 2026 16:50:20 +0200 Subject: [PATCH] fix(levoit): send speed command when leaving a preset at unchanged level Setting the same fan level while Sleep/Auto is active was skipped by the speed guard, so no UART command was sent and the device stayed in the preset. Treat a speed call that leaves a non-Manual preset as a change. --- components/levoit/fan/levoit_fan.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/levoit/fan/levoit_fan.cpp b/components/levoit/fan/levoit_fan.cpp index 6fd141c..6a3d731 100644 --- a/components/levoit/fan/levoit_fan.cpp +++ b/components/levoit/fan/levoit_fan.cpp @@ -115,7 +115,14 @@ namespace esphome if (call.get_speed().has_value() && (this->speed_count_ > 0)) { int new_speed = *call.get_speed(); - if (new_speed != cur_speed) + // A speed call issued while a non-Manual preset is active must still + // be sent even if the level is unchanged: the operating mode changes. + // Sleep/Auto leave this->speed at its last manual value because the + // MCU reports no fan level for those modes (apply_device_status gets + // speed_level == -1), so "same level" is not "no change" here. + const bool leaving_preset = + preset == nullptr && !cur_preset.empty() && cur_preset != "Manual"; + if (new_speed != cur_speed || leaving_preset) { this->speed = new_speed; speed_cmd = new_speed;