Error in listener function, any ideas. SOLVED

Hello, I am getting the following error from appdaemon, from the listen function I registered on a sensor from HA. Unfortunately I am not very knowledgable on python, so I don’t know how to approach this.

The error and some code snippets are below. I have commented out all code in the listener function except for a log message and still get the error. Any ideas?

Error:
2017-08-26 11:09:43.985940 WARNING ------------------------------------------------------------
2017-08-26 11:09:44.984754 WARNING ------------------------------------------------------------
2017-08-26 11:09:44.985906 WARNING Unexpected error in worker for App Porch Light:
2017-08-26 11:09:44.987402 WARNING Worker Ags: {‘id’: UUID(‘8504e907-4b25-4e9f-b3a8-2d55ff92fd34’), ‘old_state’: ‘MOTION’, ‘kwargs’: {}, ‘new_state’: ‘NOMOTION’, ‘name’: ‘Porch Light’, ‘entity’: ‘sensor.entry_pir’, ‘function’: ‘NOMOTION’, ‘attribute’: ‘state’, ‘type’: ‘attr’}
2017-08-26 11:09:44.988922 WARNING ------------------------------------------------------------
2017-08-26 11:09:44.991206 WARNING Traceback (most recent call last):
File “/usr/local/lib/python3.4/dist-packages/appdaemon/appdaemon.py”, line 525, in worker
ha.sanitize_state_kwargs(args[“kwargs”]))
TypeError: ‘str’ object is not callable

2017-08-26 11:09:44.992256 WARNING ------------------------------------------------------------

Code Snippet:

# Listeners
if "input_id" in self.args:
  self.listen_state(self.motion, self.args["input_id"])
  self.input_id = str(self.args["input_id"])
  self.log("Initing input_id: {}".format(self.input_id))
else:
  self.log("Input_id not detected.")

def motion(self, entity, attribute, old, new, kwargs):
  self.log("Motion changed")
#    self.log("Motion changed for entity: {}".format(self.entity_id))
#    self.log("Motion state changed from {}".format(old))
#    self.log("Motion state changed to {}".format(new))
#    if new == "MOTION":
#      if self.handle == None:
#        self.turn_on(self.entity_id)
#        self.log("First motion detected: i turned {} on, and did set timer".format(self.entity_id))
#      else:
#        self.log("First motion detected: i turned nothing on, but did set timer")
#        self.handle = self.run_in(self.light_off, delay)
#    else:
#      self.cancel_timer(self.handle)
#      self.handle = self.run_in(self.light_off, delay)
#      self.log("Motion detected again, i have reset the timer")

It’s complaining that your callback is a string instead of a function. I can’t see all your code but I think that somewhere you are assigning something to self.motion that is overriding the function def.

Thank you, thank you, thank you, I forgot I had self.motion set to somthing up top in my variables declaration. I forgot to delete that.

1 Like