diff --git a/custom_components/ge_home/entities/water_filter/filter_position.py b/custom_components/ge_home/entities/water_filter/filter_position.py index fea4c00..d9eb8b0 100644 --- a/custom_components/ge_home/entities/water_filter/filter_position.py +++ b/custom_components/ge_home/entities/water_filter/filter_position.py @@ -1,7 +1,7 @@ import logging from typing import List, Any, Optional -from gehomesdk import ErdCodeType, ErdWaterFilterPosition +from gehomesdk import ErdCodeType, ErdWaterFilterPosition, ErdCode, ErdWaterFilterMode from ...devices import ApplianceApi from ..common import GeErdSelect, OptionsConverter @@ -29,8 +29,35 @@ class GeErdFilterPositionSelect(GeErdSelect): def __init__(self, api: ApplianceApi, erd_code: ErdCodeType): super().__init__(api, erd_code, FilterPositionOptionsConverter()) + @property + def current_option(self): + """Return the current selected option""" + + #if we're transitioning or don't know what the mode is, don't allow changes + mode: ErdWaterFilterMode = self.appliance.get_erd_value(ErdCode.WH_FILTER_MODE) + if mode in [ErdWaterFilterMode.TRANSITION, ErdWaterFilterMode.UNKNOWN]: + return mode.name.title() + + return self._converter.to_option_string(self.appliance.get_erd_value(self.erd_code)) + + @property + def options(self) -> List[str]: + """Return a list of options""" + + #if we're transitioning or don't know what the mode is, don't allow changes + mode: ErdWaterFilterMode = self.appliance.get_erd_value(ErdCode.WH_FILTER_MODE) + if mode in [ErdWaterFilterMode.TRANSITION, ErdWaterFilterMode.UNKNOWN]: + return mode.name.title() + + return self._converter.options + async def async_select_option(self, option: str) -> None: value = self._converter.from_option_string(option) if value in [ErdWaterFilterPosition.UNKNOWN, ErdWaterFilterPosition.READY]: + _LOGGER.debug("Cannot set position to ready/unknown") return + if self.appliance.get_erd_value(self.erd_code) != ErdWaterFilterPosition.READY: + _LOGGER.debug("Cannot set position if not ready") + return + return await super().async_select_option(option)