Timezone, UTC and Automation

I am having problem where I have the correct timezone set in the configuration.YAML and I know UTC time is always different then the timezone displayed in the front end of the system.

  
default_config:
discovery:
media_extractor:
sun:
sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat' 

So this this the time

the correct time for my timezone is displayed in Front end of HA with UTC which I know is always different for the backend.

However the issue I am facing the automation’s I want to run they should be running to my local time zone however they don’t run, they seem to work if I change the automation’s to UTC time then they seem to work. How can I fix this issue so my automation’s run according to my local timezone and not the UTC time.

I have tried restarting and resetting the HA still no joy.

Any help appreciated.

There are actually two time zone settings that matter. One you’ve mentioned, which is in HA’s configuration. But the other is the time zone in the OS environment in which HA runs. This depends on how you have installed HA. But basically that must also be the local time zone, NOT UTC. I’ve seen some people have the time zone in the “OS” set to UTC, and that’s wrong. That will mess things up.

It seems like your local time zone is currently UTC + 1 hr. Is that right? So you have the time zone config in HA set to something like Europe/London, right?

Please go to the Template Editor and enter the following:

{{ utcnow().tzinfo }}
{{ now().tzinfo }}
{{ now().astimezone().tzinfo }}

Let me know what you get. The first should be “UTC”. The second and third should both indicate your local time zone (albeit possibly in slightly different words.)

Thanks for your reply.

Yes I am in London UK so we are UTC+1 here.

Yes time zone is set to Europe/London

after putting the code you suggested in the template editor, this is what it tells me

Well that shows that your HA time zone configuration is GB, not Europe/London. Hmm.

I looked up GB and it says that’s obsolete.

Make sure that you have HA configured for Europe/London, not GB. Also in the “OS” environment in which HA is running (either the underlying OS, or the docker container, etc.) it should probably also be set to Europe/London.

FWIW, I would have expected your results to be:

UTC
Europe/London
BST

I am running Home Assistant on Raspberry Pi 3b…

No I fixed the time issue but still not as you expect the result now I am getting

UTC
Europe/Dublin
GB

How exactly are you setting HA’s time zone configuration to “Europe/London”? Because now it’s saying “Europe/Dublin”.

Also, exactly how are you setting the time zone in the environment in which HA is running? Because it’s still saying “GB”.

The only setting or place to modify this I know is in Configurations then General… Despite doing this and restarting the Pi and HA its still showing this in terminal. I think something seriously messed up somewhere you think its worth just doing a fresh install again?

Not sure what to tell you. I can’t explain why, when you have “Europe/London” set in the General Configuration page, you get “Europe/Dublin” from the template.

What is in your configuration.yaml file? Specifically, do you see time_zone under the homeassistant key? E.g.:

homeassistant:
  ...
  time_zone: XXX

If so, what is set there?

homeassistant:
default_config:
discovery:
media_extractor:
sun:
sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'
  - platform: athan
    calculation_method: mwl
    sensors:
      - fajr
      - sunrise
      - dhuhr
      - asr
      - maghrib
      - isha
#Google Home
cast:
  media_player:
    - host: 10.107.1.***
    - host: 10.107.1.***

#Input Boolean - used to synchronize between multiple speakers
input_boolean:  
  adhan:
    name: Adhan
    initial: off 
#Play media from URL - this is another way to play the Adhan from Youtube
    #media_extractor:
# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

That’s my complete config.yaml I don’t have time_zone set in it. I think I will do a fresh install and write back if problem presists.

1 Like

Did you ever figure this out?