2021-05-16 10:07:48 -06:00
|
|
|
import logging
|
|
|
|
from typing import List
|
|
|
|
|
|
|
|
from homeassistant.helpers.entity import Entity
|
2021-07-08 12:08:40 -06:00
|
|
|
from gehomesdk import ErdCode, ErdApplianceType
|
2021-05-16 10:07:48 -06:00
|
|
|
|
|
|
|
from .base import ApplianceApi
|
2021-06-09 11:49:27 -06:00
|
|
|
from ..entities import GeErdSensor, GeErdBinarySensor
|
2021-05-16 10:07:48 -06:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
class DryerApi(ApplianceApi):
|
|
|
|
"""API class for dryer objects"""
|
2021-05-18 12:13:29 -06:00
|
|
|
APPLIANCE_TYPE = ErdApplianceType.DRYER
|
2021-05-16 10:07:48 -06:00
|
|
|
|
|
|
|
def get_all_entities(self) -> List[Entity]:
|
|
|
|
base_entities = super().get_all_entities()
|
|
|
|
|
2021-07-08 12:08:40 -06:00
|
|
|
common_entities = [
|
2021-05-18 12:13:29 -06:00
|
|
|
GeErdSensor(self, ErdCode.LAUNDRY_MACHINE_STATE),
|
2021-07-08 12:08:40 -06:00
|
|
|
GeErdSensor(self, ErdCode.LAUNDRY_CYCLE),
|
|
|
|
GeErdSensor(self, ErdCode.LAUNDRY_SUB_CYCLE),
|
2021-05-18 12:13:29 -06:00
|
|
|
GeErdBinarySensor(self, ErdCode.LAUNDRY_END_OF_CYCLE),
|
|
|
|
GeErdSensor(self, ErdCode.LAUNDRY_TIME_REMAINING),
|
|
|
|
GeErdSensor(self, ErdCode.LAUNDRY_DELAY_TIME_REMAINING),
|
2021-07-08 12:08:40 -06:00
|
|
|
GeErdBinarySensor(self, ErdCode.LAUNDRY_DOOR),
|
|
|
|
GeErdBinarySensor(self, ErdCode.LAUNDRY_REMOTE_STATUS),
|
2021-05-16 10:07:48 -06:00
|
|
|
]
|
2021-07-08 12:08:40 -06:00
|
|
|
|
|
|
|
dryer_entities = self.get_dryer_entities()
|
|
|
|
|
|
|
|
entities = base_entities + common_entities + dryer_entities
|
2021-05-16 10:07:48 -06:00
|
|
|
return entities
|
2021-07-08 12:08:40 -06:00
|
|
|
|
|
|
|
def get_dryer_entities(self):
|
|
|
|
#Not all options appear to exist on every dryer... we'll look for the presence of
|
|
|
|
#a code to figure out which sensors are applicable beyond the common ones.
|
|
|
|
dryer_entities = [
|
|
|
|
]
|
|
|
|
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_DRYNESS_LEVEL):
|
|
|
|
dryer_entities.extend([GeErdSensor(self, ErdCode.LAUNDRY_DRYER_DRYNESS_LEVEL)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_DRYNESSNEW_LEVEL):
|
|
|
|
dryer_entities.extend([GeErdSensor(self, ErdCode.LAUNDRY_DRYER_DRYNESSNEW_LEVEL)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_TEMPERATURE_OPTION):
|
|
|
|
dryer_entities.extend([GeErdSensor(self, ErdCode.LAUNDRY_DRYER_TEMPERATURE_OPTION)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_TEMPERATURENEW_OPTION):
|
|
|
|
dryer_entities.extend([GeErdSensor(self, ErdCode.LAUNDRY_DRYER_TEMPERATURENEW_OPTION)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_TUMBLE_STATUS):
|
|
|
|
dryer_entities.extend([GeErdSensor(self, ErdCode.LAUNDRY_DRYER_TUMBLE_STATUS)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_TUMBLENEW_STATUS):
|
|
|
|
dryer_entities.extend([GeErdSensor(self, ErdCode.LAUNDRY_DRYER_TUMBLENEW_STATUS)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_WASHERLINK_STATUS):
|
|
|
|
dryer_entities.extend([GeErdBinarySensor(self, ErdCode.LAUNDRY_DRYER_WASHERLINK_STATUS)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_LEVEL_SENSOR_DISABLED):
|
|
|
|
dryer_entities.extend([GeErdBinarySensor(self, ErdCode.LAUNDRY_DRYER_LEVEL_SENSOR_DISABLED)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_SHEET_USAGE_CONFIGURATION):
|
|
|
|
dryer_entities.extend([GeErdBinarySensor(self, ErdCode.LAUNDRY_DRYER_SHEET_USAGE_CONFIGURATION)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_SHEET_INVENTORY):
|
|
|
|
dryer_entities.extend([GeErdBinarySensor(self, ErdCode.LAUNDRY_DRYER_SHEET_INVENTORY)])
|
|
|
|
if self.has_erd_code(ErdCode.LAUNDRY_DRYER_ECODRY_STATUS):
|
|
|
|
dryer_entities.extend([GeErdBinarySensor(self, ErdCode.LAUNDRY_DRYER_ECODRY_STATUS)])
|
|
|
|
|
|
|
|
return dryer_entities
|
2021-05-18 12:13:29 -06:00
|
|
|
|