def _update_state_and_attributes(self) -> None:
        """Update sensor state with the last error message."""
        data = self.coordinator.data or {}
        last_error = data.get("last_error")
        self._attr_native_value = str(last_error) if last_error else "No Error"
        self._attr_extra_state_attributes = {
             "last_error_timestamp": data.get("last_update") if last_error else None,
        }
Update sensor state with the last error message.
custom_components/ai_automation_suggester/sensor.py