mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Mark unused sync toggle method from ToggleEntity as final (#72370)
This commit is contained in:
parent
7da9cac1f8
commit
deedbca46c
@ -52,15 +52,6 @@ class CecSwitchEntity(CecEntity, SwitchEntity):
|
|||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
self.schedule_update_ha_state(force_refresh=False)
|
self.schedule_update_ha_state(force_refresh=False)
|
||||||
|
|
||||||
def toggle(self, **kwargs):
|
|
||||||
"""Toggle the entity."""
|
|
||||||
self._device.toggle()
|
|
||||||
if self._state == STATE_ON:
|
|
||||||
self._state = STATE_OFF
|
|
||||||
else:
|
|
||||||
self._state = STATE_ON
|
|
||||||
self.schedule_update_ha_state(force_refresh=False)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return True if entity is on."""
|
"""Return True if entity is on."""
|
||||||
|
@ -1025,15 +1025,20 @@ class ToggleEntity(Entity):
|
|||||||
"""Turn the entity off."""
|
"""Turn the entity off."""
|
||||||
await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))
|
await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))
|
||||||
|
|
||||||
|
@final
|
||||||
def toggle(self, **kwargs: Any) -> None:
|
def toggle(self, **kwargs: Any) -> None:
|
||||||
"""Toggle the entity."""
|
"""Toggle the entity.
|
||||||
if self.is_on:
|
|
||||||
self.turn_off(**kwargs)
|
This method will never be called by Home Assistant and should not be implemented
|
||||||
else:
|
by integrations.
|
||||||
self.turn_on(**kwargs)
|
"""
|
||||||
|
|
||||||
async def async_toggle(self, **kwargs: Any) -> None:
|
async def async_toggle(self, **kwargs: Any) -> None:
|
||||||
"""Toggle the entity."""
|
"""Toggle the entity.
|
||||||
|
|
||||||
|
This method should typically not be implemented by integrations, it's enough to
|
||||||
|
implement async_turn_on + async_turn_off or turn_on + turn_off.
|
||||||
|
"""
|
||||||
if self.is_on:
|
if self.is_on:
|
||||||
await self.async_turn_off(**kwargs)
|
await self.async_turn_off(**kwargs)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user