From 2cc5f3a361ac397e16e72def24052025a160b47a Mon Sep 17 00:00:00 2001 From: Jack Simbach Date: Sun, 8 Aug 2021 11:39:32 -0400 Subject: [PATCH] - added support for split AC devices --- custom_components/ge_home/devices/__init__.py | 3 ++ custom_components/ge_home/devices/sac.py | 37 +++++++++++++++++++ custom_components/ge_home/devices/wac.py | 2 +- .../ge_home/entities/ac/__init__.py | 3 +- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 custom_components/ge_home/devices/sac.py diff --git a/custom_components/ge_home/devices/__init__.py b/custom_components/ge_home/devices/__init__.py index 0cceff7..8a1236e 100644 --- a/custom_components/ge_home/devices/__init__.py +++ b/custom_components/ge_home/devices/__init__.py @@ -13,6 +13,7 @@ from .washer_dryer import WasherDryerApi from .water_filter import WaterFilterApi from .advantium import AdvantiumApi from .wac import WacApi +from .sac import SacApi _LOGGER = logging.getLogger(__name__) @@ -38,6 +39,8 @@ def get_appliance_api_type(appliance_type: ErdApplianceType) -> Type: return AdvantiumApi if appliance_type == ErdApplianceType.AIR_CONDITIONER: return WacApi + if appliance_type == ErdApplianceType.SPLIT_AIR_CONDITIONER: + return SacApi # Fallback return ApplianceApi diff --git a/custom_components/ge_home/devices/sac.py b/custom_components/ge_home/devices/sac.py new file mode 100644 index 0000000..2edfac6 --- /dev/null +++ b/custom_components/ge_home/devices/sac.py @@ -0,0 +1,37 @@ +import logging +from typing import List + +from homeassistant.helpers.entity import Entity +from gehomesdk.erd import ErdCode, ErdApplianceType + +from .base import ApplianceApi +from ..entities import GeSacClimate, GeErdSensor, GeErdBinarySensor, GeErdSwitch, ErdOnOffBoolConverter + +_LOGGER = logging.getLogger(__name__) + + +class SacApi(ApplianceApi): + """API class for Split AC objects""" + APPLIANCE_TYPE = ErdApplianceType.SPLIT_AIR_CONDITIONER + + def get_all_entities(self) -> List[Entity]: + base_entities = super().get_all_entities() + + sac_entities = [ + GeSacClimate(self), + GeErdSensor(self, ErdCode.AC_TARGET_TEMPERATURE), + GeErdSensor(self, ErdCode.AC_AMBIENT_TEMPERATURE), + GeErdSensor(self, ErdCode.AC_FAN_SETTING, icon_override="mdi:fan"), + GeErdSensor(self, ErdCode.AC_OPERATION_MODE), + GeErdSwitch(self, ErdCode.AC_POWER_STATUS, bool_converter=ErdOnOffBoolConverter(), icon_on_override="mdi:power-on", icon_off_override="mdi:power-off"), + ] + + if self.has_erd_code(ErdCode.SAC_SLEEP_MODE): + GeErdSwitch(self, ErdCode.SAC_SLEEP_MODE, bool_converter=ErdOnOffBoolConverter(), icon_on_override="mdi:sleep", icon_off_override="mdi:sleep-off"), + if self.has_erd_code(ErdCode.SAC_AUTO_SWING_MODE): + GeErdSwitch(self, ErdCode.SAC_AUTO_SWING_MODE, bool_converter=ErdOnOffBoolConverter(), icon_on_override="mdi:arrow-decision-auto", icon_off_override="mdi:arrow-decision-auto-outline"), + + + entities = base_entities + sac_entities + return entities + diff --git a/custom_components/ge_home/devices/wac.py b/custom_components/ge_home/devices/wac.py index c03d51d..c3c049e 100644 --- a/custom_components/ge_home/devices/wac.py +++ b/custom_components/ge_home/devices/wac.py @@ -11,7 +11,7 @@ _LOGGER = logging.getLogger(__name__) class WacApi(ApplianceApi): - """API class for window AC objects""" + """API class for Window AC objects""" APPLIANCE_TYPE = ErdApplianceType.AIR_CONDITIONER def get_all_entities(self) -> List[Entity]: diff --git a/custom_components/ge_home/entities/ac/__init__.py b/custom_components/ge_home/entities/ac/__init__.py index 09ea404..79bc17f 100644 --- a/custom_components/ge_home/entities/ac/__init__.py +++ b/custom_components/ge_home/entities/ac/__init__.py @@ -1 +1,2 @@ -from .ge_wac_climate import GeWacClimate \ No newline at end of file +from .ge_wac_climate import GeWacClimate +from .ge_sac_climate import GeSacClimate \ No newline at end of file