Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Revert state/device class to original code
Browse files Browse the repository at this point in the history
    * custom_components/daikin_residential_altherma/sensor.py:
  • Loading branch information
jwillemsen committed Dec 14, 2023
1 parent a55d8fc commit e785006
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions custom_components/daikin_residential_altherma/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ def __init__(self, device: Appliance, embedded_id, management_point_type, operat
self._attr_name = f"{mpt} {operation_mode.capitalize()} {periodName} Energy Consumption"
self._attr_unique_id = f"{self._device.getId()}_{self._management_point_type}_{self._operation_mode}_{self._period}"
self._attr_entity_category = None
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
self._attr_device_class = DEVICE_CLASS_ENERGY
self._attr_icon = icon
self._attr_has_entity_name = True
_LOGGER.info("Device '%s' '%s' supports sensor '%s'", self._embedded_id, device.name, self._attr_name)
Expand Down Expand Up @@ -172,6 +170,14 @@ def device_info(self):
def unit_of_measurement(self):
return ENERGY_KILO_WATT_HOUR

@property
def state_class(self):
return STATE_CLASS_TOTAL_INCREASING

@property
def device_class(self):
return DEVICE_CLASS_ENERGY

async def async_update(self):
"""Retrieve latest state."""
await self._device.api.async_update()
Expand All @@ -186,16 +192,18 @@ def __init__(self, device: Appliance, embedded_id, management_point_type, sub_ty
self._sub_type = sub_type
self._value = value
self._unit_of_measurement = None
self._device_class = None
self._state_class = None
self._attr_has_entity_name = True
sensor_settings = VALUE_SENSOR_MAPPING.get(value)
if sensor_settings is None:
_LOGGER.info("No mapping of value '%s' to HA settings, consider adding it to VALUE_SENSOR_MAPPING", value);
else:
self._attr_icon = sensor_settings[CONF_ICON]
self._attr_device_class = sensor_settings[CONF_DEVICE_CLASS]
self._device_class = sensor_settings[CONF_DEVICE_CLASS]
self._unit_of_measurement = sensor_settings[CONF_UNIT_OF_MEASUREMENT]
self._attr_entity_registry_enabled_default = sensor_settings[ENABLED_DEFAULT]
self._attr_state_class = sensor_settings[CONF_STATE_CLASS]
self._state_class = sensor_settings[CONF_STATE_CLASS]
self._attr_entity_category = sensor_settings[ENTITY_CATEGORY]
mpt = management_point_type[0].upper() + management_point_type[1:]
myname = value[0].upper() + value[1:]
Expand Down Expand Up @@ -229,6 +237,14 @@ def available(self):
def unit_of_measurement(self):
return self._unit_of_measurement

@property
def state_class(self):
return self._state_class

@property
def device_class(self):
return self._device_class

@property
def device_info(self):
"""Return a device description for device registry."""
Expand Down

0 comments on commit e785006

Please sign in to comment.