TypeError: 'NoneType' object is not callable

I am getting the following errors very frequently with 0.38.4. Seems like it may have started after adding this in my config

  - platform: template
switches:
  climateaway:
    friendly_name: 'Climate Away / Home'
    value_template: "{{ states.climate.downstairs.attributes.away_mode == 'on' and states.climate.upstairs.attributes.away_mode == 'on' }}"
    turn_on:
      service: climate.set_away_mode
      entity_id:
        - climate.downstairs
        - climate.upstairs
      data:
        away_mode: true
    turn_off:
      service: climate.set_away_mode
      entity_id:
        - climate.downstairs
        - climate.upstairs
      data:
        away_mode: false

Any ideas on how to fix this? I’ve changed logging to be fatal only for now to stop the slowdowns I am seeing.

17-02-23 20:37:25 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback async_track_point_in_utc_time.<locals>.point_in_time_listener(<Event time_c....501454-06:00>) at /srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/event.py:108
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/events.py", line 120, in _run
self._callback(*self._args)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/event.py", line 124, in point_in_time_listener
hass.async_run_job(action, now)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 234, in async_run_job
target(*args)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/automation/state.py", line 78, in state_for_listener
async_remove_state_for_cancel()
TypeError: 'NoneType' object is not callable

On startup or recurring?

If it’s on startup, it’s because your sensor evaluates attributes before they’re valued/exist. You can wrap that value template in an “if” to prevent. If it’s recurring, not sure what the issue is.

Last night this was happening every 30 seconds and filling up my home assistant log. Let me look at this link and try it.

How would I wrap the following value template that has an and?

value_template: "{{ states.climate.downstairs.attributes.away_mode == 'on' and states.climate.upstairs.attributes.away_mode == 'on' }}"

Like this? Or somehow wrap both of the climate devices?

value_template: "{% if states.climate.state %}{{ states.climate.downstairs.attributes.away_mode == 'on' and states.climate.upstairs.attributes.away_mode == 'on' }}{% endif %}"

I believe you need an “and”. To make sure you catch both entities. But I don’t think that states.climate.state is right.You need to use the real entity_id’s. Find them on the states dev tab. Test your template with the template dev tab.

I updated my value template to this and it still works. However, I still have the original error. These are repeating errors and not just on startup.

"{{ is_state_attr('climate.downstairs', 'away_mode', 'on') and is_state_attr('climate.upstairs', 'away_mode', 'on') }}"

Any thoughts on how to wrap this in an “if”?

17-02-24 11:02:58 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback async_track_state_change.<locals>.state_change_listener(<Event state_...651431-06:00>>) at /srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/event.py:59
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/events.py", line 120, in _run
self._callback(*self._args)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/event.py", line 79, in state_change_listener
event.data.get('new_state'))
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 234, in async_run_job
target(*args)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/automation/state.py", line 87, in state_for_cancel_listener
async_remove_state_for_listener()
TypeError: 'NoneType' object is not callable

Refer to that thread I posted and get the correct entity_id’s.

The example from that thread:

value_template: '{% if states.remote.livingroom.state %}{{ states.remote.livingroom.attributes.current_activity }}{% endif %}'

I guess I just don’t understand fully what to change. I changed the value template to this but still receiving the errors. I’ll just disable error logging for now

value_template: "{% if states.climate.downstairs.attributes.away_mode and states.climate.upstairs.attributes.away_mode %}{{ is_state_attr('climate.downstairs', 'away_mode', 'on') and is_state_attr('climate.upstairs', 'away_mode', 'on') }}{% endif %}"

Right - you’re still using the attributes in your “if” - use the state

“{% if states.climate.downstairs.state and states.climate.upstairs.state %}{{ is_state_attr(‘climate.downstairs’, ‘away_mode’, ‘on’) and is_state_attr(‘climate.upstairs’, ‘away_mode’, ‘on’) }}{% endif %}”

1 Like

Thank you! Giving it a try now

This works great. Thanks for the help!

1 Like