Global vars from docs not working

my_global_var = conf.config[“AppDaemon”][“global_var”]
NameError: name ‘conf’ is not defined

appdaemon.yaml:

log:
logfile: STDOUT
errorfile: STDERR
appdaemon:
threads: 10
app_dir: /config/appdaemon/apps
plugins:
HASS:
type: hass
ha_url: http://hassio/homeassistant
token: 88cf6c9bd49c7204dc19b0b7025951a52f6951a8bfb6242c960715f9b73f1dbc
global_var: null
hadashboard:
dash_url: http://127.0.0.1:5050
dash_dir: /config/appdaemon/dashboards

You need to populate the variable with the contents using https://appdaemon.readthedocs.io/en/latest/HASS_API_REFERENCE.html?highlight=config#get-hass-config

what about this one from the example mode.py app:

File “/config/appdaemon/apps/modes.py”, line 35, in initialize
time = datetime.datetime.fromtimestamp(appdaemon.conf.now)
AttributeError: module ‘appdaemon’ has no attribute ‘conf’

please show yaml and logs and code as codeblocks, so its better readable.
the attributeerror is probably because there is an error in the example after a change from the appdaemon programm.

you probably can change the line to

time = datetime.datetime.fromtimestamp(self,datetime())

or

time = datetime.datetime.now()

the last one expects that the timezone from the system is the same as the timezone from appdaemon.

That’s what I ended up doing. ty. I’ll format next time.

self.time() gives the appdaemon time, which adjusts correctly as you use the time travel tool.