diff --git a/custom_components/econet300/sensor.py b/custom_components/econet300/sensor.py index 56e7cba..59403b5 100644 --- a/custom_components/econet300/sensor.py +++ b/custom_components/econet300/sensor.py @@ -34,8 +34,10 @@ @dataclass class EconetSensorEntityDescription(SensorEntityDescription): """Describes Econet sensor entity.""" + process_val: Callable[[Any], Any] = lambda x: x + class EconetSensor(SensorEntity): """Econet Sensor""" @@ -43,7 +45,24 @@ def __init__(self, entity_description, unique_id): super().__init__(name=None, unique_id=unique_id) self.entity_description = entity_description self._attr_native_value = None - _LOGGER.debug("EconetSensor initialized with name: %s, unique_id: %s", self.name, self.unique_id) + _LOGGER.debug( + "EconetSensor initialized with name: %s, unique_id: %s", + self.name, + self.unique_id, + ) + + @property + def name(self): + """Return the name of the sensor.""" + if self.entity_description.translation_key: + _LOGGER.debug( + "Using translation key for sensor: %s", + self.entity_description.translation_key, + ) + return f"entity.sensor.{self.entity_description.translation_key}" + else: + _LOGGER.debug("Using name for sensor: %s", self.entity_description.name) + return self.entity_description.name def _sync_state(self, value): """Sync state"""