2021-12-12 11:25:43 -07:00
|
|
|
import logging
|
|
|
|
from typing import List
|
|
|
|
|
|
|
|
from homeassistant.helpers.entity import Entity
|
|
|
|
from gehomesdk import (
|
2022-01-29 22:06:43 -07:00
|
|
|
GeAppliance,
|
2021-12-12 11:25:43 -07:00
|
|
|
ErdCode,
|
2022-01-29 22:06:43 -07:00
|
|
|
ErdApplianceType,
|
|
|
|
ErdCcmBrewSettings
|
2021-12-12 11:25:43 -07:00
|
|
|
)
|
2022-01-29 22:06:43 -07:00
|
|
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
2021-12-12 11:25:43 -07:00
|
|
|
|
|
|
|
from .base import ApplianceApi
|
|
|
|
from ..entities import (
|
|
|
|
GeCcmPotNotPresentBinarySensor,
|
|
|
|
GeErdSensor,
|
2021-12-12 16:38:17 -07:00
|
|
|
GeErdBinarySensor,
|
2022-01-29 22:06:43 -07:00
|
|
|
GeErdButton,
|
|
|
|
GeCcmBrewStrengthSelect,
|
|
|
|
GeCcmBrewTemperatureNumber,
|
|
|
|
GeCcmBrewCupsNumber,
|
|
|
|
GeCcmBrewSettingsButton
|
2021-12-12 11:25:43 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class CcmApi(ApplianceApi):
|
|
|
|
"""API class for Cafe Coffee Maker objects"""
|
|
|
|
APPLIANCE_TYPE = ErdApplianceType.CAFE_COFFEE_MAKER
|
|
|
|
|
2022-01-29 22:06:43 -07:00
|
|
|
def __init__(self, coordinator: DataUpdateCoordinator, appliance: GeAppliance):
|
|
|
|
super().__init__(coordinator, appliance)
|
|
|
|
|
|
|
|
self._brew_strengh_entity = GeCcmBrewStrengthSelect(self)
|
|
|
|
self._brew_temperature_entity = GeCcmBrewTemperatureNumber(self)
|
|
|
|
self._brew_cups_entity = GeCcmBrewCupsNumber(self)
|
|
|
|
|
2021-12-12 11:25:43 -07:00
|
|
|
def get_all_entities(self) -> List[Entity]:
|
|
|
|
base_entities = super().get_all_entities()
|
|
|
|
|
|
|
|
ccm_entities = [
|
2022-01-29 22:06:43 -07:00
|
|
|
GeErdBinarySensor(self, ErdCode.CCM_IS_BREWING),
|
|
|
|
GeErdBinarySensor(self, ErdCode.CCM_IS_DESCALING),
|
|
|
|
GeCcmBrewSettingsButton(self),
|
|
|
|
GeErdButton(self, ErdCode.CCM_CANCEL_DESCALING),
|
|
|
|
GeErdButton(self, ErdCode.CCM_START_DESCALING),
|
|
|
|
GeErdButton(self, ErdCode.CCM_CANCEL_BREWING),
|
|
|
|
self._brew_strengh_entity,
|
|
|
|
self._brew_temperature_entity,
|
|
|
|
self._brew_cups_entity,
|
2021-12-12 11:25:43 -07:00
|
|
|
GeErdSensor(self, ErdCode.CCM_CURRENT_WATER_TEMPERATURE),
|
2022-01-29 22:06:43 -07:00
|
|
|
GeErdBinarySensor(self, ErdCode.CCM_OUT_OF_WATER, device_class_override="problem"),
|
|
|
|
GeCcmPotNotPresentBinarySensor(self, ErdCode.CCM_POT_PRESENT, device_class_override="problem")
|
2021-12-12 11:25:43 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
entities = base_entities + ccm_entities
|
|
|
|
return entities
|
2022-01-29 22:06:43 -07:00
|
|
|
|
|
|
|
async def start_brewing(self) -> None:
|
|
|
|
"""Aggregate brew settings and start brewing."""
|
|
|
|
|
2022-10-16 08:44:14 -06:00
|
|
|
new_mode = ErdCcmBrewSettings(self._brew_cups_entity.native_value,
|
2022-01-29 22:06:43 -07:00
|
|
|
self._brew_strengh_entity.brew_strength,
|
2022-10-16 08:44:14 -06:00
|
|
|
self._brew_temperature_entity.native_value)
|
2022-01-29 22:06:43 -07:00
|
|
|
await self.appliance.async_set_erd_value(ErdCode.CCM_BREW_SETTINGS, new_mode)
|