Fix De Lijn 'tzinfo' error (#73502)
* Fix De Lijn component tzinfo error This fix should update the issue "Error:'str' object has no attribute 'tzinfo'" (issue #67455) * fix Black and isort errors fixing errors from Black and isort CI validation * Fix black and flake8 issues Fixing black and flake8 issues to pass CIpull/71867/head
parent
a77ea1c390
commit
17eb8c95dd
|
@ -1,6 +1,7 @@
|
|||
"""Support for De Lijn (Flemish public transport) information."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
import logging
|
||||
|
||||
from pydelijn.api import Passages
|
||||
|
@ -111,7 +112,9 @@ class DeLijnPublicTransportSensor(SensorEntity):
|
|||
first = self.line.passages[0]
|
||||
if (first_passage := first["due_at_realtime"]) is None:
|
||||
first_passage = first["due_at_schedule"]
|
||||
self._attr_native_value = first_passage
|
||||
self._attr_native_value = datetime.strptime(
|
||||
first_passage, "%Y-%m-%dT%H:%M:%S%z"
|
||||
)
|
||||
|
||||
for key in AUTO_ATTRIBUTES:
|
||||
self._attr_extra_state_attributes[key] = first[key]
|
||||
|
|
Loading…
Reference in New Issue