feat: Add RGB nightlight support for VeSyncHumid200300S (LUH-O451S-WEU)#502
feat: Add RGB nightlight support for VeSyncHumid200300S (LUH-O451S-WEU)#502MangelSpec wants to merge 2 commits intowebdjoe:devfrom
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
webdjoe
left a comment
There was a problem hiding this comment.
Apologies for the delay, great work! Just a few minor edits to keep the library clean.
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| # RGB nightlight constants |
There was a problem hiding this comment.
Please move to the constants module. Keep the stale data timeout and see comment below
| self.state.warm_mist_level = resp_model.warm_level | ||
| self.state.warm_mist_enabled = resp_model.warm_enabled | ||
| # Handle RGB nightlight | ||
| if self.supports_rgb_nightlight and resp_model.rgbNightLight is not None: |
There was a problem hiding this comment.
I'm not sure how to work around this, but for the time being move this to a separate private method
| brightness = 100 if toggle else 0 | ||
| return await self.set_nightlight_brightness(brightness) | ||
|
|
||
| # 8-color gradient used by VeSync app for RGB nightlight color slider |
There was a problem hiding this comment.
Move _RGB_NIGHTLIGHT_GRADIENTS to a new class in the utils.colors module in case it is used by other devices. Name it RGBNightlightColor or something that makes sense
| ] | ||
|
|
||
| @staticmethod | ||
| def _color_distance(r1: int, g1: int, b1: int, r2: int, g2: int, b2: int) -> float: |
There was a problem hiding this comment.
Move to utils.colors class with _RGB_NIGHTLIGHT_GRADIENTS
| return ((r1 - r2) ** 2 + (g1 - g2) ** 2 + (b1 - b2) ** 2) ** 0.5 | ||
|
|
||
| @staticmethod | ||
| def _interpolate_color( |
There was a problem hiding this comment.
Move to utils.colors class with _RGB_NIGHTLIGHT_GRADIENTS
| return (r, g, b) | ||
|
|
||
| @staticmethod | ||
| def _apply_brightness_to_rgb( |
There was a problem hiding this comment.
Move to utils.colors class with _RGB_NIGHTLIGHT_GRADIENTS
| return (int(r * 255), int(g * 255), int(b * 255)) | ||
|
|
||
| @staticmethod | ||
| def _normalize_rgb_to_full_brightness( |
| return (int(r * 255), int(g * 255), int(b * 255)) | ||
|
|
||
| @classmethod | ||
| def _rgb_to_color_slider_location(cls, red: int, green: int, blue: int) -> int: |
Summary
Adds RGB nightlight control support for the
VeSyncHumid200300Sdevice class, specifically for the LUH-O451S-WEU (OasisMist 4.5L) humidifier model.This addresses missing nightlight functionality that prevents Home Assistant from creating light entities for humidifiers with RGB nightlight features. Related issue: home-assistant/core#160387
Changes
HumidifierFeatures.RGB_NIGHTLIGHTfeature flagsupports_rgb_nightlightproperty to base classset_rgb_nightlight(power, brightness, red, green, blue)methodAPI Quirks
colorSliderLocation(0-100) mapped from an 8-color gradientKnown Limitations
Testing
Tested on physical LUH-O451S-WEU device: power on/off, brightness, color changes, state refresh.