Adjust type hints in rflink cover (#73946)
* Adjust type hints in rflink cover
* Move definition back to init
* Use attributes
* Revert "Use attributes"
This reverts commit ff4851015d
.
* Use _attr_should_poll
pull/73834/head
parent
00810235c9
commit
aca0fd3178
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Rflink devices."""
|
"""Support for Rflink devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import logging
|
import logging
|
||||||
|
@ -315,8 +317,9 @@ class RflinkDevice(Entity):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
platform = None
|
platform = None
|
||||||
_state = None
|
_state: bool | None = None
|
||||||
_available = True
|
_available = True
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -369,11 +372,6 @@ class RflinkDevice(Entity):
|
||||||
"""Platform specific event handler."""
|
"""Platform specific event handler."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return a name for the device."""
|
"""Return a name for the device."""
|
||||||
|
|
|
@ -125,7 +125,7 @@ async def async_setup_platform(
|
||||||
class RflinkCover(RflinkCommand, CoverEntity, RestoreEntity):
|
class RflinkCover(RflinkCommand, CoverEntity, RestoreEntity):
|
||||||
"""Rflink entity which can switch on/stop/off (eg: cover)."""
|
"""Rflink entity which can switch on/stop/off (eg: cover)."""
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Restore RFLink cover state (OPEN/CLOSE)."""
|
"""Restore RFLink cover state (OPEN/CLOSE)."""
|
||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
if (old_state := await self.async_get_last_state()) is not None:
|
if (old_state := await self.async_get_last_state()) is not None:
|
||||||
|
@ -142,17 +142,12 @@ class RflinkCover(RflinkCommand, CoverEntity, RestoreEntity):
|
||||||
self._state = False
|
self._state = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def is_closed(self) -> bool | None:
|
||||||
"""No polling available in RFlink cover."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_closed(self):
|
|
||||||
"""Return if the cover is closed."""
|
"""Return if the cover is closed."""
|
||||||
return not self._state
|
return not self._state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def assumed_state(self):
|
def assumed_state(self) -> bool:
|
||||||
"""Return True because covers can be stopped midway."""
|
"""Return True because covers can be stopped midway."""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue