mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +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:
|
class StarlineAccount:
|
||||||
"""StarLine Account class."""
|
"""StarLine Account class."""
|
||||||
|
|
||||||
@ -143,9 +149,7 @@ class StarlineAccount:
|
|||||||
def gps_attrs(device: StarlineDevice) -> dict[str, Any]:
|
def gps_attrs(device: StarlineDevice) -> dict[str, Any]:
|
||||||
"""Attributes for device tracker."""
|
"""Attributes for device tracker."""
|
||||||
return {
|
return {
|
||||||
"updated": dt_util.utc_from_timestamp(device.position["ts"])
|
"updated": dt_util.utc_from_timestamp(device.position["ts"]).isoformat(),
|
||||||
.replace(tzinfo=None)
|
|
||||||
.isoformat(),
|
|
||||||
"online": device.online,
|
"online": device.online,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +159,7 @@ class StarlineAccount:
|
|||||||
return {
|
return {
|
||||||
"operator": device.balance.get("operator"),
|
"operator": device.balance.get("operator"),
|
||||||
"state": device.balance.get("state"),
|
"state": device.balance.get("state"),
|
||||||
"updated": device.balance.get("ts"),
|
"updated": _parse_datetime(device.balance.get("ts")),
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user