After months of smooth operation, one of my apps that uses run_at_sunset() failed to initialize. After restarting, it no longer gets the error so maybe it’s not a serious defect but I thought I’d report it in case it needs some visibility.
Here is the app:
import appdaemon.plugins.hass.hassapi as hass
import datetime
class Curio_cabinet_light(hass.Hass):
def initialize(self):
# Configure a callback that occurs at sunset every day
self.run_at_sunset(self.light_on)
# Schedule a daily callback that will call run_daily() at 10pm every night
self.run_daily(self.light_off, datetime.time(22, 00, 0))
def light_on(self, kwargs):
self.turn_on('light.dining_room_curio_cabinet_light')
def light_off(self, kwargs):
self.turn_off('light.dining_room_curio_cabinet_light')
and the error that was reported:
2018-06-27 11:48:26.081490 WARNING AppDaemon: ------------------------------------------------------------
2018-06-27 11:48:26.111515 WARNING AppDaemon: Unexpected error running initialize() for curio
2018-06-27 11:48:26.112866 WARNING AppDaemon: ------------------------------------------------------------
2018-06-27 11:48:26.149841 WARNING AppDaemon: Traceback (most recent call last):
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 1575, in init_object
init()
File "/home/homeassistant/.appdaemon/apps/curio.py", line 8, in initialize
self.run_at_sunset(self.light_on)
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appapi.py", line 420, in run_at_sunset
handle = self._schedule_sun(name, "next_setting", callback, **kwargs)
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appapi.py", line 406, in _schedule_sun
event = self.calc_sun(type_)
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appapi.py", line 247, in calc_sun
return self.AD.calc_sun(type_)
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 892, in calc_sun
return self.sun[type_].timestamp()
KeyError: 'next_setting'
2018-06-27 11:48:26.151021 WARNING AppDaemon: ------------------------------------------------------------
2018-06-27 11:48:26.230734 WARNING AppDaemon: ------------------------------------------------------------
2018-06-27 11:48:26.231197 WARNING AppDaemon: Unexpected error running initialize() for blah
2018-06-27 11:48:26.231551 WARNING AppDaemon: ------------------------------------------------------------
2018-06-27 11:48:26.244763 WARNING AppDaemon: Traceback (most recent call last):
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 1575, in init_object
init()
File "/home/homeassistant/.appdaemon/apps/sun.py", line 38, in initialize
self.run_at_sunset(self.sunset, offset = 15*60)
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appapi.py", line 420, in run_at_sunset
handle = self._schedule_sun(name, "next_setting", callback, **kwargs)
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appapi.py", line 406, in _schedule_sun
event = self.calc_sun(type_)
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appapi.py", line 247, in calc_sun
return self.AD.calc_sun(type_)
File "/srv/appdaemon/lib/python3.5/site-packages/appdaemon/appdaemon.py", line 892, in calc_sun
return self.sun[type_].timestamp()
KeyError: 'next_setting'
2018-06-27 11:48:26.245392 WARNING AppDaemon: ------------------------------------------------------------