added new style cooktop status support (#159)

This commit is contained in:
Jack Simbach 2023-12-09 10:45:12 -05:00
parent 4249141be1
commit 6e651bcc40
1 changed files with 14 additions and 5 deletions

View File

@ -100,18 +100,27 @@ class OvenApi(ApplianceApi):
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:
# attempt to get the cooktop status using legacy status
cooktop_status_erd = ErdCode.COOKTOP_STATUS
cooktop_status: CooktopStatus = self.try_get_erd_value(ErdCode.COOKTOP_STATUS)
# if we didn't get it, try using the new version
if cooktop_status is None:
cooktop_status_erd = ErdCode.COOKTOP_STATUS_EXT
cooktop_status: CooktopStatus = self.try_get_erd_value(ErdCode.COOKTOP_STATUS_EXT)
# if we got a status through either mechanism, we can add the entities
if cooktop_status is not None:
cooktop_entities.append(GeErdBinarySensor(self, ErdCode.COOKTOP_STATUS))
cooktop_entities.append(GeErdBinarySensor(self, cooktop_status_erd))
for (k, v) in cooktop_status.burners.items():
if v.exists:
prop = self._camel_to_snake(k)
cooktop_entities.append(GeErdPropertyBinarySensor(self, ErdCode.COOKTOP_STATUS, prop+".on"))
cooktop_entities.append(GeErdPropertyBinarySensor(self, ErdCode.COOKTOP_STATUS, prop+".synchronized"))
cooktop_entities.append(GeErdPropertyBinarySensor(self, cooktop_status_erd, prop+".on"))
cooktop_entities.append(GeErdPropertyBinarySensor(self, cooktop_status_erd, prop+".synchronized"))
if not v.on_off_only:
cooktop_entities.append(GeErdPropertySensor(self, ErdCode.COOKTOP_STATUS, prop+".power_pct", icon_override="mdi:fire", device_class_override=DEVICE_CLASS_POWER_FACTOR, data_type_override=ErdDataType.INT))
cooktop_entities.append(GeErdPropertySensor(self, cooktop_status_erd, prop+".power_pct", icon_override="mdi:fire", device_class_override=DEVICE_CLASS_POWER_FACTOR, data_type_override=ErdDataType.INT))
return base_entities + oven_entities + cooktop_entities