mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix Starline attributes timezone (#105645)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
e507d1c5a5
commit
4330452212
@ -25,6 +25,12 @@ from .const import (
|
||||
)
|
||||
|
||||
|
||||
def _parse_datetime(dt_str: str | None) -> str | None:
|
||||
if dt_str is None or (parsed := dt_util.parse_datetime(dt_str)) is None:
|
||||
return None
|
||||
return parsed.replace(tzinfo=dt_util.UTC).isoformat()
|
||||
|
||||
|
||||
class StarlineAccount:
|
||||
"""StarLine Account class."""
|
||||
|
||||
@ -143,9 +149,7 @@ class StarlineAccount:
|
||||
def gps_attrs(device: StarlineDevice) -> dict[str, Any]:
|
||||
"""Attributes for device tracker."""
|
||||
return {
|
||||
"updated": dt_util.utc_from_timestamp(device.position["ts"])
|
||||
.replace(tzinfo=None)
|
||||
.isoformat(),
|
||||
"updated": dt_util.utc_from_timestamp(device.position["ts"]).isoformat(),
|
||||
"online": device.online,
|
||||
}
|
||||
|
||||
@ -155,7 +159,7 @@ class StarlineAccount:
|
||||
return {
|
||||
"operator": device.balance.get("operator"),
|
||||
"state": device.balance.get("state"),
|
||||
"updated": device.balance.get("ts"),
|
||||
"updated": _parse_datetime(device.balance.get("ts")),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
x
Reference in New Issue
Block a user