From e8b611643967dcbb4e4b4f0b9a48eab566e2d265 Mon Sep 17 00:00:00 2001 From: SMKRV Date: Sun, 24 Nov 2024 19:24:30 +0300 Subject: [PATCH] Release v2.0.0 --- custom_components/ha_text_ai/sensor.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/custom_components/ha_text_ai/sensor.py b/custom_components/ha_text_ai/sensor.py index 1b18241..8ad355b 100644 --- a/custom_components/ha_text_ai/sensor.py +++ b/custom_components/ha_text_ai/sensor.py @@ -84,13 +84,15 @@ class HATextAISensor(CoordinatorEntity, SensorEntity): super().__init__(coordinator) self._config_entry = config_entry - self._attr_name = config_entry.title - self._attr_unique_id = f"{config_entry.entry_id}_{slugify(self._attr_name)}" - self.entity_id = f"sensor.ha_text_ai_{slugify(self._attr_name)}" - - # Сохраняем instance_name из координатора self._instance_name = coordinator.instance_name + # Упрощаем формирование entity_id + self.entity_id = f"sensor.ha_text_ai_{self._instance_name}" + self._attr_name = f"HA Text AI {self._instance_name}" + self._attr_unique_id = f"{config_entry.entry_id}" + + _LOGGER.debug(f"Initializing sensor with entity_id: {self.entity_id}") + self._current_state = STATE_INITIALIZING self._error_count = 0 self._last_error = None @@ -108,7 +110,7 @@ class HATextAISensor(CoordinatorEntity, SensorEntity): sw_version="1.0.0", ) - _LOGGER.info(f"Initialized sensor with instance: {self._instance_name}") + _LOGGER.info(f"Initialized sensor: {self.entity_id} for instance: {self._instance_name}") @property def native_value(self) -> StateType: