public_transport_victoria
public_transport_victoria copied to clipboard
times displaying in UTC format
The times for the upcoming trains are incorrectly showing. I'm pretty sure the time is displaying in UTC format rather than AEST.
I'm seeing the same issue. Attributes show the below. It looks like the attributes know the times are in UTC, but it's converting to local.
Attribute | Value |
---|---|
Scheduled departure utc | 23 November 2023 at 13:33:00 |
Estimated departure utc | Unknown |
At platform | false |
Platform number | 1 |
Flags | |
Departure sequence | 0 |
Departure | 02:33 AM |
I've fixed this for myself. I'm running HA in a docker container, but while I had a timezone set in HA, the container was running on UTC. I fixed this by setting a timezone for the container with the environment variable TZ=Australia/Melbourne. Now the sensor is displaying local time.
I'm not a developer and I don't know python, but it looks to me the function on lines 151-155 of 'public_transport_victoria.py' is using a function that must invoke the containers timezone not HAs.
def convert_utc_to_local(utc):
d = datetime.datetime.strptime(utc, '%Y-%m-%dT%H:%M:%SZ')
d = d.replace(tzinfo=datetime.timezone.utc)
d = d.astimezone()
return d.strftime('%I:%M %p')
thanks for the response. I ended up fixing it as well.
I was also running HA on docker, and decided to migrate to a virtual machine (for a number of reasons) which instantly fixed the issue. Seems like it is largely a bug with docker HA installs.