Timezone setting in AppDaemon

Could someone tell me how to set the timezone in AppDaemon please.

My default appdaemon.yaml looks like this:

secrets: /config/secrets.yaml
log:
  logfile: STDOUT
  errorfile: STDERR
appdaemon:
  threads: 10
  app_dir: /config/appdaemon/apps
  plugins:
    HASS:
      type: hass
      ha_url: http://hassio/homeassistant
      ha_key: xxxxxxxxxxxxxxxxxxxxxxx
hadashboard:
  dash_url: http://127.0.0.1:5050
  dash_dir: /config/appdaemon/dashboards

When created it did not pull the timezone across and I cannot find how to set it correctly.

The documentation here seems out of date https://github.com/home-assistant/home-assistant.io/blob/current/source/_docs/ecosystem/appdaemon/configuration.markdown

i havent heard any case where in hassio there is a need to set the timezone in AD.
AD gets it timezone from HA

i dont know if there is any special reason why it wouldnt work for you, but i would take it up in the hassio section.

the docs from AD can be found here:
https://appdaemon.readthedocs.io/en/dev/index.html

and in the configuration section you can find how to setup timezone from AD, when you want it to differ from HA or when there is a problem which delays the startup from HA and HA doesnt give the timezone to AD.
https://appdaemon.readthedocs.io/en/dev/INSTALL.html#configuration

@ReneTode, thanks for that. Is the AD log timestamp always in UTC?

I’m using Schedy and it is doing the scheduling in UTC rather than my local timezone and I am trying to work out whether it is a Hassio, AppDaemon, or Schedy issue :smile:.

I’m thinking it is Schedy as the time on an ADDashboard is correct.

you forget 2 options: home assistant and the AD addon.

the AD log is normally in local time.
if its not you should look in:

the devide operating system (hassio)
the program where AD gets its time (home assistant)
the wrapper around AD (the addon)

dashboard has a javascript clock, so that shows the time set on the device that shows the dashboard.
so that has nothing to do with the time in AD.

2 Likes

Rookie mistake. Fixed without hassle…

2 Likes

I’m running AD in docker and get wrong time … date outside docker shows correct time… how could i fix this? :slight_smile:

Have you matched the timezone for the docker container to your host?

If your host is Linux you can use this on the command line.

  -v /etc/localtime:/etc/localtime:ro

If not, you have to use an environment variable, which you will need to look up yourself.

2 Likes

Wich rookie mistake did you make? I have the same problem

Funnily enough I did it again with a fresh install and couldn’t remember (initially) :grinning:

Have you actually set the TZ in the UI under configuation > general?

It defaults to Europe on new installs.

If you are using an Appdaemon version 4.xx, you need to set the timezone now in the appdaemon.yaml file.

1 Like

Thanks for your reply! problem solved!

1 Like

I had some problems with setting up time_zone, elevation, lon & lat in combination with an own build docker image of appdaemon.

This helped me: https://appdaemon.readthedocs.io/en/latest/CONFIGURE.html#appdaemon-configuration

And perhaps for somebody useful, here my current config of my 'appdaemon.yaml ':

appdaemon:
  time_zone: Europe/Berlin
  latitude: 51.0000
  longitude: 11.11223
  elevation: 2
  plugins:
    HASS:
      type: hass
      ha_url: http://raspberrypi4:9272
      token: MY_SECRET_AKA_VERY_LONG_HA_TOKEN
http:
  url: http://raspberry:5050
admin:
api:
hadashboard:

Here my docker start command:

docker run --name=appdaemon -d -p 5050:5050 --restart=always -e HA_URL="http://raspberrypi4:9272" -e TOKEN="MY_SECRET_AKA_VERY_LONG_HA_TOKEN" -e DASH_URL="http://$HOSTNAME:5050" -v /etc/localtime:/etc/localtime:ro -v /home//pi/settings/homeassistant/appdaemon/:/conf appdaemon:latest
1 Like

For anyone still struggling with this - I think I’ve figured this out.
I narrowed the issue down to the appdaemon container - if I exec-ed into the container (with docker exec -it appdaemon sh) and used the date command to print the current datetime, it would print the wrong time (1 hour behind). That told me the issue was with the appdaemon container, not the homeassistant one.
The appdaemon container is based on the Alpine OS, which comes bundled with the tzdata package. It only needs to know your timezone to know the current local time. For that it looks for the TZ environment variable, or for /etc/timezone.
You have two options:

  1. either set the TZ environment variable, Europe/Paris and so on…
  2. or map the /etc/timezone file from the host to the appdaemon container with -v /etc/timezone:/etc/timezone:ro

Don’t bother about my reply till you’ve tried the solutions proposed above with the appdaemon.yaml file. My issue was that the time in the appdaemon container itself was incorrect.

Hope this helps.