- fixed fridge issues

- requirements bump
This commit is contained in:
Jack Simbach 2021-01-14 22:38:23 -05:00
parent 27b810ac75
commit 2ed51f39a6
3 changed files with 21 additions and 13 deletions

View File

@ -3,7 +3,7 @@ import logging
from typing import Dict, List, Optional from typing import Dict, List, Optional
from gekitchensdk import GeAppliance from gekitchensdk import GeAppliance
from gekitchensdk.erd import ErdCode, ErdApplianceType from gekitchensdk.erd import ErdCode, ErdCodeType, ErdApplianceType
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
@ -108,3 +108,10 @@ class ApplianceApi:
for entity in entities: for entity in entities:
if entity.unique_id not in self._entities: if entity.unique_id not in self._entities:
self._entities[entity.unique_id] = entity self._entities[entity.unique_id] = entity
def try_get_erd_value(self, code: ErdCodeType):
try:
return self.appliance.get_erd_value(code)
except:
return None

View File

@ -41,12 +41,13 @@ class FridgeApi(ApplianceApi):
dispenser_entities = [] dispenser_entities = []
# Get the statuses used to determine presence # Get the statuses used to determine presence
ice_maker_control: IceMakerControlStatus = self.appliance.get_erd_value(ErdCode.ICE_MAKER_CONTROL)
ice_bucket_status: FridgeIceBucketStatus = self.appliance.get_erd_value(ErdCode.ICE_MAKER_BUCKET_STATUS) ice_maker_control: IceMakerControlStatus = self.try_get_erd_value(ErdCode.ICE_MAKER_CONTROL)
water_filter: ErdFilterStatus = self.appliance.get_erd_value(ErdCode.WATER_FILTER_STATUS) ice_bucket_status: FridgeIceBucketStatus = self.try_get_erd_value(ErdCode.ICE_MAKER_BUCKET_STATUS)
air_filter: ErdFilterStatus = self.appliance.get_erd_value(ErdCode.AIR_FILTER_STATUS) water_filter: ErdFilterStatus = self.try_get_erd_value(ErdCode.WATER_FILTER_STATUS)
hot_water_status: HotWaterStatus = self.appliance.get_erd_value(ErdCode.HOT_WATER_STATUS) air_filter: ErdFilterStatus = self.try_get_erd_value(ErdCode.AIR_FILTER_STATUS)
fridge_model_info: FridgeModelInfo = self.appliance.get_erd_value(ErdCode.FRIDGE_MODEL_INFO) hot_water_status: HotWaterStatus = self.try_get_erd_value(ErdCode.HOT_WATER_STATUS)
fridge_model_info: FridgeModelInfo = self.try_get_erd_value(ErdCode.FRIDGE_MODEL_INFO)
# Common entities # Common entities
common_entities = [ common_entities = [
@ -59,7 +60,7 @@ class FridgeApi(ApplianceApi):
common_entities.append(GeErdSensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS)) common_entities.append(GeErdSensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS))
# Fridge entities # Fridge entities
if fridge_model_info.has_fridge: if fridge_model_info is None or fridge_model_info.has_fridge:
fridge_entities.extend([ fridge_entities.extend([
GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "fridge"), GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "fridge"),
GeFridge(self), GeFridge(self),
@ -71,18 +72,18 @@ class FridgeApi(ApplianceApi):
if(air_filter and air_filter != ErdFilterStatus.NA): if(air_filter and air_filter != ErdFilterStatus.NA):
fridge_entities.append(GeErdSensor(self, ErdCode.AIR_FILTER_STATUS)) fridge_entities.append(GeErdSensor(self, ErdCode.AIR_FILTER_STATUS))
if(ice_bucket_status and ice_bucket_status.is_present_fridge): if(ice_bucket_status and ice_bucket_status.is_present_fridge):
GeErdPropertySensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS, "state_full_fridge") fridge_entities.append(GeErdPropertySensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS, "state_full_fridge"))
# Freezer entities # Freezer entities
if fridge_model_info.has_freezer: if fridge_model_info is None or fridge_model_info.has_freezer:
freezer_entities.extend([ freezer_entities.extend([
GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "freezer"), GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "freezer"),
GeFreezer(self), GeFreezer(self),
]) ])
if(ice_maker_control and ice_maker_control.status_freezer != ErdOnOff.NA): if(ice_maker_control and ice_maker_control.status_freezer != ErdOnOff.NA):
GeErdPropertyBinarySensor(self, ErdCode.ICE_MAKER_CONTROL, "status_freezer") freezer_entities.append(GeErdPropertyBinarySensor(self, ErdCode.ICE_MAKER_CONTROL, "status_freezer"))
if(ice_bucket_status and ice_bucket_status.is_present_freezer): if(ice_bucket_status and ice_bucket_status.is_present_freezer):
GeErdPropertySensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS, "state_full_freezer") freezer_entities.append(GeErdPropertySensor(self, ErdCode.ICE_MAKER_BUCKET_STATUS, "state_full_freezer"))
# Dispenser entities # Dispenser entities
if(hot_water_status and hot_water_status.status != ErdHotWaterStatus.NA): if(hot_water_status and hot_water_status.status != ErdHotWaterStatus.NA):

View File

@ -3,6 +3,6 @@
"name": "GE Kitchen", "name": "GE Kitchen",
"config_flow": true, "config_flow": true,
"documentation": "https://github.com/simbaja/ha_components", "documentation": "https://github.com/simbaja/ha_components",
"requirements": ["gekitchensdk==0.3.9","magicattr==0.1.5"], "requirements": ["gekitchensdk==0.3.10","magicattr==0.1.5"],
"codeowners": ["@simbaja"] "codeowners": ["@simbaja"]
} }