mirror of
https://github.com/smkrv/ha-text-ai.git
synced 2026-07-30 18:03:55 +08:00
Release v2.0.0
This commit is contained in:
@@ -59,11 +59,6 @@ async def async_setup_entry(
|
|||||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
async_add_entities([HATextAISensor(coordinator, entry)], True)
|
async_add_entities([HATextAISensor(coordinator, entry)], True)
|
||||||
|
|
||||||
class HATextAISensor(CoordinatorEntity, SensorEntity):
|
|
||||||
"""HA text AI Sensor."""
|
|
||||||
|
|
||||||
_attr_has_entity_name = True
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: HATextAICoordinator,
|
coordinator: HATextAICoordinator,
|
||||||
@@ -72,13 +67,11 @@ class HATextAISensor(CoordinatorEntity, SensorEntity):
|
|||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._config_entry = config_entry
|
self._config_entry = config_entry
|
||||||
self._attr_unique_id = f"{config_entry.entry_id}"
|
self._attr_unique_id = config_entry.entry_id
|
||||||
|
|
||||||
self._attr_suggested_display_precision = 0
|
self._attr_suggested_display_precision = 0
|
||||||
self._error_count = 0
|
self._error_count = 0
|
||||||
self._last_error = None
|
self._last_error = None
|
||||||
self._state = STATE_INITIALIZING
|
self._state = STATE_INITIALIZING
|
||||||
|
|
||||||
self._attr_device_info = {
|
self._attr_device_info = {
|
||||||
"identifiers": {(DOMAIN, self._attr_unique_id)},
|
"identifiers": {(DOMAIN, self._attr_unique_id)},
|
||||||
"name": "HA Text AI",
|
"name": "HA Text AI",
|
||||||
@@ -87,6 +80,11 @@ class HATextAISensor(CoordinatorEntity, SensorEntity):
|
|||||||
"sw_version": coordinator.api_version,
|
"sw_version": coordinator.api_version,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
"""Return the name of the sensor."""
|
||||||
|
return "HA Text AI"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str:
|
def icon(self) -> str:
|
||||||
"""Return the icon based on the current state."""
|
"""Return the icon based on the current state."""
|
||||||
|
|||||||
Reference in New Issue
Block a user