From 1374b3629e4283a7fe8659d59920c2f03997d8f4 Mon Sep 17 00:00:00 2001 From: Jack Simbach Date: Tue, 29 Dec 2020 12:02:56 -0500 Subject: [PATCH] - sensor configuration updates --- ge_kitchen/devices/dishwasher.py | 2 +- ge_kitchen/devices/fridge.py | 51 +++++++++++++++---- ge_kitchen/devices/oven.py | 4 +- ge_kitchen/entities/common/ge_erd_entity.py | 2 + ge_kitchen/entities/common/ge_erd_sensor.py | 8 +++ ge_kitchen/entities/oven/__init__.py | 1 - .../oven/ge_erd_cooktop_burner_sensor.py | 13 ----- 7 files changed, 54 insertions(+), 27 deletions(-) delete mode 100644 ge_kitchen/entities/oven/ge_erd_cooktop_burner_sensor.py diff --git a/ge_kitchen/devices/dishwasher.py b/ge_kitchen/devices/dishwasher.py index 9cb8c22..99bc43b 100644 --- a/ge_kitchen/devices/dishwasher.py +++ b/ge_kitchen/devices/dishwasher.py @@ -22,7 +22,7 @@ class DishwasherApi(ApplianceApi): GeErdSensor(self, ErdCode.CYCLE_STATE), GeErdSensor(self, ErdCode.OPERATING_MODE), GeErdSensor(self, ErdCode.PODS_REMAINING_VALUE), - GeErdSensor(self, ErdCode.RINSE_AGENT), + GeErdSensor(self, ErdCode.RINSE_AGENT, icon_override="mdi:sparkle"), GeErdSensor(self, ErdCode.TIME_REMAINING), ] entities = base_entities + dishwasher_entities diff --git a/ge_kitchen/devices/fridge.py b/ge_kitchen/devices/fridge.py index 33dd788..024b9ac 100644 --- a/ge_kitchen/devices/fridge.py +++ b/ge_kitchen/devices/fridge.py @@ -1,3 +1,5 @@ +from homeassistant.components.binary_sensor import DEVICE_CLASS_PROBLEM +from homeassistant.const import DEVICE_CLASS_TEMPERATURE import logging from typing import List @@ -5,7 +7,15 @@ from homeassistant.helpers.entity import Entity from gekitchen.erd import ErdCode, ErdApplianceType from .base import ApplianceApi -from ..entities import GeErdSensor, GeErdSwitch, GeFridgeEntity, GeFreezerEntity +from ..entities import ( + GeErdSensor, + GeErdSwitch, + GeFridge, + GeFreezer, + GeDispenser, + GeErdPropertySensor, + GeErdPropertyBinarySensor +) _LOGGER = logging.getLogger(__name__) @@ -15,17 +25,38 @@ class FridgeApi(ApplianceApi): def get_all_entities(self) -> List[Entity]: base_entities = super().get_all_entities() + + fridge_entities = [] + freezer_entities = [] + dispenser_entities = [] - fridge_entities = [ - GeErdSensor(self, ErdCode.AIR_FILTER_STATUS), - GeErdSensor(self, ErdCode.DOOR_STATUS), + common_entities = [ GeErdSensor(self, ErdCode.FRIDGE_MODEL_INFO), + GeErdSwitch(self, ErdCode.SABBATH_MODE), + GeErdSensor(self, ErdCode.DOOR_STATUS), + GeErdPropertyBinarySensor(self, ErdCode.DOOR_STATUS, "any_open") + ] + + fridge_entities.extend([ + GeErdSensor(self, ErdCode.WATER_FILTER_STATUS), + GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "fridge"), + GeFridge(self), + ]) + + freezer_entities.extend([ + GeErdPropertySensor(self, ErdCode.CURRENT_TEMPERATURE, "freezer"), + GeFreezer(self), + ]) + + dispenser_entities.extend([ GeErdSensor(self, ErdCode.HOT_WATER_IN_USE), GeErdSensor(self, ErdCode.HOT_WATER_SET_TEMP), - GeErdSensor(self, ErdCode.HOT_WATER_STATUS), - GeErdSwitch(self, ErdCode.SABBATH_MODE), - GeFreezerEntity(self), - GeFridgeEntity(self), - ] - entities = base_entities + fridge_entities + GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "status"), + GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "time_remaining", icon_override="mdi:timer-outline"), + GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "time_remaining", device_class_override=DEVICE_CLASS_TEMPERATURE), + GeErdPropertyBinarySensor(self, ErdCode.HOT_WATER_STATUS, "faulted", device_class_override=DEVICE_CLASS_PROBLEM), + GeDispenser(self) + ]) + + entities = base_entities + common_entities + fridge_entities + freezer_entities + dispenser_entities return entities diff --git a/ge_kitchen/devices/oven.py b/ge_kitchen/devices/oven.py index 4a8d8f7..eec0e9b 100644 --- a/ge_kitchen/devices/oven.py +++ b/ge_kitchen/devices/oven.py @@ -1,6 +1,7 @@ import logging from typing import List +from homeassistant.const import DEVICE_CLASS_POWER_FACTOR from homeassistant.helpers.entity import Entity from gekitchen import ( ErdCode, @@ -16,7 +17,6 @@ from ..entities import ( GeErdBinarySensor, GeErdPropertyBinarySensor, GeOven, - GeErdCooktopBurnerSensor, UPPER_OVEN, LOWER_OVEN ) @@ -76,7 +76,7 @@ class OvenApi(ApplianceApi): cooktop_entities.append(GeErdPropertyBinarySensor(self, ErdCode.COOKTOP_STATUS, k+".on")) cooktop_entities.append(GeErdPropertyBinarySensor(self, ErdCode.COOKTOP_STATUS, k+".synchronized")) if not v.on_off_only: - cooktop_entities.append(GeErdCooktopBurnerSensor(self, ErdCode.COOKTOP_STATUS, k+".power_pct")) + cooktop_entities.append(GeErdSensor(self, ErdCode.COOKTOP_STATUS, k+".power_pct", icon_override="mdi:fire", device_class_override=DEVICE_CLASS_POWER_FACTOR)) return base_entities + oven_entities + cooktop_entities diff --git a/ge_kitchen/entities/common/ge_erd_entity.py b/ge_kitchen/entities/common/ge_erd_entity.py index 9b0d99d..01c9c90 100644 --- a/ge_kitchen/entities/common/ge_erd_entity.py +++ b/ge_kitchen/entities/common/ge_erd_entity.py @@ -81,6 +81,8 @@ class GeErdEntity(GeEntity): return None if self.erd_code_class == ErdCodeClass.CLOCK: return "mdi:clock" + if self.erd_code_class == ErdCodeClass.COUNTER: + return "mdi:counter" if self.erd_code_class == ErdCodeClass.DOOR: return "mdi:door" if self.erd_code_class == ErdCodeClass.TIMER: diff --git a/ge_kitchen/entities/common/ge_erd_sensor.py b/ge_kitchen/entities/common/ge_erd_sensor.py index 7152631..308b022 100644 --- a/ge_kitchen/entities/common/ge_erd_sensor.py +++ b/ge_kitchen/entities/common/ge_erd_sensor.py @@ -47,3 +47,11 @@ class GeErdSensor(GeErdEntity, Entity): return DEVICE_CLASS_BATTERY return None + + def _get_icon(self): + if self.erd_code_class == ErdCodeClass.DOOR: + if self.state.lower().endswith("open"): + return "mdi:door-open" + if self.state.lower().endswith("closed"): + return "mdi:door-closed" + return super()._get_icon() \ No newline at end of file diff --git a/ge_kitchen/entities/oven/__init__.py b/ge_kitchen/entities/oven/__init__.py index bd936f2..a5e7f85 100644 --- a/ge_kitchen/entities/oven/__init__.py +++ b/ge_kitchen/entities/oven/__init__.py @@ -1,3 +1,2 @@ from .ge_oven import GeOven -from .ge_erd_cooktop_burner_sensor import GeErdCooktopBurnerSensor from .const import UPPER_OVEN, LOWER_OVEN \ No newline at end of file diff --git a/ge_kitchen/entities/oven/ge_erd_cooktop_burner_sensor.py b/ge_kitchen/entities/oven/ge_erd_cooktop_burner_sensor.py deleted file mode 100644 index 840a836..0000000 --- a/ge_kitchen/entities/oven/ge_erd_cooktop_burner_sensor.py +++ /dev/null @@ -1,13 +0,0 @@ -from typing import Optional -from ..common import GeErdPropertySensor - -class GeErdCooktopBurnerSensor(GeErdPropertySensor): - icon = "mdi:fire" - - @property - def units(self) -> Optional[str]: - return "%" - - @property - def device_class(self) -> Optional[str]: - return "power_factor"