Fix timestamps exposed to LLM to be in local timezone (#139825)

Co-authored-by: Michael Hansen <mike@rhasspy.org>
This commit is contained in:
michnovka
2025-09-08 21:51:17 +02:00
committed by GitHub
parent 03a7052151
commit d990c2bee2
2 changed files with 72 additions and 0 deletions

View File

@@ -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