From 17eb8c95ddeb40b09bc4082ed1492e72040d6f27 Mon Sep 17 00:00:00 2001 From: Bram Goolaerts Date: Wed, 15 Jun 2022 10:33:53 +0200 Subject: [PATCH] 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 CI --- homeassistant/components/delijn/sensor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/delijn/sensor.py b/homeassistant/components/delijn/sensor.py index e04385dcf3d..ee58a4f21c7 100644 --- a/homeassistant/components/delijn/sensor.py +++ b/homeassistant/components/delijn/sensor.py @@ -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]