- miscellaneous cleanup

- changed from device_state_attributes to extra_state_attributes
This commit is contained in:
Jack Simbach 2021-07-24 11:58:24 -04:00
parent d616f21ac5
commit bec1c1e00f
7 changed files with 28 additions and 32 deletions

View File

@ -16,8 +16,8 @@ _LOGGER = logging.getLogger(__name__)
def get_appliance_api_type(appliance_type: ErdApplianceType) -> Type:
_LOGGER.debug(f"Found device type: {appliance_type}")
"""Get the appropriate appliance type"""
_LOGGER.debug(f"Found device type: {appliance_type}")
if appliance_type == ErdApplianceType.OVEN:
return OvenApi
if appliance_type == ErdApplianceType.FRIDGE:

View File

@ -60,9 +60,7 @@ class GeErdSensor(GeErdEntity, Entity):
in [ErdCodeClass.RAW_TEMPERATURE, ErdCodeClass.NON_ZERO_TEMPERATURE]
or self.device_class == DEVICE_CLASS_TEMPERATURE
):
if self._measurement_system == ErdMeasurementUnits.METRIC:
return TEMP_CELSIUS
return TEMP_FAHRENHEIT
return self._temp_units
if (
self.erd_code_class == ErdCodeClass.BATTERY
or self.device_class == DEVICE_CLASS_BATTERY

View File

@ -42,13 +42,3 @@ class GeWaterHeater(GeEntity, WaterHeaterEntity, metaclass=abc.ABCMeta):
@property
def supported_features(self):
raise NotImplementedError
@property
def other_state_attrs(self) -> Dict[str, Any]:
"""State attributes to be optionally overridden in subclasses."""
return {}
@property
def device_state_attributes(self) -> Dict[str, Any]:
other_attrs = self.other_state_attrs
return {**other_attrs}

View File

@ -139,15 +139,17 @@ class GeAbstractFridge(GeWaterHeater):
"""Get state attributes for the ice maker, if applicable."""
data = {}
erd_val: FridgeIceBucketStatus = self.appliance.get_erd_value(ErdCode.ICE_MAKER_BUCKET_STATUS)
ice_bucket_status = getattr(erd_val, f"state_full_{self.heater_type}")
if ice_bucket_status != ErdFullNotFull.NA:
data["ice_bucket"] = self._stringify(ice_bucket_status)
if self.api.has_erd_code(ErdCode.ICE_MAKER_BUCKET_STATUS):
erd_val: FridgeIceBucketStatus = self.appliance.get_erd_value(ErdCode.ICE_MAKER_BUCKET_STATUS)
ice_bucket_status = getattr(erd_val, f"state_full_{self.heater_type}")
if ice_bucket_status != ErdFullNotFull.NA:
data["ice_bucket"] = self._stringify(ice_bucket_status)
erd_val: IceMakerControlStatus = self.appliance.get_erd_value(ErdCode.ICE_MAKER_CONTROL)
ice_control_status = getattr(erd_val, f"status_{self.heater_type}")
if ice_control_status != ErdOnOff.NA:
data["ice_maker"] = self._stringify(ice_control_status)
if self.api.has_erd_code(ErdCode.ICE_MAKER_CONTROL):
erd_val: IceMakerControlStatus = self.appliance.get_erd_value(ErdCode.ICE_MAKER_CONTROL)
ice_control_status = getattr(erd_val, f"status_{self.heater_type}")
if ice_control_status != ErdOnOff.NA:
data["ice_maker"] = self._stringify(ice_control_status)
return data
@ -157,8 +159,13 @@ class GeAbstractFridge(GeWaterHeater):
return {}
@property
def device_state_attributes(self) -> Dict[str, Any]:
def other_state_attrs(self) -> Dict[str, Any]:
"""Other state attributes for the entity"""
return {}
@property
def extra_state_attributes(self) -> Dict[str, Any]:
door_attrs = self.door_state_attrs
ice_maker_attrs = self.ice_maker_state_attrs
other_attrs = self.other_state_attrs
return {**door_attrs, **ice_maker_attrs, **other_attrs}
other_state_attrs = self.other_state_attrs
return {**door_attrs, **ice_maker_attrs, **other_state_attrs}

View File

@ -110,7 +110,7 @@ class GeDispenser(GeWaterHeater):
return convert_temperature(self._max_temp, TEMP_FAHRENHEIT, self.temperature_unit)
@property
def other_state_attrs(self) -> Dict[str, Any]:
def extra_state_attributes(self) -> Dict[str, Any]:
data = {}
data["target_temperature"] = self.target_temperature

View File

@ -26,11 +26,12 @@ class GeFridge(GeAbstractFridge):
@property
def other_state_attrs(self) -> Dict[str, Any]:
"""Water filter state."""
filter_status: ErdFilterStatus = self.appliance.get_erd_value(ErdCode.WATER_FILTER_STATUS)
if filter_status == ErdFilterStatus.NA:
return {}
return {"water_filter_status": self._stringify(filter_status)}
if(self.api.has_erd_code(ErdCode.WATER_FILTER_STATUS)):
filter_status: ErdFilterStatus = self.appliance.get_erd_value(ErdCode.WATER_FILTER_STATUS)
if filter_status == ErdFilterStatus.NA:
return {}
return {"water_filter_status": self._stringify(filter_status)}
return {}
@property
def door_state_attrs(self) -> Dict[str, Any]:

View File

@ -180,7 +180,7 @@ class GeOven(GeWaterHeater):
return self._stringify(erd_value, temp_units=self.temperature_unit)
@property
def device_state_attributes(self) -> Optional[Dict[str, Any]]:
def extra_state_attributes(self) -> Optional[Dict[str, Any]]:
probe_present = False
if self.api.has_erd_code(self.get_erd_code("PROBE_PRESENT")):
probe_present: bool = self.get_erd_value("PROBE_PRESENT")