1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-17 03:23:26 +01:00
Files
2026-06-22 15:14:48 +01:00

55 lines
1.7 KiB
Python

"""Support for Spa Client selects."""
from typing import override
from pybalboa import SpaControl
from pybalboa.enums import LowHighRange
from homeassistant.components.select import SelectEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import BalboaConfigEntry
from .entity import BalboaEntity
async def async_setup_entry(
hass: HomeAssistant,
entry: BalboaConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
) -> None:
"""Set up the spa select entity."""
spa = entry.runtime_data
async_add_entities([BalboaTempRangeSelectEntity(spa.temperature_range)])
class BalboaTempRangeSelectEntity(BalboaEntity, SelectEntity):
"""Representation of a Temperature Range select."""
_attr_translation_key = "temperature_range"
_attr_options = [
LowHighRange.LOW.name.lower(),
LowHighRange.HIGH.name.lower(),
]
def __init__(self, control: SpaControl) -> None:
"""Initialise the select."""
super().__init__(control.client, "TempHiLow")
self._control = control
@property
@override
def current_option(self) -> str | None:
"""Return current select option."""
if self._control.state == LowHighRange.HIGH:
return LowHighRange.HIGH.name.lower()
return LowHighRange.LOW.name.lower()
@override
async def async_select_option(self, option: str) -> None:
"""Select temperature range high/low mode."""
if option == LowHighRange.HIGH.name.lower():
await self._client.set_temperature_range(LowHighRange.HIGH)
else:
await self._client.set_temperature_range(LowHighRange.LOW)