Mark unused sync toggle method from ToggleEntity as final (#72370)
This commit is contained in:
parent
7da9cac1f8
commit
deedbca46c
2 changed files with 11 additions and 15 deletions
|
@ -52,15 +52,6 @@ class CecSwitchEntity(CecEntity, SwitchEntity):
|
|||
self._state = STATE_OFF
|
||||
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
|
||||
def is_on(self) -> bool:
|
||||
"""Return True if entity is on."""
|
||||
|
|
|
@ -1025,15 +1025,20 @@ class ToggleEntity(Entity):
|
|||
"""Turn the entity off."""
|
||||
await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))
|
||||
|
||||
@final
|
||||
def toggle(self, **kwargs: Any) -> None:
|
||||
"""Toggle the entity."""
|
||||
if self.is_on:
|
||||
self.turn_off(**kwargs)
|
||||
else:
|
||||
self.turn_on(**kwargs)
|
||||
"""Toggle the entity.
|
||||
|
||||
This method will never be called by Home Assistant and should not be implemented
|
||||
by integrations.
|
||||
"""
|
||||
|
||||
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:
|
||||
await self.async_turn_off(**kwargs)
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue