I have added a couple of new functions to run a block of code at sunrise and sunset and for some reason, it’s failing with the following error. Am I missing something here?
Error:
2017-12-21 07:16:23.328100 WARNING Unexpected error in worker for App sunset_lights_2:
2017-12-21 07:16:23.334834 WARNING Unexpected error in worker for App sunset_lights_1:
2017-12-21 07:16:23.335374 WARNING Unexpected error in worker for App sunset_lights_3:
2017-12-21 07:16:23.341853 WARNING Worker Ags: {'name': 'sunset_lights_2', 'function': <bound method TurnOnLightsAtSunset.sunrise_cb of <sunsetlights.TurnOnLightsAtSunset object at 0x75ad7$
2017-12-21 07:16:23.344975 WARNING Worker Ags: {'name': 'sunset_lights_1', 'function': <bound method TurnOnLightsAtSunset.sunrise_cb of <sunsetlights.TurnOnLightsAtSunset object at 0x75a06$
2017-12-21 07:16:23.345651 WARNING Worker Ags: {'name': 'sunset_lights_3', 'function': <bound method TurnOnLightsAtSunset.sunrise_cb of <sunsetlights.TurnOnLightsAtSunset object at 0x75ad7$
2017-12-21 07:16:23.346110 WARNING ------------------------------------------------------------
2017-12-21 07:16:23.346488 WARNING ------------------------------------------------------------
2017-12-21 07:16:23.346908 WARNING ------------------------------------------------------------
2017-12-21 07:16:23.364073 WARNING Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 505, in worker
function(utils.sanitize_timer_kwargs(args["kwargs"]))
File "/home/homeassistant/.homeassistant/config/apps/sunsetlights.py", line 96, in sunrise_cb
self.log("Sunrise Triggered")
File "/usr/local/lib/python3.4/dist-packages/appdaemon/appapi.py", line 87, in log
msg = self._sub_stack(msg)
File "/usr/local/lib/python3.4/dist-packages/appdaemon/appapi.py", line 66, in _sub_stack
stack = inspect.stack()
File "/usr/lib/python3.4/inspect.py", line 1342, in stack
return getouterframes(sys._getframe(1), context)
File "/usr/lib/python3.4/inspect.py", line 1321, in getouterframes
framelist.append((frame,) + getframeinfo(frame, context))
File "/usr/lib/python3.4/inspect.py", line 1296, in getframeinfo
lines, lnum = findsource(frame)
File "/usr/lib/python3.4/inspect.py", line 709, in findsource
if pat.match(lines[lnum]): break
IndexError: list index out of range
Code (inside initialize):
# Run at sunrise
self.run_at_sunrise(self.sunrise_cb)
# Run at sunset
self.run_at_sunset(self.sunset_cb)
def sunrise_cb(self, kwargs):
self.log("Sunrise Triggered")
dh_trigger = self.get_state("input_boolean.ad_dark_house_lights")
self.log("Current ad_dark_house_lights trigger status = {}".format(self.dh_trigger))
if dh_trigger == "off":
self.turn_on("input_boolean.ad_dark_house_lights")
msg = "Good morning. AppDaemon dark house flag turned ON at sunrise\n"
self.log(msg)
self.set_state("sensor.appd_notify_message", state=msg, attributes={"ifttt":False, "frontend":True, "announce":False})