2020-12-29 10:02:56 -07:00
|
|
|
from homeassistant.components.binary_sensor import DEVICE_CLASS_PROBLEM
|
|
|
|
from homeassistant.const import DEVICE_CLASS_TEMPERATURE
|
2020-12-28 15:46:15 -07:00
|
|
|
import logging
|
|
|
|
from typing import List
|
|
|
|
|
|
|
|
from homeassistant.helpers.entity import Entity
|
2020-12-29 10:40:29 -07:00
|
|
|
from gekitchen import (
|
|
|
|
ErdCode,
|
|
|
|
ErdApplianceType,
|
|
|
|
ErdOnOff,
|
|
|
|
ErdHotWaterStatus,
|
|
|
|
FridgeIceBucketStatus,
|
|
|
|
IceMakerControlStatus,
|
|
|
|
ErdFilterStatus,
|
|
|
|
HotWaterStatus
|
|
|
|
)
|
2020-12-28 15:46:15 -07:00
|
|
|
|
|
|
|
from .base import ApplianceApi
|
2020-12-29 10:02:56 -07:00
|
|
|
from ..entities import (
|
|
|
|
GeErdSensor,
|
|
|
|
GeErdSwitch,
|
|
|
|
GeFridge,
|
|
|
|
GeFreezer,
|
|
|
|
GeDispenser,
|
|
|
|
GeErdPropertySensor,
|
|
|
|
GeErdPropertyBinarySensor
|
|
|
|
)
|
2020-12-28 15:46:15 -07:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
class FridgeApi(ApplianceApi):
|
|
|
|
"""API class for oven objects"""
|
|
|
|
APPLIANCE_TYPE = ErdApplianceType.FRIDGE
|
|
|
|
|
|
|
|
def get_all_entities(self) -> List[Entity]:
|
|
|
|
base_entities = super().get_all_entities()
|
2020-12-29 10:02:56 -07:00
|
|
|
|
|
|
|
fridge_entities = []
|
|
|
|
freezer_entities = []
|
|
|
|
dispenser_entities = []
|
2020-12-28 15:46:15 -07:00
|
|
|
|
2020-12-29 10:40:29 -07:00
|
|
|
# Get the statuses used to determine presence
|
|
|
|
ice_maker_control: IceMakerControlStatus = self.appliance.get_erd_value(ErdCode.ICE_MAKER_CONTROL)
|
|
|
|
ice_bucket_status: FridgeIceBucketStatus = self.appliance.get_erd_value(ErdCode.ICE_MAKER_BUCKET_STATUS)
|
|
|
|
water_filter: ErdFilterStatus = self.appliance.get_erd_value(ErdCode.WATER_FILTER_STATUS)
|
|
|
|
air_filter: ErdFilterStatus = self.appliance.get_erd_value(ErdCode.AIR_FILTER_STATUS)
|
|
|
|
hot_water_status: HotWaterStatus = self.appliance.get_erd_value(ErdCode.HOT_WATER_STATUS)
|
|
|
|
|
|
|
|
# Common entities
|
2020-12-29 10:02:56 -07:00
|
|
|
common_entities = [
|
2020-12-28 15:46:15 -07:00
|
|
|
GeErdSensor(self, ErdCode.FRIDGE_MODEL_INFO),
|
|
|
|
GeErdSwitch(self, ErdCode.SABBATH_MODE),
|
2020-12-29 10:02:56 -07:00
|
|
|
GeErdSensor(self, ErdCode.DOOR_STATUS),
|
|
|
|
GeErdPropertyBinarySensor(self, ErdCode.DOOR_STATUS, "any_open")
|
2020-12-28 15:46:15 -07:00
|
|
|
]
|
2020-12-29 10:40:29 -07:00
|
|
|
if(ice_bucket_status and (ice_bucket_status.is_present_fridge or ice_bucket_status.is_present_freezer)):
|
|
|
|
common_entities.append(GeErdSensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS))
|
2020-12-29 10:02:56 -07:00
|
|
|
|
2020-12-29 10:40:29 -07:00
|
|
|
# Fridge entities
|
2020-12-29 10:02:56 -07:00
|
|
|
fridge_entities.extend([
|
|
|
|
GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "fridge"),
|
|
|
|
GeFridge(self),
|
|
|
|
])
|
2020-12-29 10:40:29 -07:00
|
|
|
if(ice_maker_control and ice_maker_control.status_fridge != ErdOnOff.NA):
|
|
|
|
fridge_entities.append(GeErdPropertyBinarySensor(self, ErdCode.ICE_MAKER_CONTROL, "status_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):
|
|
|
|
fridge_entities.append(GeErdSensor(self, ErdCode.AIR_FILTER_STATUS))
|
|
|
|
if(ice_bucket_status and ice_bucket_status.is_present_fridge):
|
|
|
|
GeErdPropertySensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS, "state_full_fridge")
|
2020-12-29 10:02:56 -07:00
|
|
|
|
2020-12-29 10:40:29 -07:00
|
|
|
# Freezer entities
|
2020-12-29 10:02:56 -07:00
|
|
|
freezer_entities.extend([
|
|
|
|
GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "freezer"),
|
|
|
|
GeFreezer(self),
|
|
|
|
])
|
2020-12-29 10:40:29 -07:00
|
|
|
if(ice_maker_control and ice_maker_control.status_freezer != ErdOnOff.NA):
|
|
|
|
GeErdPropertyBinarySensor(self, ErdCode.ICE_MAKER_CONTROL, "status_freezer")
|
|
|
|
if(ice_bucket_status and ice_bucket_status.is_present_freezer):
|
|
|
|
GeErdPropertySensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS, "state_full_freezer")
|
2020-12-29 10:02:56 -07:00
|
|
|
|
2020-12-29 10:40:29 -07:00
|
|
|
if(hot_water_status and hot_water_status.status != ErdHotWaterStatus.NA):
|
|
|
|
# Dispenser entities
|
|
|
|
dispenser_entities.extend([
|
|
|
|
GeErdSensor(self, ErdCode.HOT_WATER_IN_USE),
|
|
|
|
GeErdSensor(self, ErdCode.HOT_WATER_SET_TEMP),
|
|
|
|
GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "status"),
|
|
|
|
GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "time_remaining", icon_override="mdi:timer-outline"),
|
|
|
|
GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "current_temp", device_class_override=DEVICE_CLASS_TEMPERATURE),
|
|
|
|
GeErdPropertyBinarySensor(self, ErdCode.HOT_WATER_STATUS, "faulted", device_class_override=DEVICE_CLASS_PROBLEM),
|
|
|
|
GeDispenser(self)
|
|
|
|
])
|
2020-12-29 10:02:56 -07:00
|
|
|
|
|
|
|
entities = base_entities + common_entities + fridge_entities + freezer_entities + dispenser_entities
|
2020-12-28 15:46:15 -07:00
|
|
|
return entities
|