mirror of
https://github.com/micahqcade/custom_vesync.git
synced 2025-02-11 09:39:00 +01:00
add dim to night_light (#52)
This commit is contained in:
parent
83439e7174
commit
f15e78e7af
@ -204,6 +204,9 @@ class VeSyncNightLightHA(VeSyncDimmableLightHA):
|
|||||||
"""Initialize the VeSync device."""
|
"""Initialize the VeSync device."""
|
||||||
super().__init__(device)
|
super().__init__(device)
|
||||||
self.device = device
|
self.device = device
|
||||||
|
self.has_brightness = has_feature(
|
||||||
|
self.device, "details", "night_light_brightness"
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@ -220,16 +223,16 @@ class VeSyncNightLightHA(VeSyncDimmableLightHA):
|
|||||||
"""Get night light brightness."""
|
"""Get night light brightness."""
|
||||||
return (
|
return (
|
||||||
_vesync_brightness_to_ha(self.device.details["night_light_brightness"])
|
_vesync_brightness_to_ha(self.device.details["night_light_brightness"])
|
||||||
if has_feature(self.device, "details", "night_light_brightness")
|
if self.has_brightness
|
||||||
else None
|
else {"on": 255, "dim": 125, "off": 0}[self.device.details["night_light"]]
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return True if night light is on."""
|
"""Return True if night light is on."""
|
||||||
if has_feature(self.device, "details", "night_light"):
|
if has_feature(self.device, "details", "night_light"):
|
||||||
return self.device.details["night_light"] == "on"
|
return self.device.details["night_light"] in ["on", "dim"]
|
||||||
if has_feature(self.device, "details", "night_light_brightness"):
|
if self.has_brightness:
|
||||||
return self.device.details["night_light_brightness"] > 0
|
return self.device.details["night_light_brightness"] > 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -240,10 +243,14 @@ class VeSyncNightLightHA(VeSyncDimmableLightHA):
|
|||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
"""Turn the night light on."""
|
"""Turn the night light on."""
|
||||||
if self.device.config_dict["module"] == "VeSyncAirBypass":
|
if self.device.config_dict["module"] == "VeSyncAirBypass":
|
||||||
|
if ATTR_BRIGHTNESS in kwargs and kwargs[ATTR_BRIGHTNESS] < 255:
|
||||||
|
self.device.set_night_light("dim")
|
||||||
|
else:
|
||||||
self.device.set_night_light("on")
|
self.device.set_night_light("on")
|
||||||
elif ATTR_BRIGHTNESS in kwargs:
|
elif ATTR_BRIGHTNESS in kwargs:
|
||||||
brightness = _ha_brightness_to_vesync(kwargs[ATTR_BRIGHTNESS])
|
self.device.set_night_light_brightness(
|
||||||
self.device.set_night_light_brightness(brightness)
|
_ha_brightness_to_vesync(kwargs[ATTR_BRIGHTNESS])
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.device.set_night_light_brightness(100)
|
self.device.set_night_light_brightness(100)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user