From dfc7ff8e646e88d8ba55b16f157f3aceba759d5b Mon Sep 17 00:00:00 2001 From: DeerMaximum <43999966+DeerMaximum@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:28:42 +0000 Subject: [PATCH] Bump pyvlx to 0.2.21 (#105800) * Bump pyvlx to 0.2.21 * Fix typing * Optimize fix --- homeassistant/components/velux/__init__.py | 4 ++-- homeassistant/components/velux/cover.py | 13 +++++++------ homeassistant/components/velux/light.py | 2 ++ homeassistant/components/velux/manifest.json | 2 +- requirements_all.txt | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/velux/__init__.py b/homeassistant/components/velux/__init__.py index b43ee39ed4e..d6a5f540c06 100644 --- a/homeassistant/components/velux/__init__.py +++ b/homeassistant/components/velux/__init__.py @@ -1,7 +1,7 @@ """Support for VELUX KLF 200 devices.""" import logging -from pyvlx import OpeningDevice, PyVLX, PyVLXException +from pyvlx import Node, PyVLX, PyVLXException import voluptuous as vol from homeassistant.const import ( @@ -90,7 +90,7 @@ class VeluxEntity(Entity): _attr_should_poll = False - def __init__(self, node: OpeningDevice) -> None: + def __init__(self, node: Node) -> None: """Initialize the Velux device.""" self.node = node self._attr_unique_id = node.serial_number diff --git a/homeassistant/components/velux/cover.py b/homeassistant/components/velux/cover.py index 48c09a2b3c2..c8fb2aafb96 100644 --- a/homeassistant/components/velux/cover.py +++ b/homeassistant/components/velux/cover.py @@ -1,7 +1,7 @@ """Support for Velux covers.""" from __future__ import annotations -from typing import Any +from typing import Any, cast from pyvlx import OpeningDevice, Position from pyvlx.opening_device import Awning, Blind, GarageDoor, Gate, RollerShutter, Window @@ -40,6 +40,7 @@ class VeluxCover(VeluxEntity, CoverEntity): """Representation of a Velux cover.""" _is_blind = False + node: OpeningDevice def __init__(self, node: OpeningDevice) -> None: """Initialize VeluxCover.""" @@ -86,7 +87,7 @@ class VeluxCover(VeluxEntity, CoverEntity): def current_cover_tilt_position(self) -> int | None: """Return the current position of the cover.""" if self._is_blind: - return 100 - self.node.orientation.position_percent + return 100 - cast(Blind, self.node).orientation.position_percent return None @property @@ -116,20 +117,20 @@ class VeluxCover(VeluxEntity, CoverEntity): async def async_close_cover_tilt(self, **kwargs: Any) -> None: """Close cover tilt.""" - await self.node.close_orientation(wait_for_completion=False) + await cast(Blind, self.node).close_orientation(wait_for_completion=False) async def async_open_cover_tilt(self, **kwargs: Any) -> None: """Open cover tilt.""" - await self.node.open_orientation(wait_for_completion=False) + await cast(Blind, self.node).open_orientation(wait_for_completion=False) async def async_stop_cover_tilt(self, **kwargs: Any) -> None: """Stop cover tilt.""" - await self.node.stop_orientation(wait_for_completion=False) + await cast(Blind, self.node).stop_orientation(wait_for_completion=False) 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] orientation = Position(position_percent=position_percent) - await self.node.set_orientation( + await cast(Blind, 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 a600aceedd2..a6d63436ecf 100644 --- a/homeassistant/components/velux/light.py +++ b/homeassistant/components/velux/light.py @@ -35,6 +35,8 @@ class VeluxLight(VeluxEntity, LightEntity): _attr_supported_color_modes = {ColorMode.BRIGHTNESS} _attr_color_mode = ColorMode.BRIGHTNESS + node: LighteningDevice + @property def brightness(self): """Return the current brightness.""" diff --git a/homeassistant/components/velux/manifest.json b/homeassistant/components/velux/manifest.json index 0495ff80a43..901034aa387 100644 --- a/homeassistant/components/velux/manifest.json +++ b/homeassistant/components/velux/manifest.json @@ -5,5 +5,5 @@ "documentation": "https://www.home-assistant.io/integrations/velux", "iot_class": "local_polling", "loggers": ["pyvlx"], - "requirements": ["pyvlx==0.2.20"] + "requirements": ["pyvlx==0.2.21"] } diff --git a/requirements_all.txt b/requirements_all.txt index 46cd06c365e..7a4cec7cef6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2287,7 +2287,7 @@ pyvesync==2.1.10 pyvizio==0.1.61 # homeassistant.components.velux -pyvlx==0.2.20 +pyvlx==0.2.21 # homeassistant.components.volumio pyvolumio==0.1.5