2020-12-17 19:20:43 -07:00
|
|
|
"""GE Kitchen Sensor Entities - Fridge"""
|
|
|
|
import logging
|
2020-12-28 16:36:38 -07:00
|
|
|
from typing import Any, Dict
|
2020-12-17 19:20:43 -07:00
|
|
|
|
|
|
|
from gekitchen import (
|
|
|
|
ErdCode,
|
|
|
|
ErdDoorStatus,
|
|
|
|
ErdFilterStatus
|
|
|
|
)
|
|
|
|
|
2020-12-28 16:36:38 -07:00
|
|
|
from .const import *
|
|
|
|
from .ge_abstract_fridge import (
|
2020-12-17 19:20:43 -07:00
|
|
|
ATTR_DOOR_STATUS,
|
|
|
|
HEATER_TYPE_FRIDGE,
|
|
|
|
OP_MODE_TURBO_COOL,
|
2020-12-28 16:36:38 -07:00
|
|
|
GeAbstractFridge
|
2020-12-17 19:20:43 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2020-12-28 16:36:38 -07:00
|
|
|
class GeFridge(GeAbstractFridge):
|
2020-12-17 19:20:43 -07:00
|
|
|
heater_type = HEATER_TYPE_FRIDGE
|
|
|
|
turbo_erd_code = ErdCode.TURBO_COOL_STATUS
|
|
|
|
turbo_mode = OP_MODE_TURBO_COOL
|
|
|
|
icon = "mdi:fridge-bottom"
|
|
|
|
|
|
|
|
@property
|
|
|
|
def other_state_attrs(self) -> Dict[str, Any]:
|
|
|
|
"""Water filter state."""
|
|
|
|
filter_status: ErdFilterStatus = self.appliance.get_erd_value(ErdCode.WATER_FILTER_STATUS)
|
|
|
|
if filter_status == ErdFilterStatus.NA:
|
|
|
|
return {}
|
|
|
|
return {"water_filter_status": filter_status.name.replace("_", " ").title()}
|
|
|
|
|
|
|
|
@property
|
|
|
|
def door_state_attrs(self) -> Dict[str, Any]:
|
|
|
|
"""Get state attributes for the doors."""
|
|
|
|
data = {}
|
|
|
|
door_status = self.door_status
|
|
|
|
if not door_status:
|
|
|
|
return {}
|
|
|
|
door_right = door_status.fridge_right
|
|
|
|
door_left = door_status.fridge_left
|
|
|
|
drawer = door_status.drawer
|
|
|
|
|
|
|
|
if door_right and door_right != ErdDoorStatus.NA:
|
|
|
|
data["right_door"] = door_status.fridge_right.name.title()
|
|
|
|
if door_left and door_left != ErdDoorStatus.NA:
|
|
|
|
data["left_door"] = door_status.fridge_left.name.title()
|
|
|
|
if drawer and drawer != ErdDoorStatus.NA:
|
|
|
|
data["drawer"] = door_status.fridge_left.name.title()
|
|
|
|
|
|
|
|
if data:
|
|
|
|
all_closed = all(v == "Closed" for v in data.values())
|
|
|
|
data[ATTR_DOOR_STATUS] = "Closed" if all_closed else "Open"
|
|
|
|
|
|
|
|
return data
|