I’m getting the following error when an event scheduled with run_in tries to fire. Fair notice, this event has a several values being passed through kwargs.
2017-04-08 20:46:11.118393 WARNING ------------------------------------------------------------
2017-04-08 20:46:11.118971 WARNING Unexpected error during exec_schedule() for App: light_control
2017-04-08 20:46:11.119657 WARNING Args: {'name': 'light_control', 'type': None, 'offset': 0, 'basetime': 1491702372, 'id': UUID('8e010d93-ef24-420b-9571-6983c4ebfd6f'), 'callback': <bound method light_control.timer_handler of <light_control.light_control object at 0x70141e10>>, 'repeat': False, 'timestamp': 1491702372, 'interval': 0, 'kwargs': {'trigger': 'switch.master_toilet_light', 'entity': 'switch.master_toilet_fan', 'trigger_state': 'off', 'state': 'off'}}
2017-04-08 20:46:11.120115 WARNING ------------------------------------------------------------
2017-04-08 20:46:11.120780 WARNING Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py", line 391, in exec_schedule
"attribute": args["kwargs"]["attribute"],
KeyError: 'attribute'
2017-04-08 20:46:11.121223 WARNING ------------------------------------------------------------
2017-04-08 20:46:11.121988 WARNING Scheduler entry has been deleted
2017-04-08 20:46:11.122354 WARNING ------------------------------------------------------------
2017-04-08 20:28:17.128735 WARNING ------------------------------------------------------------
2017-04-08 20:28:17.129556 WARNING Scheduler entry has been deleted
2017-04-08 20:28:17.130086 WARNING ------------------------------------------------------------
Here is the calling section of code.
if onoff=="off":
self.log("turning off {} in {} seconds onoff={} trigger={} trigger_state={}".format(light,seconds,onoff,trigger,trigger_state))
self.run_in(self.timer_handler,seconds,entity=light,state=onoff,trigger=trigger,trigger_state=trigger_state)
elif onoff=="on":
self.log("turning on {} in {} seconds onoff={} trigger={} trigger_state={}".format(light,seconds,onoff,trigger,trigger_state))
self.run_in(self.timer_handler,seconds,entity=light,state=onoff,trigger=trigger,trigger_state=trigger_state)
else:
self.log("invalid value for on/off - {}".format(onoff))
Here is the callback function
def timer_handler(self,kwargs):
self.log("in timer_handler")
for a in kwargs:
self.log("{} = {}".format(a,kwargs[a]))
if "trigger" in kwargs:
if not kwargs["trigger_state"]==self.get_state(kwargs["trigger"],attribute="state"):
self.log("trigger {} state changed not turning {} {}".format(kwargs["trigger"],kwargs["light_entity"],kwargs["state"]))
return
if kwargs["state"]=="on":
self.turn_on(kwargs["light_entity"])
else:
self.turn_off(kwargs["light_entity"])
I never even get the “in timer_handler” log message so I don’t believe it’s getting into the handler.
Here is the message log
2017-04-08 20:45:41.790957 INFO light_control: set_light_state - (126) turning off switch.master_toilet_fan in 30 seconds onoff=off trigger=switch.master_toilet_light trigger_state=off
2017-04-08 20:46:11.121613 WARNING Logged an error to /home/homeassistant/appdaemon/appdaemon.err
Any ideas?