- updated app types to include electric cooktops (resolves #252)

- updated cooktop to incorporate newer cooktop attributes
This commit is contained in:
Jack Simbach 2024-05-07 21:44:03 -04:00 committed by simbaja
parent e9fde572bf
commit 8761ac32c8
2 changed files with 22 additions and 10 deletions

View File

@ -37,6 +37,8 @@ def get_appliance_api_type(appliance_type: ErdApplianceType) -> Type:
return OvenApi return OvenApi
if appliance_type == ErdApplianceType.COOKTOP: if appliance_type == ErdApplianceType.COOKTOP:
return CooktopApi return CooktopApi
if appliance_type == ErdApplianceType.ELECTRIC_COOKTOP:
return CooktopApi
if appliance_type == ErdApplianceType.FRIDGE: if appliance_type == ErdApplianceType.FRIDGE:
return FridgeApi return FridgeApi
if appliance_type == ErdApplianceType.BEVERAGE_CENTER: if appliance_type == ErdApplianceType.BEVERAGE_CENTER:

View File

@ -35,16 +35,26 @@ class CooktopApi(ApplianceApi):
cooktop_entities = [] cooktop_entities = []
if cooktop_config == ErdCooktopConfig.PRESENT: if cooktop_config == ErdCooktopConfig.PRESENT:
cooktop_status: CooktopStatus = self.appliance.get_erd_value(ErdCode.COOKTOP_STATUS) # attempt to get the cooktop status using legacy status
cooktop_entities.append(GeErdBinarySensor(self, ErdCode.COOKTOP_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, cooktop_status_erd))
for (k, v) in cooktop_status.burners.items(): for (k, v) in cooktop_status.burners.items():
if v.exists: if v.exists:
prop = self._camel_to_snake(k) prop = self._camel_to_snake(k)
cooktop_entities.append(GeErdPropertyBinarySensor(self, ErdCode.COOKTOP_STATUS, prop+".on")) cooktop_entities.append(GeErdPropertyBinarySensor(self, cooktop_status_erd, prop+".on"))
cooktop_entities.append(GeErdPropertyBinarySensor(self, ErdCode.COOKTOP_STATUS, prop+".synchronized")) cooktop_entities.append(GeErdPropertyBinarySensor(self, cooktop_status_erd, prop+".synchronized"))
if not v.on_off_only: if not v.on_off_only:
cooktop_entities.append(GeErdPropertySensor(self, ErdCode.COOKTOP_STATUS, prop+".power_pct", icon_override="mdi:fire", device_class_override=SensorDeviceClass.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=SensorDeviceClass.POWER_FACTOR, data_type_override=ErdDataType.INT))
return base_entities + cooktop_entities return base_entities + cooktop_entities