forked from ajmarks/ha_components
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added convertable drawer to fridge
- Loading branch information
Showing
3 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .ge_fridge import GeFridge | ||
from .ge_freezer import GeFreezer | ||
from .ge_dispenser import GeDispenser | ||
from .ge_dispenser import GeDispenser | ||
from .convertable_drawer_mode_options import ConvertableDrawerModeOptionsConverter |
34 changes: 34 additions & 0 deletions
34
custom_components/ge_home/entities/fridge/convertable_drawer_mode_options.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import logging | ||
from typing import List, Any, Optional | ||
|
||
from gehomesdk import ErdConvertableDrawerMode | ||
from ..common import OptionsConverter | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
class ConvertableDrawerModeOptionsConverter(OptionsConverter): | ||
def __init__(self): | ||
super().__init__() | ||
self._excluded_options = [ | ||
ErdConvertableDrawerMode.UNKNOWN0, | ||
ErdConvertableDrawerMode.UNKNOWN1, | ||
ErdConvertableDrawerMode.NA | ||
] | ||
|
||
@property | ||
def options(self) -> List[str]: | ||
return [i.stringify() for i in ErdConvertableDrawerMode if i not in self._excluded_options] | ||
def from_option_string(self, value: str) -> Any: | ||
try: | ||
return ErdConvertableDrawerMode[value.upper()] | ||
except: | ||
_LOGGER.warn(f"Could not set hood light level to {value.upper()}") | ||
return ErdConvertableDrawerMode.NA | ||
def to_option_string(self, value: ErdConvertableDrawerMode) -> Optional[str]: | ||
try: | ||
if value is not None: | ||
return value.stringify() | ||
except: | ||
pass | ||
return ErdConvertableDrawerMode.NA.stringify() | ||
|