mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Cleanup update/async_update typing in Entities (#74035)
This commit is contained in:
parent
21b842cf9c
commit
e8917af823
@ -233,7 +233,7 @@ class GaradgetCover(CoverEntity):
|
|||||||
self._start_watcher("stop")
|
self._start_watcher("stop")
|
||||||
return ret["return_value"] == 1
|
return ret["return_value"] == 1
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get updated status from API."""
|
"""Get updated status from API."""
|
||||||
try:
|
try:
|
||||||
status = self._get_variable("doorStatus")
|
status = self._get_variable("doorStatus")
|
||||||
|
@ -66,7 +66,7 @@ class LutronCover(LutronDevice, CoverEntity):
|
|||||||
position = kwargs[ATTR_POSITION]
|
position = kwargs[ATTR_POSITION]
|
||||||
self._lutron_device.level = position
|
self._lutron_device.level = position
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Call when forcing a refresh of the device."""
|
"""Call when forcing a refresh of the device."""
|
||||||
# Reading the property (rather than last_level()) fetches value
|
# Reading the property (rather than last_level()) fetches value
|
||||||
level = self._lutron_device.level
|
level = self._lutron_device.level
|
||||||
|
@ -102,7 +102,7 @@ class SomaTilt(SomaEntity, CoverEntity):
|
|||||||
)
|
)
|
||||||
self.set_position(kwargs[ATTR_TILT_POSITION])
|
self.set_position(kwargs[ATTR_TILT_POSITION])
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Update the entity with the latest data."""
|
"""Update the entity with the latest data."""
|
||||||
response = await self.get_shade_state_from_api()
|
response = await self.get_shade_state_from_api()
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ class SomaShade(SomaEntity, CoverEntity):
|
|||||||
f'Error while setting the cover position ({self.name}): {response["msg"]}'
|
f'Error while setting the cover position ({self.name}): {response["msg"]}'
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Update the cover with the latest data."""
|
"""Update the cover with the latest data."""
|
||||||
response = await self.get_shade_state_from_api()
|
response = await self.get_shade_state_from_api()
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class ZhaCover(ZhaEntity, CoverEntity):
|
|||||||
self._state = STATE_OPEN if self._current_position > 0 else STATE_CLOSED
|
self._state = STATE_OPEN if self._current_position > 0 else STATE_CLOSED
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Attempt to retrieve the open/close state of the cover."""
|
"""Attempt to retrieve the open/close state of the cover."""
|
||||||
await super().async_update()
|
await super().async_update()
|
||||||
await self.async_get_state()
|
await self.async_get_state()
|
||||||
|
@ -202,7 +202,7 @@ class FanGroup(BaseFan, ZhaGroupEntity):
|
|||||||
self.error("Could not set fan mode: %s", ex)
|
self.error("Could not set fan mode: %s", ex)
|
||||||
self.async_set_state(0, "fan_mode", fan_mode)
|
self.async_set_state(0, "fan_mode", fan_mode)
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Attempt to retrieve on off state from the fan."""
|
"""Attempt to retrieve on off state from the fan."""
|
||||||
all_states = [self.hass.states.get(x) for x in self._entity_ids]
|
all_states = [self.hass.states.get(x) for x in self._entity_ids]
|
||||||
states: list[State] = list(filter(None, all_states))
|
states: list[State] = list(filter(None, all_states))
|
||||||
|
@ -137,7 +137,7 @@ class ZhaDoorLock(ZhaEntity, LockEntity):
|
|||||||
return
|
return
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Attempt to retrieve state from the lock."""
|
"""Attempt to retrieve state from the lock."""
|
||||||
await super().async_update()
|
await super().async_update()
|
||||||
await self.async_get_state()
|
await self.async_get_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user