mirror of https://github.com/simbaja/ha_gehome.git
Add support for fridges with reduced support for ERD codes (no turbo mode, no current temperature reporting, no temperature setpoint limit reporting, no door status reporting). This change has been tested on a Fisher & Paykel RF610AA.
This commit is contained in:
parent
73f3154eba
commit
0afb05f9ee
|
@ -6,6 +6,7 @@ import logging
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||||
|
from homeassistant.util.temperature import convert as convert_temperature
|
||||||
|
|
||||||
from gehomesdk import (
|
from gehomesdk import (
|
||||||
ErdCode,
|
ErdCode,
|
||||||
|
@ -26,6 +27,14 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
class GeAbstractFridge(GeWaterHeater):
|
class GeAbstractFridge(GeWaterHeater):
|
||||||
"""Mock a fridge or freezer as a water heater."""
|
"""Mock a fridge or freezer as a water heater."""
|
||||||
|
|
||||||
|
# These values are from the Fisher & Paykel RF610AA in imperial units
|
||||||
|
# They're to be used as hardcoded limits when ErdCode.SETPOINT_LIMITS is unavailable.
|
||||||
|
temp_limits = {}
|
||||||
|
temp_limits["fridge_min"] = 32
|
||||||
|
temp_limits["fridge_max"] = 46
|
||||||
|
temp_limits["freezer_min"] = -6
|
||||||
|
temp_limits["freezer_max"] = 7
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def heater_type(self) -> str:
|
def heater_type(self) -> str:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -40,7 +49,11 @@ class GeAbstractFridge(GeWaterHeater):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def operation_list(self) -> List[str]:
|
def operation_list(self) -> List[str]:
|
||||||
|
try:
|
||||||
return [OP_MODE_NORMAL, OP_MODE_SABBATH, self.turbo_mode]
|
return [OP_MODE_NORMAL, OP_MODE_SABBATH, self.turbo_mode]
|
||||||
|
except:
|
||||||
|
_LOGGER.debug("Turbo mode not supported.")
|
||||||
|
return [OP_MODE_NORMAL, OP_MODE_SABBATH]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
|
@ -63,11 +76,15 @@ class GeAbstractFridge(GeWaterHeater):
|
||||||
@property
|
@property
|
||||||
def current_temperature(self) -> int:
|
def current_temperature(self) -> int:
|
||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
|
try:
|
||||||
current_temps = self.appliance.get_erd_value(ErdCode.CURRENT_TEMPERATURE)
|
current_temps = self.appliance.get_erd_value(ErdCode.CURRENT_TEMPERATURE)
|
||||||
current_temp = getattr(current_temps, self.heater_type)
|
current_temp = getattr(current_temps, self.heater_type)
|
||||||
if current_temp is None:
|
if current_temp is None:
|
||||||
_LOGGER.exception(f"{self.name} has None for current_temperature (available: {self.available})!")
|
_LOGGER.exception(f"{self.name} has None for current_temperature (available: {self.available})!")
|
||||||
return current_temp
|
return current_temp
|
||||||
|
except:
|
||||||
|
_LOGGER.debug("Device doesn't report current temperature.")
|
||||||
|
return None
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs):
|
async def async_set_temperature(self, **kwargs):
|
||||||
target_temp = kwargs.get(ATTR_TEMPERATURE)
|
target_temp = kwargs.get(ATTR_TEMPERATURE)
|
||||||
|
@ -95,21 +112,32 @@ class GeAbstractFridge(GeWaterHeater):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_temp(self):
|
def min_temp(self):
|
||||||
"""Return the minimum temperature."""
|
"""Return the minimum temperature if available, otherwise use hardcoded limits."""
|
||||||
|
try:
|
||||||
return getattr(self.setpoint_limits, f"{self.heater_type}_min")
|
return getattr(self.setpoint_limits, f"{self.heater_type}_min")
|
||||||
|
except:
|
||||||
|
_LOGGER.debug("No temperature setpoint limits available. Using hardcoded limits.")
|
||||||
|
return convert_temperature(self.temp_limits[f"{self.heater_type}_min"], TEMP_FAHRENHEIT, self.temperature_unit)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self):
|
def max_temp(self):
|
||||||
"""Return the maximum temperature."""
|
"""Return the maximum temperature if available, otherwise use hardcoded limits."""
|
||||||
|
try:
|
||||||
return getattr(self.setpoint_limits, f"{self.heater_type}_max")
|
return getattr(self.setpoint_limits, f"{self.heater_type}_max")
|
||||||
|
except:
|
||||||
|
_LOGGER.debug("No temperature setpoint limits available. Using hardcoded limits.")
|
||||||
|
return convert_temperature(self.temp_limits[f"{self.heater_type}_max"], TEMP_FAHRENHEIT, self.temperature_unit)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_operation(self) -> str:
|
def current_operation(self) -> str:
|
||||||
"""Get the current operation mode."""
|
"""Get the current operation mode."""
|
||||||
if self.appliance.get_erd_value(ErdCode.SABBATH_MODE):
|
if self.appliance.get_erd_value(ErdCode.SABBATH_MODE):
|
||||||
return OP_MODE_SABBATH
|
return OP_MODE_SABBATH
|
||||||
|
try:
|
||||||
if self.appliance.get_erd_value(self.turbo_erd_code):
|
if self.appliance.get_erd_value(self.turbo_erd_code):
|
||||||
return self.turbo_mode
|
return self.turbo_mode
|
||||||
|
except:
|
||||||
|
_LOGGER.debug("Turbo mode not supported.")
|
||||||
return OP_MODE_NORMAL
|
return OP_MODE_NORMAL
|
||||||
|
|
||||||
async def async_set_sabbath_mode(self, sabbath_on: bool = True):
|
async def async_set_sabbath_mode(self, sabbath_on: bool = True):
|
||||||
|
|
|
@ -26,7 +26,10 @@ class GeFreezer(GeAbstractFridge):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def door_state_attrs(self) -> Optional[Dict[str, Any]]:
|
def door_state_attrs(self) -> Optional[Dict[str, Any]]:
|
||||||
|
try:
|
||||||
door_status = self.door_status.freezer
|
door_status = self.door_status.freezer
|
||||||
if door_status and door_status != ErdDoorStatus.NA:
|
if door_status and door_status != ErdDoorStatus.NA:
|
||||||
return {ATTR_DOOR_STATUS: self._stringify(door_status)}
|
return {ATTR_DOOR_STATUS: self._stringify(door_status)}
|
||||||
|
except:
|
||||||
|
_LOGGER.debug("Device does not report door status.")
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -36,6 +36,7 @@ class GeFridge(GeAbstractFridge):
|
||||||
@property
|
@property
|
||||||
def door_state_attrs(self) -> Dict[str, Any]:
|
def door_state_attrs(self) -> Dict[str, Any]:
|
||||||
"""Get state attributes for the doors."""
|
"""Get state attributes for the doors."""
|
||||||
|
try:
|
||||||
data = {}
|
data = {}
|
||||||
door_status = self.door_status
|
door_status = self.door_status
|
||||||
if not door_status:
|
if not door_status:
|
||||||
|
@ -56,3 +57,6 @@ class GeFridge(GeAbstractFridge):
|
||||||
data[ATTR_DOOR_STATUS] = "Closed" if all_closed else "Open"
|
data[ATTR_DOOR_STATUS] = "Closed" if all_closed else "Open"
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
except:
|
||||||
|
_LOGGER.debug("Device does not report door status.")
|
||||||
|
return {}
|
||||||
|
|
Loading…
Reference in New Issue