mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-27 09:34:01 +08:00
Release v2.0.0
This commit is contained in:
@@ -84,13 +84,15 @@ class HATextAISensor(CoordinatorEntity, SensorEntity):
|
|||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
|
||||||
self._config_entry = config_entry
|
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
|
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._current_state = STATE_INITIALIZING
|
||||||
self._error_count = 0
|
self._error_count = 0
|
||||||
self._last_error = None
|
self._last_error = None
|
||||||
@@ -108,7 +110,7 @@ class HATextAISensor(CoordinatorEntity, SensorEntity):
|
|||||||
sw_version="1.0.0",
|
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
|
@property
|
||||||
def native_value(self) -> StateType:
|
def native_value(self) -> StateType:
|
||||||
|
|||||||
Reference in New Issue
Block a user