fix(levoit): send speed command when leaving a preset at unchanged level - #53
Open
Bleialf wants to merge 1 commit into
Open
fix(levoit): send speed command when leaving a preset at unchanged level#53Bleialf wants to merge 1 commit into
Bleialf wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
Pull request overview
This PR fixes a logic gap in the Levoit fan control path where setting the same speed while a non-Manual preset (e.g., Sleep/Auto) is active could be treated as “no change,” preventing the UART command from being sent and leaving the device stuck in the preset mode.
Changes:
- Treat a speed call as a “change” when it implicitly leaves a non-Manual preset, even if the numeric speed level is unchanged.
- Add clarifying inline comments documenting why speed can appear unchanged while the operating mode should still transition to Manual.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
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.
Repro (Core 300S): Manual @ 100% → Sleep → set 100% again → nothing happens.
Cause: in Sleep/Auto the MCU reports no fan level, so
apply_device_status()gets
speed_level == -1andthis->speedstays stale. The nextset_percentage(100)looks like "no change" and is skipped.Tested on a Core 300S: Sleep and Auto both fixed.