Repository navigation
fix: purifier light detection and display guards used the wrong state - #551
Open
ryan-ronnander wants to merge 1 commit into
Open
ryan-ronnander wants to merge 1 commit into
ryan-ronnander wants to merge 1 commit into
Conversation
9 of 21 tasks
- toggle_light_detection compared the requested state against light_detection_status (the dark/lit sensor reading) instead of light_detection_switch (the feature toggle), so enabling it in a dark room or disabling it in a lit room returned early without calling the API. - toggle_display refused whenever the room was dark, on every model. The Vital 200S accepts setDisplay with light detection on, so the guard now applies only to the Vital 100S (the 11017000 report in webdjoe#351) and checks light_detection_switch. - Add tests for both guards. - Verified on a Levoit Vital 200S (LAP-V201S-WUS).
ryan-ronnander
force-pushed
the
fix-light-detection-guard
branch
from
October 9, 2026 10:06
f5fba49 to
31b1340
Compare
This branch has not been deployed
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.
Why
This started with the display switch in Home Assistant failing on my Vital 200S, while the VeSync app changed the same setting without complaint:
Follow-up to #351. The two guards it added check
light_detection_status(whether the room is dark right now) where they meanlight_detection_switch(whether the feature is enabled). On a Levoit Vital 200S (LAP-V201S-WUS), that makes light detection and the display unreliable to control through pyvesync, and so through Home Assistant too. I'm preparing a Home Assistant VeSync change that adds a light detection switch and a dark room sensor for these purifiers. With the current guards, that switch silently does nothing when turned on in a dark room, and the existing display switch fails whenever the room is dark.toggle_light_detectioncheckedlight_detection_status(whether the room is dark right now) where it meantlight_detection_switch(whether the feature is enabled). Turning light detection on in a dark room, or off in a lit room, returnedTruewithout calling the API.toggle_displayrefused wheneverlight_detection_statuswas on, which is the same wrong field. As a result the display switch in HA failed with "Cannot set display when light detection is enabled" depending on how bright the room was.Fix
toggle_light_detectioncompares againstlight_detection_switch.toggle_displaynow applies only to the Vital 100S (LAP-V102S), and checkslight_detection_switch. The Vital 200S acceptssetDisplaywith light detection enabled, and the VeSync app lets you change both settings at any time. The display setting is the master: with light detection on, the device only darkens a display that is set to on while the room is dark.I kept the guard for the Vital 100S because #351 reported
11017000 BYPASS_NOT_SUPPORTEDthere, and I don't own a 100S to check. If someone with a 100S finds that it accepts the call, the guard can go.Only
VeSyncAirBaseV2changes (Vital 100S/200S, Everest Air, Sprout). The Core series and the other purifier classes are untouched.Tested on hardware
Vital 200S, through Home Assistant with this branch installed. Light detection on, room lit:
setDisplayoff returned success, and the next cloud poll reporteddisplay_status: offsetDisplayon returned success, and the next cloud poll reporteddisplay_status: onTests
TestAirBaseV2Guardsintest_purifiers.py: