Hi guys,
I’m running Home Assistant 0.77.3 on a RPI.
In “configuration.yaml”, I’ve set Asia/Bangkok as timezone (UTC+7), which seems work to ok in the Webui.
But the time-stamps in my logfile and also my weather-app “Dark sky” are six hours back (UTC+1)
Any ideas?
PS: “date” on the RPI shows “So 9. Sep 12:58:41 +07 2018” which is also correct.
thanks in advance.
The front end shows local time. All the back end stuff is done using UTC. Are you sure you are seeing UTC+1?
Are you sure you are seeing UTC+1?
Yes, the screenshot was taken one minute before this log entry.
2018-09-09 07:26:04 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: new_state=<state sensor.sonoff_th=28.6; unit_of_measurement=°C, friendly_name=Sonoff TH @ 2018-09-09T13:26:04.312664+07:00>, entity_id=sensor.sonoff_th, old_state=<state sensor.sonoff_th=28.7; unit_of_measurement=°C, friendly_name=Sonoff TH @
Edit: “All the back end stuff is done using UTC”
Does it mean, my weather-app is pretty useless, since it shows the temperature from six hours ago?
Or is there any chance to configure this behaviour?
Your log should definitely be in local time. See here: https://www.home-assistant.io/blog/2015/05/09/utc-time-zone-awareness/
Asia/Bangkok is a canonical time zone, so that’s good.
No the only configuration option you have is for the local time zone for the front end (all the stuff displayed to you).
Strange…
So it seems to be bug in this version of hass?
Only for you Mine has the correct UTC and local time.
The only thing I can suggest is to set another +7 time zone (e.g. Asia/Ho_Chi_Minh) and see if that fixes it.
You say the timezone setting in HA is correct. And you say the OS is showing the correct time. But is the OS showing the correct time because it is set to the correct time and its timezone setting is correct? Or could it be the OS’s timezone setting is incorrect, and the time setting is also incorrect to compensate for the wrong timezone setting?
Basically, you need to make sure the OS’s timezone setting is correct (and is the same as the timezone setting in HA.) Then, and only then, make sure the time is set correctly.
Timezone on the RPI is set correctly
pi@raspberrypi:~ $ sudo raspi-config
Current default time zone: ‘Asia/Bangkok’
Local time is now: Sun Sep 9 22:32:30 +07 2018.
Universal Time is now: Sun Sep 9 15:32:30 UTC 2018.
and /etc/timezone is set to Asia/Bangkok
Rpi no internal clock? Correct?
If the OS and HA both have the same, correct timezone set, and the time is set correctly in the OS, then the times should be shown correctly. If they aren’t, then either you have something entered incorrectly somewhere, or, well, I don’t know what to tell you.
I dug a little bit further and this behaviour only happens, if I start hass as a service via systemd:
sudo systemctl start home-assistant
If I start hass “normally”, like:
sudo /srv/homeassistant/bin/python3 /srv/homeassistant/bin/hass -c /home/homeassistant/.homeassistant
all times are correct, the log shows the local time and the weather app works also correctly.
Okay, finally, I found the error.
In the “home-assitant.service” file, the parameter
Environment was set to “TZ=Europe/London”. This now also explains the six hours difference instead of seven…
Wow, good find! Glad it’s working.
Where is the home-assistant.service file located? I’m having the same issue. I’ve searched around in the folders and can’t find it.
If you’re using systemd, then checkout Autostart using systemd.
Note that according to those instructions, the file would not have the timezone setting. Mine doesn’t.
Running Hassio 0.84.5, I am also a bit confused about time. Is it synced during the startup, as I understand RPI3 does not have an RTC built in.
The current system time is
But in HASSIO Logs, events are logged on a time almost 3 hours earlier
But when the startup complete , the time date sensor shows correct time, is it the internal HA time on Rpi3, or current world time synced via NTP.
Thanks.
Since you’re using hassio, not sure if you can do this, but if so, get to a command line prompt for your pi system. Then type this command:
timedatectl status
What do you get, especially for “Time zone”, “Network time on” & “NTP synchronized”? Also, are the “Local time” and “Universal time” correct?
Then check the time_zone setting in configuration.yaml. Does it agree with the timezone shown by the timedatectl command?
EDIT: Also, assuming you’re using systemd to automatically start HA, check the config file. In my case it’s /etc/systemd/system/[email protected]. Make sure there’s nothing in there changing the timezone.
This command not available in HassIO
Well, bottom line, you need to make sure that the timezone settings throughout your system all agree, and that the clock is set correctly.
I have been chasing this for a while on my forecast card… It’s 6 hours prior to current time. Exactly what my diff is from UTC (but doubled). All my time based automation start correctly… Any ideas are appreciated.
root@ham:/opt/homeassistant/config# cat …/hass.service
[Unit]
Description=Home Assistant
After=syslog.target network-online.target
[Service]
Type=simple
User=homeassistant
Environment=CONFIG_LOC=/opt/homeassistant/config
Environment=LOG_FILE=/opt/homeassistant/log/hass.log
ExecStart=/opt/homeassistant/bin/hass -c $CONFIG_LOC --log-file $LOG_FILE --log-no-color --log-rotate-days 7
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
root@ham:/opt/homeassistant/config# timedatectl status
Local time: Sat 2019-02-02 16:58:24 CST
Universal time: Sat 2019-02-02 22:58:24 UTC
RTC time: n/a
Time zone: America/Chicago (CST, -0600)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
root@ham:/opt/homeassistant/config# cat includes/hass.yaml
name: Wiesalani
latitude: xxxxxx
longitude: xxxxxx
elevation: 347
unit_system: imperial
customize: !include customize.yaml
auth_providers:
- type: homeassistant
- type: trusted_networks
I assume includes/hass.yaml is included from configuration.yaml for the basic homeassistant config, is that right? If so, I don’t see the time_zone configuration variable.