mirror of https://github.com/simbaja/ha_gehome.git
- added fridge/freezer controls
This commit is contained in:
parent
ff983cc594
commit
19c05fc83d
|
@ -31,7 +31,8 @@ from ..entities import (
|
|||
GeDispenser,
|
||||
GeErdPropertySensor,
|
||||
GeErdPropertyBinarySensor,
|
||||
ConvertableDrawerModeOptionsConverter
|
||||
ConvertableDrawerModeOptionsConverter,
|
||||
GeFridgeIceControlSwitch
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -61,7 +62,10 @@ class FridgeApi(ApplianceApi):
|
|||
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
|
||||
|
@ -80,8 +84,11 @@ class FridgeApi(ApplianceApi):
|
|||
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):
|
||||
|
@ -105,8 +112,13 @@ class FridgeApi(ApplianceApi):
|
|||
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"))
|
||||
|
||||
|
|
|
@ -29,5 +29,5 @@ class GeErdSwitch(GeErdBinarySensor, SwitchEntity):
|
|||
|
||||
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())
|
||||
|
|
|
@ -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
|
|
@ -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)
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue