Fix timezone issue (#92005)
parent
083f42cce6
commit
74e3cac8b5
|
@ -610,14 +610,6 @@ class GTFSDepartureSensor(SensorEntity):
|
|||
self._include_tomorrow,
|
||||
)
|
||||
|
||||
# Define the state as a UTC timestamp with ISO 8601 format
|
||||
if not self._departure:
|
||||
self._state = None
|
||||
else:
|
||||
self._state = self._departure["departure_time"].replace(
|
||||
tzinfo=dt_util.UTC
|
||||
)
|
||||
|
||||
# Fetch trip and route details once, unless updated
|
||||
if not self._departure:
|
||||
self._trip = None
|
||||
|
@ -648,6 +640,19 @@ class GTFSDepartureSensor(SensorEntity):
|
|||
)
|
||||
self._agency = False
|
||||
|
||||
# Define the state as a UTC timestamp with ISO 8601 format
|
||||
if not self._departure:
|
||||
self._state = None
|
||||
else:
|
||||
if self._agency:
|
||||
self._state = self._departure["departure_time"].replace(
|
||||
tzinfo=dt_util.get_time_zone(self._agency.agency_timezone)
|
||||
)
|
||||
else:
|
||||
self._state = self._departure["departure_time"].replace(
|
||||
tzinfo=dt_util.UTC
|
||||
)
|
||||
|
||||
# Assign attributes, icon and name
|
||||
self.update_attributes()
|
||||
|
||||
|
|
Loading…
Reference in New Issue