mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Restore switch.turn_on and switch.turn_off functionality for SmartTub pumps (#47586)
Revert "Remove turn_on and turn_off from SmartTub pump switches (#47184)" This reverts commit bab66a5cb968bcc7c6ef7787c9dc645885569429.
This commit is contained in:
parent
a060acc2b1
commit
7840db0598
@ -61,6 +61,20 @@ class SmartTubPump(SmartTubEntity, SwitchEntity):
|
||||
"""Return True if the pump is on."""
|
||||
return self.pump.state != SpaPump.PumpState.OFF
|
||||
|
||||
async def async_turn_on(self, **kwargs) -> None:
|
||||
"""Turn the pump on."""
|
||||
|
||||
# the API only supports toggling
|
||||
if not self.is_on:
|
||||
await self.async_toggle()
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
"""Turn the pump off."""
|
||||
|
||||
# the API only supports toggling
|
||||
if self.is_on:
|
||||
await self.async_toggle()
|
||||
|
||||
async def async_toggle(self, **kwargs) -> None:
|
||||
"""Toggle the pump on or off."""
|
||||
async with async_timeout.timeout(API_TIMEOUT):
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"pump_id,entity_suffix,pump_state",
|
||||
@ -28,3 +30,22 @@ async def test_pumps(spa, setup_entry, hass, pump_id, pump_state, entity_suffix)
|
||||
blocking=True,
|
||||
)
|
||||
pump.toggle.assert_called()
|
||||
|
||||
if state.state == STATE_OFF:
|
||||
await hass.services.async_call(
|
||||
"switch",
|
||||
"turn_on",
|
||||
{"entity_id": entity_id},
|
||||
blocking=True,
|
||||
)
|
||||
pump.toggle.assert_called()
|
||||
else:
|
||||
assert state.state == STATE_ON
|
||||
|
||||
await hass.services.async_call(
|
||||
"switch",
|
||||
"turn_off",
|
||||
{"entity_id": entity_id},
|
||||
blocking=True,
|
||||
)
|
||||
pump.toggle.assert_called()
|
||||
|
Loading…
x
Reference in New Issue
Block a user