From 4f9c4df200877bcb417658852c1cf0ac070540d7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 27 Nov 2026 07:51:39 +0100 Subject: [PATCH] Use the action field enums in velux (#194877) --- homeassistant/components/velux/cover.py | 22 ++++++++++------------ homeassistant/components/velux/light.py | 6 +++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/velux/cover.py b/homeassistant/components/velux/cover.py index 00ccecf2b0c5..f4beaac341ab 100644 --- a/homeassistant/components/velux/cover.py +++ b/homeassistant/components/velux/cover.py @@ -17,13 +17,11 @@ from pyvlx.opening_device import ( ) from homeassistant.components.cover import ( - ATTR_POSITION, - ATTR_SPEED, - ATTR_TILT_POSITION, CoverDeviceClass, CoverEntity, CoverEntityCapabilityAttribute, CoverEntityFeature, + CoverServiceArgument, CoverSpeed, ) from homeassistant.core import HomeAssistant @@ -181,22 +179,22 @@ class VeluxCover(VeluxEntity, CoverEntity): @override async def async_close_cover(self, **kwargs: Any) -> None: """Close the cover.""" - velocity = self._velocity_from_speed(kwargs.get(ATTR_SPEED)) + velocity = self._velocity_from_speed(kwargs.get(CoverServiceArgument.SPEED)) await self.node.close(velocity=velocity, wait_for_completion=False) @wrap_pyvlx_call_exceptions @override async def async_open_cover(self, **kwargs: Any) -> None: """Open the cover.""" - velocity = self._velocity_from_speed(kwargs.get(ATTR_SPEED)) + velocity = self._velocity_from_speed(kwargs.get(CoverServiceArgument.SPEED)) await self.node.open(velocity=velocity, wait_for_completion=False) @wrap_pyvlx_call_exceptions @override async def async_set_cover_position(self, **kwargs: Any) -> None: """Move the cover to a specific position.""" - position_percent = 100 - kwargs[ATTR_POSITION] - velocity = self._velocity_from_speed(kwargs.get(ATTR_SPEED)) + position_percent = 100 - kwargs[CoverServiceArgument.POSITION] + velocity = self._velocity_from_speed(kwargs.get(CoverServiceArgument.SPEED)) await self.node.set_position( Position(position_percent=position_percent), @@ -272,7 +270,7 @@ class VeluxDualRollerShutter(VeluxCover): @override async def async_close_cover(self, **kwargs: Any) -> None: """Close the cover.""" - velocity = self._velocity_from_speed(kwargs.get(ATTR_SPEED)) + velocity = self._velocity_from_speed(kwargs.get(CoverServiceArgument.SPEED)) await self.node.close( curtain=self.part, velocity=velocity, wait_for_completion=False ) @@ -281,7 +279,7 @@ class VeluxDualRollerShutter(VeluxCover): @override async def async_open_cover(self, **kwargs: Any) -> None: """Open the cover.""" - velocity = self._velocity_from_speed(kwargs.get(ATTR_SPEED)) + velocity = self._velocity_from_speed(kwargs.get(CoverServiceArgument.SPEED)) await self.node.open( curtain=self.part, velocity=velocity, wait_for_completion=False ) @@ -290,8 +288,8 @@ class VeluxDualRollerShutter(VeluxCover): @override async def async_set_cover_position(self, **kwargs: Any) -> None: """Move the cover to a specific position.""" - position_percent = 100 - kwargs[ATTR_POSITION] - velocity = self._velocity_from_speed(kwargs.get(ATTR_SPEED)) + position_percent = 100 - kwargs[CoverServiceArgument.POSITION] + velocity = self._velocity_from_speed(kwargs.get(CoverServiceArgument.SPEED)) await self.node.set_position( Position(position_percent=position_percent), @@ -350,7 +348,7 @@ class VeluxBlind(VeluxCover): @override async def async_set_cover_tilt_position(self, **kwargs: Any) -> None: """Move cover tilt to a specific position.""" - position_percent = 100 - kwargs[ATTR_TILT_POSITION] + position_percent = 100 - kwargs[CoverServiceArgument.TILT_POSITION] orientation = Position(position_percent=position_percent) await self.node.set_orientation( orientation=orientation, wait_for_completion=False diff --git a/homeassistant/components/velux/light.py b/homeassistant/components/velux/light.py index 197f7385da98..68ad0f8049d3 100644 --- a/homeassistant/components/velux/light.py +++ b/homeassistant/components/velux/light.py @@ -4,7 +4,7 @@ from typing import Any, override from pyvlx import DimmableDevice, Intensity, Light, OnOffLight -from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity +from homeassistant.components.light import ColorMode, LightEntity, LightServiceArgument from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback @@ -75,8 +75,8 @@ class VeluxDimmableLight(VeluxOnOffLight): @override async def async_turn_on(self, **kwargs: Any) -> None: """Instruct the light to turn on.""" - if ATTR_BRIGHTNESS in kwargs: - intensity_percent = int(kwargs[ATTR_BRIGHTNESS] / 255 * 100) + if LightServiceArgument.BRIGHTNESS in kwargs: + intensity_percent = int(kwargs[LightServiceArgument.BRIGHTNESS] / 255 * 100) await self.node.set_intensity( Intensity(intensity_percent=intensity_percent), wait_for_completion=True,