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 abc
|
||||||
|
import logging
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from homeassistant.components.water_heater import WaterHeaterEntity
|
from homeassistant.components.water_heater import WaterHeaterEntity
|
||||||
|
@ -10,9 +11,19 @@ from gekitchen import ErdCode, ErdMeasurementUnits
|
||||||
from ge_kitchen.const import DOMAIN
|
from ge_kitchen.const import DOMAIN
|
||||||
from .ge_erd_entity import GeEntity
|
from .ge_erd_entity import GeEntity
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class GeWaterHeater(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
|
class GeWaterHeater(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
|
||||||
"""Mock temperature/operation mode supporting device as a water heater"""
|
"""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
|
@property
|
||||||
def heater_type(self) -> str:
|
def heater_type(self) -> str:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -49,9 +60,3 @@ class GeWaterHeater(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
|
||||||
def device_state_attributes(self) -> Dict[str, Any]:
|
def device_state_attributes(self) -> Dict[str, Any]:
|
||||||
other_attrs = self.other_state_attrs
|
other_attrs = self.other_state_attrs
|
||||||
return {**other_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 sys
|
||||||
import os
|
import os
|
||||||
import abc
|
import abc
|
||||||
import async_timeout
|
|
||||||
from datetime import timedelta
|
|
||||||
import logging
|
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 (
|
from gekitchen import (
|
||||||
ErdCode,
|
ErdCode,
|
||||||
ErdOnOff,
|
ErdOnOff,
|
||||||
ErdDoorStatus,
|
|
||||||
ErdFilterStatus,
|
|
||||||
ErdFullNotFull,
|
ErdFullNotFull,
|
||||||
ErdHotWaterStatus,
|
|
||||||
ErdMeasurementUnits,
|
|
||||||
ErdPodStatus
|
|
||||||
)
|
|
||||||
from gekitchen.erd_types import (
|
|
||||||
FridgeDoorStatus,
|
FridgeDoorStatus,
|
||||||
FridgeSetPointLimits,
|
FridgeSetPointLimits,
|
||||||
FridgeSetPoints,
|
FridgeSetPoints,
|
||||||
FridgeIceBucketStatus,
|
FridgeIceBucketStatus,
|
||||||
HotWaterStatus,
|
|
||||||
IceMakerControlStatus
|
IceMakerControlStatus
|
||||||
)
|
)
|
||||||
|
from ge_kitchen.const import DOMAIN
|
||||||
from homeassistant.components.water_heater import (
|
from ..common import GeWaterHeater
|
||||||
SUPPORT_OPERATION_MODE,
|
from .const import *
|
||||||
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"
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class GeAbstractFridgeEntity(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
|
class GeAbstractFridge(GeWaterHeater):
|
||||||
"""Mock a fridge or freezer as a water heater."""
|
"""Mock a fridge or freezer as a water heater."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -84,13 +50,6 @@ class GeAbstractFridgeEntity(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta)
|
||||||
def name(self) -> Optional[str]:
|
def name(self) -> Optional[str]:
|
||||||
return f"{self.serial_number} {self.heater_type.title()}"
|
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
|
@property
|
||||||
def target_temps(self) -> FridgeSetPoints:
|
def target_temps(self) -> FridgeSetPoints:
|
||||||
"""Get the current temperature settings tuple."""
|
"""Get the current temperature settings tuple."""
|
||||||
|
@ -197,11 +156,6 @@ class GeAbstractFridgeEntity(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta)
|
||||||
"""Get state attributes for the doors."""
|
"""Get state attributes for the doors."""
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@property
|
|
||||||
def other_state_attrs(self) -> Dict[str, Any]:
|
|
||||||
"""State attributes to be optionally overridden in subclasses."""
|
|
||||||
return {}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self) -> Dict[str, Any]:
|
def device_state_attributes(self) -> Dict[str, Any]:
|
||||||
door_attrs = self.door_state_attrs
|
door_attrs = self.door_state_attrs
|
|
@ -1,69 +1,38 @@
|
||||||
"""GE Kitchen Sensor Entities - Fridge Water Heater"""
|
"""GE Kitchen Sensor Entities - Dispenser"""
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import abc
|
|
||||||
import async_timeout
|
|
||||||
from datetime import timedelta
|
|
||||||
import logging
|
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 (
|
from gekitchen import (
|
||||||
ErdCode,
|
ErdCode,
|
||||||
ErdPresent,
|
ErdPresent,
|
||||||
ErdMeasurementUnits,
|
ErdPodStatus,
|
||||||
ErdPodStatus
|
|
||||||
)
|
|
||||||
from gekitchen.erd_types import (
|
|
||||||
HotWaterStatus
|
HotWaterStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components.water_heater import (
|
from ..common import GeWaterHeater
|
||||||
WaterHeaterEntity,
|
from .const import (
|
||||||
)
|
HEATER_TYPE_DISPENSER, OP_MODE_K_CUP,
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
|
||||||
from ..entities import GeEntity
|
|
||||||
from .abstract_fridge_entity import (
|
|
||||||
OP_MODE_K_CUP,
|
|
||||||
OP_MODE_NORMAL,
|
OP_MODE_NORMAL,
|
||||||
OP_MODE_SABBATH,
|
OP_MODE_SABBATH
|
||||||
GeAbstractFridgeEntity
|
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class GeFridgeWaterHeater(GeEntity, WaterHeaterEntity):
|
class GeDispenser(GeWaterHeater):
|
||||||
"""Entity for in-fridge water heaters"""
|
"""Entity for in-fridge dispensers"""
|
||||||
|
|
||||||
# These values are from FridgeHotWaterFragment.smali in the android app
|
# These values are from FridgeHotWaterFragment.smali in the android app
|
||||||
min_temp = 90
|
min_temp = 90
|
||||||
max_temp = 185
|
max_temp = 185
|
||||||
|
|
||||||
|
heater_type = HEATER_TYPE_DISPENSER
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hot_water_status(self) -> HotWaterStatus:
|
def hot_water_status(self) -> HotWaterStatus:
|
||||||
"""Access the main status value conveniently."""
|
"""Access the main status value conveniently."""
|
||||||
return self.appliance.get_erd_value(ErdCode.HOT_WATER_STATUS)
|
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
|
@property
|
||||||
def supports_k_cups(self) -> bool:
|
def supports_k_cups(self) -> bool:
|
||||||
"""Return True if the device supports k-cup brewing."""
|
"""Return True if the device supports k-cup brewing."""
|
|
@ -1,24 +1,22 @@
|
||||||
"""GE Kitchen Sensor Entities - Freezer"""
|
"""GE Kitchen Sensor Entities - Freezer"""
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TYPE_CHECKING
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
from gekitchen import (
|
from gekitchen import (
|
||||||
ErdCode,
|
ErdCode,
|
||||||
ErdDoorStatus
|
ErdDoorStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from .ge_abstract_fridge import (
|
||||||
from ..entities import GeEntity
|
|
||||||
from .abstract_fridge_entity import (
|
|
||||||
ATTR_DOOR_STATUS,
|
ATTR_DOOR_STATUS,
|
||||||
HEATER_TYPE_FREEZER,
|
HEATER_TYPE_FREEZER,
|
||||||
OP_MODE_TURBO_FREEZE,
|
OP_MODE_TURBO_FREEZE,
|
||||||
GeAbstractFridgeEntity
|
GeAbstractFridge
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class GeFreezerEntity(GeAbstractFridgeEntity):
|
class GeFreezer(GeAbstractFridge):
|
||||||
"""A freezer is basically a fridge."""
|
"""A freezer is basically a fridge."""
|
||||||
|
|
||||||
heater_type = HEATER_TYPE_FREEZER
|
heater_type = HEATER_TYPE_FREEZER
|
||||||
|
@ -32,4 +30,3 @@ class GeFreezerEntity(GeAbstractFridgeEntity):
|
||||||
if door_status and door_status != ErdDoorStatus.NA:
|
if door_status and door_status != ErdDoorStatus.NA:
|
||||||
return {ATTR_DOOR_STATUS: door_status.name.title()}
|
return {ATTR_DOOR_STATUS: door_status.name.title()}
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""GE Kitchen Sensor Entities - Fridge"""
|
"""GE Kitchen Sensor Entities - Fridge"""
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, TYPE_CHECKING
|
from typing import Any, Dict
|
||||||
|
|
||||||
from gekitchen import (
|
from gekitchen import (
|
||||||
ErdCode,
|
ErdCode,
|
||||||
|
@ -8,31 +8,22 @@ from gekitchen import (
|
||||||
ErdFilterStatus
|
ErdFilterStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from .const import *
|
||||||
from ..entities import GeEntity
|
from .ge_abstract_fridge import (
|
||||||
from .abstract_fridge_entity import (
|
|
||||||
ATTR_DOOR_STATUS,
|
ATTR_DOOR_STATUS,
|
||||||
HEATER_TYPE_FRIDGE,
|
HEATER_TYPE_FRIDGE,
|
||||||
OP_MODE_TURBO_COOL,
|
OP_MODE_TURBO_COOL,
|
||||||
GeAbstractFridgeEntity
|
GeAbstractFridge
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class GeFridgeEntity(GeAbstractFridgeEntity):
|
class GeFridge(GeAbstractFridge):
|
||||||
heater_type = HEATER_TYPE_FRIDGE
|
heater_type = HEATER_TYPE_FRIDGE
|
||||||
turbo_erd_code = ErdCode.TURBO_COOL_STATUS
|
turbo_erd_code = ErdCode.TURBO_COOL_STATUS
|
||||||
turbo_mode = OP_MODE_TURBO_COOL
|
turbo_mode = OP_MODE_TURBO_COOL
|
||||||
icon = "mdi:fridge-bottom"
|
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
|
@property
|
||||||
def other_state_attrs(self) -> Dict[str, Any]:
|
def other_state_attrs(self) -> Dict[str, Any]:
|
||||||
"""Water filter state."""
|
"""Water filter state."""
|
Loading…
Reference in New Issue