fix: wire up nightlight brightness/toggle for Sprout Humidifier (LEH-B381S)#528
Merged
webdjoe merged 3 commits intoJul 12, 2026
Merged
Conversation
…B381S) VeSyncSproutHumid already had a working _set_nightlight_state helper that builds the correct setLightStatus payload, but never overrode the base class's set_nightlight_brightness/toggle_nightlight stubs. As a result, any caller (e.g. Home Assistant's select/switch entities) hit the base class fallback, which logs "Nightlight brightness has not been configured" and returns False instead of calling the API. Also fixes a latent bug in _set_nightlight_state: it unconditionally stored the passed-in brightness (including None) as the new state, and would send "brightness": null to the API when toggling the light before a brightness had ever been read or set. It now falls back to the last known brightness, or 100 if none is known yet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
Author
|
Validated against my physical LEH-B381S (Sprout Humidifier) and VeSync account. All three methods work correctly end-to-end: ``` --- turn_on_nightlight() --- --- set_nightlight_brightness(30) --- --- turn_off_nightlight() --- Confirmed each state change matched what happened on the physical device/Levoit app. |
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.
Summary
The LEH-B381S (Sprout Humidifier) already declares
NIGHTLIGHT/NIGHTLIGHT_BRIGHTNESSsupport indevice_map.py, andVeSyncSproutHumidalready had a working private_set_nightlight_statehelper that builds the correctsetLightStatuspayload. However, the class never overrode the base class'sset_nightlight_brightness/toggle_nightlightmethods, so any caller (e.g. Home Assistant'sselect/switchentities) fell through to the base-class stub, which just logsNightlight brightness has not been configured.and returnsFalseinstead of calling the API.Traceback this was pulled from (Home Assistant, via
select.async_select_option):set_nightlight_brightnessandtoggle_nightlightoverrides toVeSyncSproutHumid, wired to the existing_set_nightlight_statehelper (mirroring the pattern used inVeSyncHumid200300S/VeSyncHumid1000S)._set_nightlight_state: it unconditionally stored the passed-inbrightness(includingNone) as the new state, and would send"brightness": nullto the API when toggling the light before a brightness had ever been read or set. It now falls back to the last known brightness, or100if none is known yet.Test plan
turn_on_nightlight,turn_off_nightlight, andset_nightlight_brightnesstest cases forLEH-B381Sintest_humidifiers.pysrc/tests/api/vesynchumidifier/LEH-B381S.yamlpytest src/tests/— 355 passed, 3 skippedmypy src/pyvesync/devices/vesynchumidifier.py— no issues🤖 Generated with Claude Code