"""Support for Rheem EcoNet thermostats with variable fan speeds and fan modes.""" from __future__ import annotations from pyeconet.equipment import EquipmentType from pyeconet.equipment.thermostat import Thermostat, ThermostatFanMode from homeassistant.components.select import SelectEntity from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import EconetConfigEntry from .entity import EcoNetEntity async def async_setup_entry( hass: HomeAssistant, entry: EconetConfigEntry, async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Set up the econet thermostat select entity.""" equipment = entry.runtime_data async_add_entities( EconetFanModeSelect(thermostat) for thermostat in equipment[EquipmentType.THERMOSTAT] if thermostat.supports_fan_mode ) class EconetFanModeSelect(EcoNetEntity[Thermostat], SelectEntity): """Select entity.""" def __init__(self, thermostat: Thermostat) -> None: """Initialize EcoNet platform.""" super().__init__(thermostat) self._attr_name = f"{thermostat.device_name} fan mode" self._attr_unique_id = ( f"{thermostat.device_id}_{thermostat.device_name}_fan_mode" ) @property def options(self) -> list[str]: """Return available select options.""" return [e.value for e in self._econet.fan_modes] @property def current_option(self) -> str: """Return current select option.""" return self._econet.fan_mode.value def select_option(self, option: str) -> None: """Set the selected option.""" self._econet.set_fan_mode(ThermostatFanMode.by_string(option))