Appdaemon errors on cold system boot

Hi,

Error below started occuring last few months possibly as a result of upgrading HA or AD and only occurs after a complete system reboot, get around the problem by restarting appdaemon after HA is fully up, suspect it’s attempting to calcuate on data that isn’t available during the init. of HA.
System is running Raspian and with current versions of all.
The code is part of the def initialize section of an app:
self.run_at_sunset(self.lightsonfront,offset = 60* 60) #turn on front lights 60minutes after sunset

Probably could get around the problem by delaying the instruction execution…just thought I’d raise the issue first!

2019-01-20 15:16:35.234625 WARNING AppDaemon: ------------------------------------------------------------
2019-01-20 15:16:35.235848 WARNING AppDaemon: Unexpected error running initialize() for outside_light
2019-01-20 15:16:35.236964 WARNING AppDaemon: ------------------------------------------------------------
2019-01-20 15:16:35.247787 WARNING AppDaemon: Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py”, line 1581, in init_object
init()
File “/home/pi/appdaemon/conf/apps/outside_lights.py”, line 17, in initialize
self.run_at_sunset(self.lightsonfront,offset = 60* 60) #turn on front lights 60minutes after sunset
File “/usr/local/lib/python3.5/dist-packages/appdaemon/appapi.py”, line 434, in run_at_sunset
handle = self.schedule_sun(name, “next_setting”, callback, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/appdaemon/appapi.py”, line 420, in schedule_sun
event = self.calc_sun(type
)
File “/usr/local/lib/python3.5/dist-packages/appdaemon/appapi.py”, line 261, in calc_sun
return self.AD.calc_sun(type
)
File “/usr/local/lib/python3.5/dist-packages/appdaemon/appdaemon.py”, line 897, in calc_sun
return self.sun[type_].timestamp()
KeyError: ‘next_setting’

2019-01-20 15:16:35.249229 WARNING AppDaemon: ------------------------------------------------------------

Thanks,

Rob.

its a known problem that parts of HA are not up and running when HA gives the signal to AD (and other programs) that its up and running.

HA gives the signal its there, when the core is up, but at that point it isnt finished loading the components.
its the only signal that AD can use.
in the next release we dont rely on time data from HA anymore. (timezone, etc. need to be given in appdaemon.yml)

at this point you can create delays or try if setting timezone, elevation, latitude and longtitude in appdaemon.yaml will take care of your problem.

Thanks Rene,

Makes sense, especially with the newer versions of HA they definetely take a lot longer to fire up.

Rob.

1 Like