diff --git a/README.md b/README.md index 42ad817..319ddd0 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Integration for GE WiFi-enabled appliances into Home Assistant. This integratio - Laundry (Washer/Dryer) - Whole Home Water Filter - Whole Home Water Softener -- A/C (Portable, Split, Window) +- A/C (Portable, Split, Window, Built-In) - Range Hood - Advantium - Microwave @@ -69,4 +69,4 @@ Please click [here](CHANGELOG.md) for change information. [license-shield]: https://img.shields.io/github/license/simbaja/ha_gehome.svg?style=for-the-badge [maintenance-shield]: https://img.shields.io/badge/maintainer-Jack%20Simbach%20%40simbaja-blue.svg?style=for-the-badge [releases-shield]: https://img.shields.io/github/release/simbaja/ha_gehome.svg?style=for-the-badge -[releases]: https://github.com/simbaja/ha_gehome/releases \ No newline at end of file +[releases]: https://github.com/simbaja/ha_gehome/releases diff --git a/custom_components/ge_home/climate.py b/custom_components/ge_home/climate.py index 3694a09..fbdb94d 100644 --- a/custom_components/ge_home/climate.py +++ b/custom_components/ge_home/climate.py @@ -14,7 +14,7 @@ from .update_coordinator import GeHomeUpdateCoordinator _LOGGER = logging.getLogger(__name__) async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable): - """GE Home Water Heaters.""" + """GE Climate Devices.""" _LOGGER.debug('Adding GE Climate Entities') coordinator: GeHomeUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] diff --git a/custom_components/ge_home/devices/biac.py b/custom_components/ge_home/devices/biac.py index 8ddcfd2..916b6cb 100644 --- a/custom_components/ge_home/devices/biac.py +++ b/custom_components/ge_home/devices/biac.py @@ -7,11 +7,12 @@ from gehomesdk.erd import ErdCode, ErdApplianceType from .base import ApplianceApi from ..entities import GeSacClimate, GeErdSensor, GeErdSwitch, ErdOnOffBoolConverter, GeErdBinarySensor + _LOGGER = logging.getLogger(__name__) class BiacApi(ApplianceApi): - """API class for Built-in AC objects""" + """API class for Built-In AC objects""" APPLIANCE_TYPE = ErdApplianceType.BUILT_IN_AIR_CONDITIONER def get_all_entities(self) -> List[Entity]: @@ -31,4 +32,4 @@ class BiacApi(ApplianceApi): entities = base_entities + sac_entities return entities - + diff --git a/custom_components/ge_home/entities/ac/__init__.py b/custom_components/ge_home/entities/ac/__init__.py index 0f2e6ad..aefb995 100644 --- a/custom_components/ge_home/entities/ac/__init__.py +++ b/custom_components/ge_home/entities/ac/__init__.py @@ -1,3 +1,4 @@ from .ge_wac_climate import GeWacClimate from .ge_sac_climate import GeSacClimate -from .ge_pac_climate import GePacClimate \ No newline at end of file +from .ge_pac_climate import GePacClimate +from .ge_biac_climate import GeBiacClimate diff --git a/custom_components/ge_home/entities/ac/ge_biac_climate.py b/custom_components/ge_home/entities/ac/ge_biac_climate.py new file mode 100644 index 0000000..f3b7453 --- /dev/null +++ b/custom_components/ge_home/entities/ac/ge_biac_climate.py @@ -0,0 +1,45 @@ +import logging +from typing import Any, List, Optional + +from homeassistant.components.climate.const import ( + HVAC_MODE_AUTO, + HVAC_MODE_COOL, + HVAC_MODE_FAN_ONLY, +) +from gehomesdk import ErdAcOperationMode +from ...devices import ApplianceApi +from ..common import GeClimate, OptionsConverter +from .fan_mode_options import AcFanModeOptionsConverter, AcFanOnlyFanModeOptionsConverter + +_LOGGER = logging.getLogger(__name__) + +class BiacHvacModeOptionsConverter(OptionsConverter): + @property + def options(self) -> List[str]: + return [HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_FAN_ONLY] + def from_option_string(self, value: str) -> Any: + try: + return { + HVAC_MODE_AUTO: ErdAcOperationMode.ENERGY_SAVER, + HVAC_MODE_COOL: ErdAcOperationMode.COOL, + HVAC_MODE_FAN_ONLY: ErdAcOperationMode.FAN_ONLY + }.get(value) + except: + _LOGGER.warn(f"Could not set HVAC mode to {value.upper()}") + return ErdAcOperationMode.COOL + def to_option_string(self, value: Any) -> Optional[str]: + try: + return { + ErdAcOperationMode.ENERGY_SAVER: HVAC_MODE_AUTO, + ErdAcOperationMode.AUTO: HVAC_MODE_AUTO, + ErdAcOperationMode.COOL: HVAC_MODE_COOL, + ErdAcOperationMode.FAN_ONLY: HVAC_MODE_FAN_ONLY + }.get(value) + except: + _LOGGER.warn(f"Could not determine operation mode mapping for {value}") + return HVAC_MODE_COOL + +class GeBiacClimate(GeClimate): + """Class for Built-In AC units""" + def __init__(self, api: ApplianceApi): + super().__init__(api, BiacHvacModeOptionsConverter(), AcFanModeOptionsConverter(), AcFanOnlyFanModeOptionsConverter()) diff --git a/custom_components/ge_home/entities/common/ge_climate.py b/custom_components/ge_home/entities/common/ge_climate.py index fc48f93..7f44edb 100644 --- a/custom_components/ge_home/entities/common/ge_climate.py +++ b/custom_components/ge_home/entities/common/ge_climate.py @@ -191,4 +191,4 @@ class GeClimate(GeEntity, ClimateEntity): return (temperature_f - 32.0) * (5/9) def _get_icon(self) -> Optional[str]: - return "mdi:air-conditioner" \ No newline at end of file + return "mdi:air-conditioner"