Error doing job: Exception in callback : TypeError: is_state() missing 1 required positional argument: 'state'

I have a lot of these issues in the log.
I am not able to understand what it is the template that causes this issue.

2019-12-16 19:58:36 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <function async_track_state_change.<locals>.state_change_listener at 0x730fad68>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 70, in uvloop.loop.Handle._run
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 104, in state_change_listener
    event.data.get("new_state"),
  File "/usr/src/homeassistant/homeassistant/core.py", line 371, in async_run_job
    target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/binary_sensor.py", line 182, in template_bsensor_state_listener
    self.async_check_state()
  File "/usr/src/homeassistant/homeassistant/components/template/binary_sensor.py", line 305, in async_check_state
    state = self._async_render()
  File "/usr/src/homeassistant/homeassistant/components/template/binary_sensor.py", line 244, in _async_render
    state = self._template.async_render().lower() == "true"
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 220, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 3, in top-level template code
  File "/usr/local/lib/python3.7/site-packages/jinja2/sandbox.py", line 440, in call
    return __context.call(__obj, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 980, in wrapper
    return func(hass, *args[1:], **kwargs)
TypeError: is_state() missing 1 required positional argument: 'state'

Well, to start, it would be a template that contains a call to the is_state() function that only supplies one argument.

Thanks for the feedback.
/usr/src/homeassistant/homeassistant/components/template/binary_sensor.py
Maybe can it be a binary_sensor?

The problem is in one of your configuration YAML files. Look in those files for a template that contains a call to the is_state() function and that only contains one argument in that call.

Finally I found the issue.
I was missing a , in a template:

is_state('binary_sensor.xxxxxxxx' 'on')

2 Likes

Thanks for this… After several hours of frustration finding this post led to discovering not 1, but 2, missing commas… out of 16 intended to be identical statements.

Don’t you wish code was sometimes like… ahhh, close enough?