forked from ajmarks/ha_components
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
5 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
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,4 +1,5 @@ | ||
from .ge_fridge import GeFridge | ||
from .ge_freezer import GeFreezer | ||
from .ge_dispenser import GeDispenser | ||
from .convertable_drawer_mode_options import ConvertableDrawerModeOptionsConverter | ||
from .convertable_drawer_mode_options import ConvertableDrawerModeOptionsConverter | ||
from .ge_fridge_ice_control_switch import GeFridgeIceControlSwitch |
47 changes: 47 additions & 0 deletions
47
custom_components/ge_home/entities/fridge/ge_fridge_ice_control_switch.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,47 @@ | ||
import logging | ||
from gehomesdk import ErdCode, IceMakerControlStatus, ErdOnOff | ||
|
||
from ...devices import ApplianceApi | ||
from ..common import GeErdSwitch, BoolConverter | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
class GeFridgeIceControlSwitch(GeErdSwitch): | ||
def __init__(self, api: ApplianceApi, control_type: str): | ||
super().__init__(api, ErdCode.ICE_MAKER_CONTROL, BoolConverter()) | ||
self._control_type = control_type | ||
|
||
@property | ||
def control_status(self) -> IceMakerControlStatus: | ||
return self.appliance.get_erd_value(ErdCode.ICE_MAKER_CONTROL) | ||
|
||
@property | ||
def is_on(self) -> bool: | ||
if self._control_type == "fridge": | ||
return self.control_status.status_fridge == ErdOnOff.ON | ||
else: | ||
return self.control_status.status_freezer == ErdOnOff.ON | ||
|
||
async def async_turn_on(self, **kwargs): | ||
"""Turn the switch on.""" | ||
_LOGGER.debug(f"Turning on {self.unique_id}") | ||
|
||
old_status = self.control_status | ||
if self._control_type == "fridge": | ||
new_status = IceMakerControlStatus(ErdOnOff.ON, old_status.status_freezer) | ||
else: | ||
new_status = IceMakerControlStatus(old_status.status_fridge, ErdOnOff.ON) | ||
|
||
await self.appliance.async_set_erd_value(self.erd_code, new_status) | ||
|
||
async def async_turn_off(self, **kwargs): | ||
"""Turn the switch off.""" | ||
_LOGGER.debug(f"Turning off {self.unique_id}") | ||
|
||
old_status = self.control_status | ||
if self._control_type == "fridge": | ||
new_status = IceMakerControlStatus(ErdOnOff.OFF, old_status.status_freezer) | ||
else: | ||
new_status = IceMakerControlStatus(old_status.status_fridge, ErdOnOff.OFF) | ||
|
||
await self.appliance.async_set_erd_value(self.erd_code, new_status) |
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