mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
ZWave.me: Light support for off transition (#169333)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -61,10 +61,21 @@ class ZWaveMeRGB(ZWaveMeEntity, LightEntity):
|
||||
self._attr_supported_features = LightEntityFeature.TRANSITION
|
||||
self._attr_supported_color_modes: set[ColorMode] = {self._attr_color_mode}
|
||||
|
||||
@staticmethod
|
||||
def _transition_to_duration(transition: float) -> int:
|
||||
rounded_transition = round(transition)
|
||||
if rounded_transition <= 127:
|
||||
return rounded_transition
|
||||
return min(127, round(rounded_transition / 60)) + 127
|
||||
|
||||
@override
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
self.controller.zwave_api.send_command(self.device.id, "off")
|
||||
"""Turn the device off."""
|
||||
command = "off"
|
||||
transition = kwargs.get(ATTR_TRANSITION)
|
||||
if transition is not None:
|
||||
command = f"exactSmooth?level=0&duration={self._transition_to_duration(transition)}"
|
||||
self.controller.zwave_api.send_command(self.device.id, command)
|
||||
|
||||
@override
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
@@ -92,11 +103,7 @@ class ZWaveMeRGB(ZWaveMeEntity, LightEntity):
|
||||
|
||||
if transition is not None:
|
||||
command_id = "exactSmooth"
|
||||
if transition < 127:
|
||||
duration = round(transition)
|
||||
else:
|
||||
duration = min(127, round((transition) / 60)) + 127
|
||||
command_args["duration"] = str(duration)
|
||||
command_args["duration"] = str(self._transition_to_duration(transition))
|
||||
|
||||
cmd = command_id
|
||||
if command_args:
|
||||
|
||||
Reference in New Issue
Block a user