2020-12-28 15:46:15 -07:00
|
|
|
import abc
|
2020-12-28 16:36:38 -07:00
|
|
|
import logging
|
2020-12-28 15:46:15 -07:00
|
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
|
|
|
|
from homeassistant.components.water_heater import WaterHeaterEntity
|
|
|
|
from homeassistant.const import (
|
|
|
|
TEMP_FAHRENHEIT,
|
|
|
|
TEMP_CELSIUS
|
|
|
|
)
|
2020-12-29 15:01:29 -07:00
|
|
|
from gekitchensdk import ErdCode, ErdMeasurementUnits
|
2020-12-28 15:46:15 -07:00
|
|
|
from ge_kitchen.const import DOMAIN
|
|
|
|
from .ge_erd_entity import GeEntity
|
|
|
|
|
2020-12-28 16:36:38 -07:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2020-12-28 15:46:15 -07:00
|
|
|
class GeWaterHeater(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
|
|
|
|
"""Mock temperature/operation mode supporting device as a water heater"""
|
|
|
|
|
2020-12-28 16:36:38 -07:00
|
|
|
@property
|
|
|
|
def available(self) -> bool:
|
|
|
|
available = super().available
|
|
|
|
if not available:
|
|
|
|
app = self.appliance
|
2020-12-28 20:13:46 -07:00
|
|
|
_LOGGER.critical(f"{self.name} unavailable. Appliance info: Available - {app._available} and Init - {app.initialized}")
|
2020-12-28 16:36:38 -07:00
|
|
|
return available
|
|
|
|
|
2020-12-28 15:46:15 -07:00
|
|
|
@property
|
|
|
|
def heater_type(self) -> str:
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
@property
|
|
|
|
def operation_list(self) -> List[str]:
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
@property
|
|
|
|
def unique_id(self) -> str:
|
|
|
|
return f"{DOMAIN}_{self.serial_number}_{self.heater_type}"
|
|
|
|
|
|
|
|
@property
|
|
|
|
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 supported_features(self):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
@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]:
|
|
|
|
other_attrs = self.other_state_attrs
|
|
|
|
return {**other_attrs}
|