mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Fix timestamps exposed to LLM to be in local timezone (#139825)
Co-authored-by: Michael Hansen <mike@rhasspy.org>
This commit is contained in:
@@ -687,6 +687,11 @@ def _get_exposed_entities(
|
||||
if include_state:
|
||||
info["state"] = state.state
|
||||
|
||||
# Convert timestamp device_class states from UTC to local time
|
||||
if state.attributes.get("device_class") == "timestamp" and state.state:
|
||||
if (parsed_utc := dt_util.parse_datetime(state.state)) is not None:
|
||||
info["state"] = dt_util.as_local(parsed_utc).isoformat()
|
||||
|
||||
if description:
|
||||
info["description"] = description
|
||||
|
||||
|
||||
Reference in New Issue
Block a user