From 2fe84ab801453847ace8f7c0580eec4eb8a41f27 Mon Sep 17 00:00:00 2001 From: SMKRV Date: Sun, 24 Nov 2024 00:56:33 +0300 Subject: [PATCH] Release v2.0.0 --- custom_components/ha_text_ai/sensor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/custom_components/ha_text_ai/sensor.py b/custom_components/ha_text_ai/sensor.py index 56758f4..0808764 100644 --- a/custom_components/ha_text_ai/sensor.py +++ b/custom_components/ha_text_ai/sensor.py @@ -100,6 +100,14 @@ class HATextAISensor(CoordinatorEntity, SensorEntity): return dt_util.as_local(last_response['timestamp']) return self._current_state + @property + def state(self) -> StateType: + """Return the state of the sensor.""" + last_response = self.coordinator.last_response + if last_response and 'timestamp' in last_response: + return dt_util.as_local(last_response['timestamp']) + return self._current_state + @property def extra_state_attributes(self) -> Dict[str, Any]: """Return entity specific state attributes."""