mirror of https://github.com/simbaja/ha_gehome.git
- cleaned up the fridge water heater entities
This commit is contained in:
parent
b4f4a172f0
commit
6f0bacbdbf
|
@ -1,4 +1,5 @@
|
|||
import abc
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from homeassistant.components.water_heater import WaterHeaterEntity
|
||||
|
@ -10,9 +11,19 @@ from gekitchen import ErdCode, ErdMeasurementUnits
|
|||
from ge_kitchen.const import DOMAIN
|
||||
from .ge_erd_entity import GeEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class GeWaterHeater(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
|
||||
"""Mock temperature/operation mode supporting device as a water heater"""
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
available = super().available
|
||||
if not available:
|
||||
app = self.appliance
|
||||
_LOGGER.critical(f"{self.name} unavailable. Appliance info: Availaible - {app._available} and Init - {app.initialized}")
|
||||
return available
|
||||
|
||||
@property
|
||||
def heater_type(self) -> str:
|
||||
raise NotImplementedError
|
||||
|
@ -49,9 +60,3 @@ class GeWaterHeater(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
|
|||
def device_state_attributes(self) -> Dict[str, Any]:
|
||||
other_attrs = self.other_state_attrs
|
||||
return {**other_attrs}
|
||||
|
||||
async def async_set_sabbath_mode(self, sabbath_on: bool = True):
|
||||
"""Set sabbath mode if it's changed"""
|
||||
if self.appliance.get_erd_value(ErdCode.SABBATH_MODE) == sabbath_on:
|
||||
return
|
||||
await self.appliance.async_set_erd_value(ErdCode.SABBATH_MODE, sabbath_on)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
from .ge_fridge import GeFridge
|
||||
from .ge_freezer import GeFreezer
|
||||
from .ge_dispenser import GeDispenser
|
|
@ -0,0 +1,18 @@
|
|||
from homeassistant.components.water_heater import (
|
||||
SUPPORT_OPERATION_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE
|
||||
)
|
||||
|
||||
ATTR_DOOR_STATUS = "door_status"
|
||||
GE_FRIDGE_SUPPORT = (SUPPORT_OPERATION_MODE | SUPPORT_TARGET_TEMPERATURE)
|
||||
|
||||
HEATER_TYPE_FRIDGE = "fridge"
|
||||
HEATER_TYPE_FREEZER = "freezer"
|
||||
HEATER_TYPE_DISPENSER = "dispenser"
|
||||
|
||||
# Fridge/Freezer
|
||||
OP_MODE_K_CUP = "K-Cup Brewing"
|
||||
OP_MODE_NORMAL = "Normal"
|
||||
OP_MODE_SABBATH = "Sabbath Mode"
|
||||
OP_MODE_TURBO_COOL = "Turbo Cool"
|
||||
OP_MODE_TURBO_FREEZE = "Turbo Freeze"
|
|
@ -2,62 +2,28 @@
|
|||
import sys
|
||||
import os
|
||||
import abc
|
||||
import async_timeout
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TYPE_CHECKING
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
sys.path.append(os.getcwd() + '/..')
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
|
||||
from bidict import bidict
|
||||
from gekitchen import (
|
||||
ErdCode,
|
||||
ErdOnOff,
|
||||
ErdDoorStatus,
|
||||
ErdFilterStatus,
|
||||
ErdFullNotFull,
|
||||
ErdHotWaterStatus,
|
||||
ErdMeasurementUnits,
|
||||
ErdPodStatus
|
||||
)
|
||||
from gekitchen.erd_types import (
|
||||
FridgeDoorStatus,
|
||||
FridgeSetPointLimits,
|
||||
FridgeSetPoints,
|
||||
FridgeIceBucketStatus,
|
||||
HotWaterStatus,
|
||||
IceMakerControlStatus
|
||||
)
|
||||
|
||||
from homeassistant.components.water_heater import (
|
||||
SUPPORT_OPERATION_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
WaterHeaterEntity,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
|
||||
from ..entities import GeEntity, stringify_erd_value
|
||||
from ..const import DOMAIN
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..appliance_api import ApplianceApi
|
||||
from ..update_coordinator import GeKitchenUpdateCoordinator
|
||||
|
||||
ATTR_DOOR_STATUS = "door_status"
|
||||
GE_FRIDGE_SUPPORT = (SUPPORT_OPERATION_MODE | SUPPORT_TARGET_TEMPERATURE)
|
||||
HEATER_TYPE_FRIDGE = "fridge"
|
||||
HEATER_TYPE_FREEZER = "freezer"
|
||||
|
||||
# Fridge/Freezer
|
||||
OP_MODE_K_CUP = "K-Cup Brewing"
|
||||
OP_MODE_NORMAL = "Normal"
|
||||
OP_MODE_SABBATH = "Sabbath Mode"
|
||||
OP_MODE_TURBO_COOL = "Turbo Cool"
|
||||
OP_MODE_TURBO_FREEZE = "Turbo Freeze"
|
||||
from ge_kitchen.const import DOMAIN
|
||||
from ..common import GeWaterHeater
|
||||
from .const import *
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class GeAbstractFridgeEntity(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
|
||||
class GeAbstractFridge(GeWaterHeater):
|
||||
"""Mock a fridge or freezer as a water heater."""
|
||||
|
||||
@property
|
||||
|
@ -84,13 +50,6 @@ class GeAbstractFridgeEntity(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta)
|
|||
def name(self) -> Optional[str]:
|
||||
return f"{self.serial_number} {self.heater_type.title()}"
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
measurement_system = self.appliance.get_erd_value(ErdCode.TEMPERATURE_UNIT)
|
||||
if measurement_system == ErdMeasurementUnits.METRIC:
|
||||
return TEMP_CELSIUS
|
||||
return TEMP_FAHRENHEIT
|
||||
|
||||
@property
|
||||
def target_temps(self) -> FridgeSetPoints:
|
||||
"""Get the current temperature settings tuple."""
|
||||
|
@ -197,11 +156,6 @@ class GeAbstractFridgeEntity(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta)
|
|||
"""Get state attributes for the doors."""
|
||||
return {}
|
||||
|
||||
@property
|
||||
def other_state_attrs(self) -> Dict[str, Any]:
|
||||
"""State attributes to be optionally overridden in subclasses."""
|
||||
return {}
|
||||
|
||||
@property
|
||||
def device_state_attributes(self) -> Dict[str, Any]:
|
||||
door_attrs = self.door_state_attrs
|
|
@ -1,69 +1,38 @@
|
|||
"""GE Kitchen Sensor Entities - Fridge Water Heater"""
|
||||
import sys
|
||||
import os
|
||||
import abc
|
||||
import async_timeout
|
||||
from datetime import timedelta
|
||||
"""GE Kitchen Sensor Entities - Dispenser"""
|
||||
|
||||
import logging
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TYPE_CHECKING
|
||||
from typing import List, Optional
|
||||
|
||||
sys.path.append(os.getcwd() + '/..')
|
||||
|
||||
from bidict import bidict
|
||||
from gekitchen import (
|
||||
ErdCode,
|
||||
ErdPresent,
|
||||
ErdMeasurementUnits,
|
||||
ErdPodStatus
|
||||
)
|
||||
from gekitchen.erd_types import (
|
||||
ErdPodStatus,
|
||||
HotWaterStatus
|
||||
)
|
||||
|
||||
from homeassistant.components.water_heater import (
|
||||
WaterHeaterEntity,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from ..entities import GeEntity
|
||||
from .abstract_fridge_entity import (
|
||||
OP_MODE_K_CUP,
|
||||
from ..common import GeWaterHeater
|
||||
from .const import (
|
||||
HEATER_TYPE_DISPENSER, OP_MODE_K_CUP,
|
||||
OP_MODE_NORMAL,
|
||||
OP_MODE_SABBATH,
|
||||
GeAbstractFridgeEntity
|
||||
OP_MODE_SABBATH
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class GeFridgeWaterHeater(GeEntity, WaterHeaterEntity):
|
||||
"""Entity for in-fridge water heaters"""
|
||||
|
||||
class GeDispenser(GeWaterHeater):
|
||||
"""Entity for in-fridge dispensers"""
|
||||
|
||||
# These values are from FridgeHotWaterFragment.smali in the android app
|
||||
min_temp = 90
|
||||
max_temp = 185
|
||||
|
||||
heater_type = HEATER_TYPE_DISPENSER
|
||||
|
||||
@property
|
||||
def hot_water_status(self) -> HotWaterStatus:
|
||||
"""Access the main status value conveniently."""
|
||||
return self.appliance.get_erd_value(ErdCode.HOT_WATER_STATUS)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Make a unique id."""
|
||||
return f"{self.serial_number}-fridge-hot-water"
|
||||
|
||||
@property
|
||||
def name(self) -> Optional[str]:
|
||||
"""Name it reasonably."""
|
||||
return f"GE Fridge Water Heater {self.serial_number}"
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
"""Select the appropriate temperature unit."""
|
||||
measurement_system = self.appliance.get_erd_value(ErdCode.TEMPERATURE_UNIT)
|
||||
if measurement_system == ErdMeasurementUnits.METRIC:
|
||||
return TEMP_CELSIUS
|
||||
return TEMP_FAHRENHEIT
|
||||
|
||||
@property
|
||||
def supports_k_cups(self) -> bool:
|
||||
"""Return True if the device supports k-cup brewing."""
|
|
@ -1,24 +1,22 @@
|
|||
"""GE Kitchen Sensor Entities - Freezer"""
|
||||
import logging
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TYPE_CHECKING
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from gekitchen import (
|
||||
ErdCode,
|
||||
ErdDoorStatus
|
||||
)
|
||||
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from ..entities import GeEntity
|
||||
from .abstract_fridge_entity import (
|
||||
from .ge_abstract_fridge import (
|
||||
ATTR_DOOR_STATUS,
|
||||
HEATER_TYPE_FREEZER,
|
||||
OP_MODE_TURBO_FREEZE,
|
||||
GeAbstractFridgeEntity
|
||||
GeAbstractFridge
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class GeFreezerEntity(GeAbstractFridgeEntity):
|
||||
class GeFreezer(GeAbstractFridge):
|
||||
"""A freezer is basically a fridge."""
|
||||
|
||||
heater_type = HEATER_TYPE_FREEZER
|
||||
|
@ -32,4 +30,3 @@ class GeFreezerEntity(GeAbstractFridgeEntity):
|
|||
if door_status and door_status != ErdDoorStatus.NA:
|
||||
return {ATTR_DOOR_STATUS: door_status.name.title()}
|
||||
return {}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
"""GE Kitchen Sensor Entities - Fridge"""
|
||||
import logging
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TYPE_CHECKING
|
||||
from typing import Any, Dict
|
||||
|
||||
from gekitchen import (
|
||||
ErdCode,
|
||||
|
@ -8,31 +8,22 @@ from gekitchen import (
|
|||
ErdFilterStatus
|
||||
)
|
||||
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from ..entities import GeEntity
|
||||
from .abstract_fridge_entity import (
|
||||
from .const import *
|
||||
from .ge_abstract_fridge import (
|
||||
ATTR_DOOR_STATUS,
|
||||
HEATER_TYPE_FRIDGE,
|
||||
OP_MODE_TURBO_COOL,
|
||||
GeAbstractFridgeEntity
|
||||
GeAbstractFridge
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class GeFridgeEntity(GeAbstractFridgeEntity):
|
||||
class GeFridge(GeAbstractFridge):
|
||||
heater_type = HEATER_TYPE_FRIDGE
|
||||
turbo_erd_code = ErdCode.TURBO_COOL_STATUS
|
||||
turbo_mode = OP_MODE_TURBO_COOL
|
||||
icon = "mdi:fridge-bottom"
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
available = super().available
|
||||
if not available:
|
||||
app = self.appliance
|
||||
_LOGGER.critical(f"{self.name} unavailable. Appliance info: Availaible - {app._available} and Init - {app.initialized}")
|
||||
return available
|
||||
|
||||
@property
|
||||
def other_state_attrs(self) -> Dict[str, Any]:
|
||||
"""Water filter state."""
|
Loading…
Reference in New Issue