1 """Support for Balboa Spa pumps."""
3 from __future__
import annotations
6 from typing
import Any, cast
8 from pybalboa
import SpaControl
9 from pybalboa.enums
import OffOnState, UnknownState
15 percentage_to_ranged_value,
16 ranged_value_to_percentage,
19 from .
import BalboaConfigEntry
20 from .entity
import BalboaEntity
25 entry: BalboaConfigEntry,
26 async_add_entities: AddEntitiesCallback,
28 """Set up the spa's pumps."""
29 spa = entry.runtime_data
34 """Representation of a Balboa Spa pump fan entity."""
36 _attr_supported_features = (
37 FanEntityFeature.SET_SPEED
38 | FanEntityFeature.TURN_OFF
39 | FanEntityFeature.TURN_ON
41 _enable_turn_on_off_backwards_compatibility =
False
42 _attr_translation_key =
"pump"
44 def __init__(self, control: SpaControl) ->
None:
45 """Initialize a Balboa pump fan entity."""
46 super().
__init__(control.client, control.name)
49 "index": f
"{cast(int, control.index) + 1}"
53 """Turn the pump off."""
54 await self.
_control_control.set_state(OffOnState.OFF)
58 percentage: int |
None =
None,
59 preset_mode: str |
None =
None,
62 """Turn the pump on (by default on max speed)."""
63 if percentage
is None:
68 """Set the speed of the pump."""
74 state = OffOnState.OFF
75 await self.
_control_control.set_state(state)
79 """Return the speed of the pump."""
80 if self.
_control_control.state == UnknownState.UNKNOWN:
82 if self.
_control_control.state == OffOnState.OFF:
88 """Return true if the pump is running."""
89 if self.
_control_control.state == UnknownState.UNKNOWN:
91 return self.
_control_control.state != OffOnState.OFF
95 """Return the number of different speed settings the pump supports."""
None async_turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
int|None percentage(self)
_attr_translation_placeholders
None async_set_percentage(self, int percentage)
None __init__(self, SpaControl control)
None async_turn_off(self, **Any kwargs)
None async_set_percentage(self, int percentage)
None async_setup_entry(HomeAssistant hass, BalboaConfigEntry entry, AddEntitiesCallback async_add_entities)
float percentage_to_ranged_value(tuple[float, float] low_high_range, float percentage)
int ranged_value_to_percentage(tuple[float, float] low_high_range, float value)