mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 01:58:20 +00:00
Fix tradfri cover typing
This commit is contained in:
parent
951ae92668
commit
e7cc87be4c
@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, cast
|
||||
from typing import Any
|
||||
|
||||
from pytradfri.api.aiocoap_api import APIRequestProtocol
|
||||
|
||||
@ -56,12 +56,14 @@ class TradfriCover(TradfriBaseEntity, CoverEntity):
|
||||
gateway_id=gateway_id,
|
||||
)
|
||||
|
||||
self._device_control = self._device.blind_control
|
||||
self._device_data = self._device_control.blinds[0]
|
||||
device_control = self._device.blind_control
|
||||
assert device_control # blind_control is ensured when creating the entity
|
||||
self._device_control = device_control
|
||||
self._device_data = device_control.blinds[0]
|
||||
|
||||
def _refresh(self) -> None:
|
||||
"""Refresh the device."""
|
||||
self._device_data = self.coordinator.data.blind_control.blinds[0]
|
||||
self._device_data = self._device_control.blinds[0]
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, str] | None:
|
||||
@ -74,32 +76,22 @@ class TradfriCover(TradfriBaseEntity, CoverEntity):
|
||||
|
||||
None is unknown, 0 is closed, 100 is fully open.
|
||||
"""
|
||||
if not self._device_data:
|
||||
return None
|
||||
return 100 - cast(int, self._device_data.current_cover_position)
|
||||
return 100 - self._device_data.current_cover_position
|
||||
|
||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover to a specific position."""
|
||||
if not self._device_control:
|
||||
return
|
||||
await self._api(self._device_control.set_state(100 - kwargs[ATTR_POSITION]))
|
||||
|
||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||
"""Open the cover."""
|
||||
if not self._device_control:
|
||||
return
|
||||
await self._api(self._device_control.set_state(0))
|
||||
|
||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||
"""Close cover."""
|
||||
if not self._device_control:
|
||||
return
|
||||
await self._api(self._device_control.set_state(100))
|
||||
|
||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||
"""Close cover."""
|
||||
if not self._device_control:
|
||||
return
|
||||
await self._api(self._device_control.trigger_blind())
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user