mirror of https://github.com/simbaja/ha_gehome.git
- added oven warming drawers
- simplified oven entity logic
This commit is contained in:
parent
3d18d57a9a
commit
b772321284
|
@ -11,7 +11,8 @@ from gehomesdk import (
|
||||||
ErdCooktopConfig,
|
ErdCooktopConfig,
|
||||||
CooktopStatus,
|
CooktopStatus,
|
||||||
ErdOvenLightLevel,
|
ErdOvenLightLevel,
|
||||||
ErdOvenLightLevelAvailability
|
ErdOvenLightLevelAvailability,
|
||||||
|
ErdOvenWarmingState
|
||||||
)
|
)
|
||||||
|
|
||||||
from .base import ApplianceApi
|
from .base import ApplianceApi
|
||||||
|
@ -23,6 +24,7 @@ from ..entities import (
|
||||||
GeErdPropertyBinarySensor,
|
GeErdPropertyBinarySensor,
|
||||||
GeOven,
|
GeOven,
|
||||||
GeOvenLightLevelSelect,
|
GeOvenLightLevelSelect,
|
||||||
|
GeOvenWarmingStateSelect,
|
||||||
UPPER_OVEN,
|
UPPER_OVEN,
|
||||||
LOWER_OVEN
|
LOWER_OVEN
|
||||||
)
|
)
|
||||||
|
@ -49,6 +51,10 @@ class OvenApi(ApplianceApi):
|
||||||
lower_light : ErdOvenLightLevel = self.try_get_erd_value(ErdCode.LOWER_OVEN_LIGHT)
|
lower_light : ErdOvenLightLevel = self.try_get_erd_value(ErdCode.LOWER_OVEN_LIGHT)
|
||||||
lower_light_availability: ErdOvenLightLevelAvailability = self.try_get_erd_value(ErdCode.LOWER_OVEN_LIGHT_AVAILABILITY)
|
lower_light_availability: ErdOvenLightLevelAvailability = self.try_get_erd_value(ErdCode.LOWER_OVEN_LIGHT_AVAILABILITY)
|
||||||
|
|
||||||
|
upper_warm_drawer : ErdOvenWarmingState = self.try_get_erd_value(ErdCode.UPPER_OVEN_WARMING_DRAWER_STATE)
|
||||||
|
lower_warm_drawer : ErdOvenWarmingState = self.try_get_erd_value(ErdCode.LOWER_OVEN_WARMING_DRAWER_STATE)
|
||||||
|
warm_drawer : ErdOvenWarmingState = self.try_get_erd_value(ErdCode.WARMING_DRAWER_STATE)
|
||||||
|
|
||||||
_LOGGER.debug(f"Oven Config: {oven_config}")
|
_LOGGER.debug(f"Oven Config: {oven_config}")
|
||||||
_LOGGER.debug(f"Cooktop Config: {cooktop_config}")
|
_LOGGER.debug(f"Cooktop Config: {cooktop_config}")
|
||||||
oven_entities = []
|
oven_entities = []
|
||||||
|
@ -56,13 +62,6 @@ class OvenApi(ApplianceApi):
|
||||||
|
|
||||||
if oven_config.has_lower_oven:
|
if oven_config.has_lower_oven:
|
||||||
oven_entities.extend([
|
oven_entities.extend([
|
||||||
GeErdSensor(self, ErdCode.UPPER_OVEN_COOK_MODE),
|
|
||||||
GeErdSensor(self, ErdCode.UPPER_OVEN_COOK_TIME_REMAINING),
|
|
||||||
GeErdTimerSensor(self, ErdCode.UPPER_OVEN_KITCHEN_TIMER),
|
|
||||||
GeErdSensor(self, ErdCode.UPPER_OVEN_USER_TEMP_OFFSET),
|
|
||||||
GeErdSensor(self, ErdCode.UPPER_OVEN_DISPLAY_TEMPERATURE),
|
|
||||||
GeErdBinarySensor(self, ErdCode.UPPER_OVEN_REMOTE_ENABLED),
|
|
||||||
|
|
||||||
GeErdSensor(self, ErdCode.LOWER_OVEN_COOK_MODE),
|
GeErdSensor(self, ErdCode.LOWER_OVEN_COOK_MODE),
|
||||||
GeErdSensor(self, ErdCode.LOWER_OVEN_COOK_TIME_REMAINING),
|
GeErdSensor(self, ErdCode.LOWER_OVEN_COOK_TIME_REMAINING),
|
||||||
GeErdTimerSensor(self, ErdCode.LOWER_OVEN_KITCHEN_TIMER),
|
GeErdTimerSensor(self, ErdCode.LOWER_OVEN_KITCHEN_TIMER),
|
||||||
|
@ -70,32 +69,34 @@ class OvenApi(ApplianceApi):
|
||||||
GeErdSensor(self, ErdCode.LOWER_OVEN_DISPLAY_TEMPERATURE),
|
GeErdSensor(self, ErdCode.LOWER_OVEN_DISPLAY_TEMPERATURE),
|
||||||
GeErdBinarySensor(self, ErdCode.LOWER_OVEN_REMOTE_ENABLED),
|
GeErdBinarySensor(self, ErdCode.LOWER_OVEN_REMOTE_ENABLED),
|
||||||
|
|
||||||
GeOven(self, LOWER_OVEN, True, self._temperature_code(has_lower_raw_temperature)),
|
GeOven(self, LOWER_OVEN, True, self._temperature_code(has_lower_raw_temperature))
|
||||||
GeOven(self, UPPER_OVEN, True, self._temperature_code(has_upper_raw_temperature)),
|
|
||||||
])
|
])
|
||||||
if has_upper_raw_temperature:
|
|
||||||
oven_entities.append(GeErdSensor(self, ErdCode.UPPER_OVEN_RAW_TEMPERATURE))
|
|
||||||
if upper_light_availability is None or upper_light_availability.is_available or upper_light is not None:
|
|
||||||
oven_entities.append(GeOvenLightLevelSelect(self, ErdCode.UPPER_OVEN_LIGHT))
|
|
||||||
if has_lower_raw_temperature:
|
if has_lower_raw_temperature:
|
||||||
oven_entities.append(GeErdSensor(self, ErdCode.LOWER_OVEN_RAW_TEMPERATURE))
|
oven_entities.append(GeErdSensor(self, ErdCode.LOWER_OVEN_RAW_TEMPERATURE))
|
||||||
if lower_light_availability is None or lower_light_availability.is_available or lower_light is not None:
|
if lower_light_availability is None or lower_light_availability.is_available or lower_light is not None:
|
||||||
oven_entities.append(GeOvenLightLevelSelect(self, ErdCode.LOWER_OVEN_LIGHT))
|
oven_entities.append(GeOvenLightLevelSelect(self, ErdCode.LOWER_OVEN_LIGHT))
|
||||||
else:
|
if lower_warm_drawer is not None:
|
||||||
oven_entities.extend([
|
oven_entities.append(GeOvenWarmingStateSelect(self, ErdCode.LOWER_OVEN_WARMING_DRAWER_STATE))
|
||||||
GeErdSensor(self, ErdCode.UPPER_OVEN_COOK_MODE, self._single_name(ErdCode.UPPER_OVEN_COOK_MODE)),
|
|
||||||
GeErdSensor(self, ErdCode.UPPER_OVEN_COOK_TIME_REMAINING, self._single_name(ErdCode.UPPER_OVEN_COOK_TIME_REMAINING)),
|
|
||||||
GeErdTimerSensor(self, ErdCode.UPPER_OVEN_KITCHEN_TIMER, self._single_name(ErdCode.UPPER_OVEN_KITCHEN_TIMER)),
|
|
||||||
GeErdSensor(self, ErdCode.UPPER_OVEN_USER_TEMP_OFFSET, self._single_name(ErdCode.UPPER_OVEN_USER_TEMP_OFFSET)),
|
|
||||||
GeErdSensor(self, ErdCode.UPPER_OVEN_DISPLAY_TEMPERATURE, self._single_name(ErdCode.UPPER_OVEN_DISPLAY_TEMPERATURE)),
|
|
||||||
GeErdBinarySensor(self, ErdCode.UPPER_OVEN_REMOTE_ENABLED, self._single_name(ErdCode.UPPER_OVEN_REMOTE_ENABLED)),
|
|
||||||
GeOven(self, UPPER_OVEN, False, self._temperature_code(has_upper_raw_temperature))
|
|
||||||
])
|
|
||||||
if has_upper_raw_temperature:
|
|
||||||
oven_entities.append(GeErdSensor(self, ErdCode.UPPER_OVEN_RAW_TEMPERATURE, self._single_name(ErdCode.UPPER_OVEN_RAW_TEMPERATURE)))
|
|
||||||
if upper_light_availability is None or upper_light_availability.is_available or upper_light is not None:
|
|
||||||
oven_entities.append(GeOvenLightLevelSelect(self, ErdCode.UPPER_OVEN_LIGHT, self._single_name(ErdCode.UPPER_OVEN_LIGHT)))
|
|
||||||
|
|
||||||
|
oven_entities.extend([
|
||||||
|
GeErdSensor(self, ErdCode.UPPER_OVEN_COOK_MODE, self._single_name(ErdCode.UPPER_OVEN_COOK_MODE, oven_config.has_lower_oven)),
|
||||||
|
GeErdSensor(self, ErdCode.UPPER_OVEN_COOK_TIME_REMAINING, self._single_name(ErdCode.UPPER_OVEN_COOK_TIME_REMAINING, oven_config.has_lower_oven)),
|
||||||
|
GeErdTimerSensor(self, ErdCode.UPPER_OVEN_KITCHEN_TIMER, self._single_name(ErdCode.UPPER_OVEN_KITCHEN_TIMER, oven_config.has_lower_oven)),
|
||||||
|
GeErdSensor(self, ErdCode.UPPER_OVEN_USER_TEMP_OFFSET, self._single_name(ErdCode.UPPER_OVEN_USER_TEMP_OFFSET, oven_config.has_lower_oven)),
|
||||||
|
GeErdSensor(self, ErdCode.UPPER_OVEN_DISPLAY_TEMPERATURE, self._single_name(ErdCode.UPPER_OVEN_DISPLAY_TEMPERATURE, oven_config.has_lower_oven)),
|
||||||
|
GeErdBinarySensor(self, ErdCode.UPPER_OVEN_REMOTE_ENABLED, self._single_name(ErdCode.UPPER_OVEN_REMOTE_ENABLED, oven_config.has_lower_oven)),
|
||||||
|
|
||||||
|
GeOven(self, UPPER_OVEN, False, self._temperature_code(has_upper_raw_temperature))
|
||||||
|
])
|
||||||
|
if has_upper_raw_temperature:
|
||||||
|
oven_entities.append(GeErdSensor(self, ErdCode.UPPER_OVEN_RAW_TEMPERATURE, self._single_name(ErdCode.UPPER_OVEN_RAW_TEMPERATURE)))
|
||||||
|
if upper_light_availability is None or upper_light_availability.is_available or upper_light is not None:
|
||||||
|
oven_entities.append(GeOvenLightLevelSelect(self, ErdCode.UPPER_OVEN_LIGHT, self._single_name(ErdCode.UPPER_OVEN_LIGHT)))
|
||||||
|
if upper_warm_drawer is not None:
|
||||||
|
oven_entities.append(GeOvenWarmingStateSelect(self, ErdCode.UPPER_OVEN_WARMING_DRAWER_STATE, self._single_name(ErdCode.UPPER_OVEN_WARMING_DRAWER_STATE)))
|
||||||
|
|
||||||
|
if oven_config.has_warming_drawer and warm_drawer is not None:
|
||||||
|
oven_entities.append(GeErdSensor(self, ErdCode.WARMING_DRAWER_STATE))
|
||||||
|
|
||||||
if cooktop_config == ErdCooktopConfig.PRESENT:
|
if cooktop_config == ErdCooktopConfig.PRESENT:
|
||||||
cooktop_status: CooktopStatus = self.try_get_erd_value(ErdCode.COOKTOP_STATUS)
|
cooktop_status: CooktopStatus = self.try_get_erd_value(ErdCode.COOKTOP_STATUS)
|
||||||
|
@ -112,8 +113,13 @@ class OvenApi(ApplianceApi):
|
||||||
|
|
||||||
return base_entities + oven_entities + cooktop_entities
|
return base_entities + oven_entities + cooktop_entities
|
||||||
|
|
||||||
def _single_name(self, erd_code: ErdCode):
|
def _single_name(self, erd_code: ErdCode, make_single: bool):
|
||||||
return erd_code.name.replace(UPPER_OVEN+"_","").replace("_", " ").title()
|
name = erd_code.name
|
||||||
|
|
||||||
|
if make_single:
|
||||||
|
name = name.replace(UPPER_OVEN+"_","")
|
||||||
|
|
||||||
|
return name.replace("_", " ").title()
|
||||||
|
|
||||||
def _camel_to_snake(self, s):
|
def _camel_to_snake(self, s):
|
||||||
return ''.join(['_'+c.lower() if c.isupper() else c for c in s]).lstrip('_')
|
return ''.join(['_'+c.lower() if c.isupper() else c for c in s]).lstrip('_')
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
from .ge_oven import GeOven
|
from .ge_oven import GeOven
|
||||||
from .ge_oven_light_level_select import GeOvenLightLevelSelect
|
from .ge_oven_light_level_select import GeOvenLightLevelSelect
|
||||||
|
from .ge_oven_warming_state_select import GeOvenWarmingStateSelect
|
||||||
from .const import UPPER_OVEN, LOWER_OVEN
|
from .const import UPPER_OVEN, LOWER_OVEN
|
|
@ -0,0 +1,56 @@
|
||||||
|
import logging
|
||||||
|
from typing import List, Any, Optional
|
||||||
|
|
||||||
|
from gehomesdk import ErdCodeType, ErdOvenWarmingStateAvailability, ErdOvenWarmingState, ErdCode
|
||||||
|
from ...devices import ApplianceApi
|
||||||
|
from ..common import GeErdSelect, OptionsConverter
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class OvenWarmingStateOptionsConverter(OptionsConverter):
|
||||||
|
@property
|
||||||
|
def options(self) -> List[str]:
|
||||||
|
return [i.stringify() for i in ErdOvenWarmingState]
|
||||||
|
def from_option_string(self, value: str) -> Any:
|
||||||
|
try:
|
||||||
|
return ErdOvenWarmingState[value.upper()]
|
||||||
|
except:
|
||||||
|
_LOGGER.warn(f"Could not set Oven warming state to {value.upper()}")
|
||||||
|
return ErdOvenWarmingState.OFF
|
||||||
|
def to_option_string(self, value: ErdOvenWarmingState) -> Optional[str]:
|
||||||
|
try:
|
||||||
|
if value is not None:
|
||||||
|
return value.stringify()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return ErdOvenWarmingState.OFF.stringify()
|
||||||
|
|
||||||
|
class GeOvenWarmingStateSelect(GeErdSelect):
|
||||||
|
|
||||||
|
def __init__(self, api: ApplianceApi, erd_code: ErdCodeType, erd_override: str = None):
|
||||||
|
#check to see if we have a status
|
||||||
|
value: ErdOvenWarmingState = api.try_get_erd_value(erd_code)
|
||||||
|
self._has_status = value is not None and value != ErdOvenWarmingState.NOT_AVAILABLE
|
||||||
|
self._assumed_state = ErdOvenWarmingState.OFF
|
||||||
|
|
||||||
|
super().__init__(api, erd_code, OvenWarmingStateOptionsConverter(self._availability), erd_override=erd_override)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def assumed_state(self) -> bool:
|
||||||
|
return not self._has_status
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_option(self):
|
||||||
|
if self.assumed_state:
|
||||||
|
return self._assumed_state
|
||||||
|
|
||||||
|
return self._converter.to_option_string(self.appliance.get_erd_value(self.erd_code))
|
||||||
|
|
||||||
|
async def async_select_option(self, option: str) -> None:
|
||||||
|
"""Change the selected option."""
|
||||||
|
_LOGGER.debug(f"Setting select from {self.current_option} to {option}")
|
||||||
|
|
||||||
|
new_state = self._converter.from_option_string(option)
|
||||||
|
await self.appliance.async_set_erd_value(self.erd_code, new_state)
|
||||||
|
self._assumed_state = new_state
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "GE Home (SmartHQ)",
|
"name": "GE Home (SmartHQ)",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://github.com/simbaja/ha_gehome",
|
"documentation": "https://github.com/simbaja/ha_gehome",
|
||||||
"requirements": ["gehomesdk==0.5.10","magicattr==0.1.6","slixmpp==1.8.3"],
|
"requirements": ["gehomesdk==0.5.13","magicattr==0.1.6","slixmpp==1.8.3"],
|
||||||
"codeowners": ["@simbaja"],
|
"codeowners": ["@simbaja"],
|
||||||
"version": "0.6.7"
|
"version": "0.6.7"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue