Skip to content

Commit

Permalink
- added fridge/freezer controls
Browse files Browse the repository at this point in the history
  • Loading branch information
simbaja committed Nov 27, 2023
1 parent ff983cc commit 19c05fc
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
16 changes: 14 additions & 2 deletions custom_components/ge_home/devices/fridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
GeDispenser,
GeErdPropertySensor,
GeErdPropertyBinarySensor,
ConvertableDrawerModeOptionsConverter
ConvertableDrawerModeOptionsConverter,
GeFridgeIceControlSwitch
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -61,7 +62,10 @@ def get_all_entities(self) -> List[Entity]:
proximity_light: ErdOnOff = self.try_get_erd_value(ErdCode.PROXIMITY_LIGHT)
display_mode: ErdOnOff = self.try_get_erd_value(ErdCode.DISPLAY_MODE)
lockout_mode: ErdOnOff = self.try_get_erd_value(ErdCode.LOCKOUT_MODE)

turbo_cool: ErdOnOff = self.try_get_erd_value(ErdCode.TURBO_COOL_STATUS)
turbo_freeze: ErdOnOff = self.try_get_erd_value(ErdCode.TURBO_FREEZE_STATUS)
ice_boost: ErdOnOff = self.try_get_erd_value(ErdCode.FRIDGE_ICE_BOOST)

units = self.hass.config.units

# Common entities
Expand All @@ -80,8 +84,11 @@ def get_all_entities(self) -> List[Entity]:
GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "fridge"),
GeFridge(self),
])
if turbo_cool is not None:
fridge_entities.append(GeErdSwitch(self, ErdCode.FRIDGE_ICE_BOOST))
if(ice_maker_control and ice_maker_control.status_fridge != ErdOnOff.NA):
fridge_entities.append(GeErdPropertyBinarySensor(self, ErdCode.ICE_MAKER_CONTROL, "status_fridge"))
fridge_entities.append(GeFridgeIceControlSwitch(self, "fridge"))
if(water_filter and water_filter != ErdFilterStatus.NA):
fridge_entities.append(GeErdSensor(self, ErdCode.WATER_FILTER_STATUS))
if(air_filter and air_filter != ErdFilterStatus.NA):
Expand All @@ -105,8 +112,13 @@ def get_all_entities(self) -> List[Entity]:
GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "freezer"),
GeFreezer(self),
])
if turbo_freeze is not None:
freezer_entities.append(GeErdSwitch(self, ErdCode.TURBO_FREEZE_STATUS))
if ice_boost is not None:
freezer_entities.append(GeErdSwitch(self, ErdCode.FRIDGE_ICE_BOOST))
if(ice_maker_control and ice_maker_control.status_freezer != ErdOnOff.NA):
freezer_entities.append(GeErdPropertyBinarySensor(self, ErdCode.ICE_MAKER_CONTROL, "status_freezer"))
freezer_entities.append(GeFridgeIceControlSwitch(self, "freezer"))
if(ice_bucket_status and ice_bucket_status.is_present_freezer):
freezer_entities.append(GeErdPropertySensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS, "state_full_freezer"))

Expand Down
2 changes: 1 addition & 1 deletion custom_components/ge_home/entities/common/ge_erd_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ async def async_turn_on(self, **kwargs):

async def async_turn_off(self, **kwargs):
"""Turn the switch off."""
_LOGGER.debug(f"Turning on {self.unique_id}")
_LOGGER.debug(f"Turning off {self.unique_id}")
await self.appliance.async_set_erd_value(self.erd_code, self._converter.false_value())
3 changes: 2 additions & 1 deletion custom_components/ge_home/entities/fridge/__init__.py
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
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)
2 changes: 1 addition & 1 deletion custom_components/ge_home/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"integration_type": "hub",
"iot_class": "cloud_push",
"documentation": "https://github.com/simbaja/ha_gehome",
"requirements": ["gehomesdk==0.5.24","magicattr==0.1.6","slixmpp==1.8.3"],
"requirements": ["gehomesdk==0.5.25","magicattr==0.1.6","slixmpp==1.8.3"],
"codeowners": ["@simbaja"],
"version": "0.6.9"
}

0 comments on commit 19c05fc

Please sign in to comment.