Watchman Tracebacks: TypeError: 'NoneType' object is not iterable
kernelpanic85 opened this issue · 4 comments
kernelpanic85 commented
I've been getting the following Watchman errors in my logs running HA 2024.3.3 and Watchman 0.6.1.
Logger: homeassistant.helpers.event
Source: helpers/template.py:575
First occurred: April 3, 2024 at 6:45:24 PM (9 occurrences)
Last logged: April 4, 2024 at 11:00:23 PM
Error while processing template: Template<template=(<h3> Missing Services: {{ states.sensor.watchman_missing_services.state }} </h3> {%- for item in state_attr("sensor.watchman_missing_services", "services") %} <hr><table><tr> <td> <ha-icon icon='mdi:cloud-alert'></ha-icon> {{ item.id }} <a title="{{item.occurrences}}">{{item.occurrences.split('/')[-1]}}</a> </td></tr></table> {%- endfor %}) renders=18>
Error while processing template: Template<template=(<h3> Missing Services: {{ states.sensor.watchman_missing_services.state }} </h3> {%- for item in state_attr("sensor.watchman_missing_services", "services") %} <hr><table><tr> <td> <ha-icon icon='mdi:cloud-alert'></ha-icon> {{ item.id }} <a title="{{item.occurrences}}">{{item.occurrences.split('/')[-1]}}</a> </td></tr></table> {%- endfor %}) renders=22>
Error while processing template: Template<template=(<h3> Missing Services: {{ states.sensor.watchman_missing_services.state }} </h3> {%- for item in state_attr("sensor.watchman_missing_services", "services") %} <hr><table><tr> <td> <ha-icon icon='mdi:cloud-alert'></ha-icon> {{ item.id }} <a title="{{item.occurrences}}">{{item.occurrences.split('/')[-1]}}</a> </td></tr></table> {%- endfor %}) renders=26>
Error while processing template: Template<template=(<h3> Missing Services: {{ states.sensor.watchman_missing_services.state }} </h3> {%- for item in state_attr("sensor.watchman_missing_services", "services") %} <hr><table><tr> <td> <ha-icon icon='mdi:cloud-alert'></ha-icon> {{ item.id }} <a title="{{item.occurrences}}">{{item.occurrences.split('/')[-1]}}</a> </td></tr></table> {%- endfor %}) renders=30>
Error while processing template: Template<template=(<h3> Missing Services: {{ states.sensor.watchman_missing_services.state }} </h3> {%- for item in state_attr("sensor.watchman_missing_services", "services") %} <hr><table><tr> <td> <ha-icon icon='mdi:cloud-alert'></ha-icon> {{ item.id }} <a title="{{item.occurrences}}">{{item.occurrences.split('/')[-1]}}</a> </td></tr></table> {%- endfor %}) renders=34>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 573, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2364, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
TypeError: 'NoneType' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 699, in async_render_to_info
render_info._result = self.async_render(
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 575, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: 'NoneType' object is not iterable
ildar170975 commented
These errors seem to be related to a card you created.
kernelpanic85 commented
Thanks I am using the card config from the readme. The missing services sensor reads 0 right now, is it just that the card config needs to handle when the sensor is 0?
type: vertical-stack
cards:
- type: markdown
content: >-
<h2> <ha-icon icon='mdi:shield-half-full'></ha-icon> Watchman report</h2>
<h3>Missing Entities: {{ states.sensor.watchman_missing_entities.state }}
</h3> {%- for item in state_attr("sensor.watchman_missing_entities",
"entities") %} <hr> <table><tr> <td> <ha-icon icon='mdi: {%- if
item.state=="missing"-%}cloud-alert' {%- elif item.state=="unavail"
-%}cloud-off-outline' {%- else-%}cloud-question' {%- endif -%} ></ha-icon>
{{ item.id }} [{{item.state}}] <a title="{{item.occurrences}}">
{{item.occurrences.split('/')[-1].split(':')[0]}}</a> </td></tr></table>
{%- endfor %}
- type: markdown
content: >-
<h2 class="some"> <ha-icon icon='mdi:shield-half-full'></ha-icon> Watchman
report</h2> <h3> Missing Services: {{
states.sensor.watchman_missing_services.state }} </h3> {%- for item in
state_attr("sensor.watchman_missing_services", "services") %}
<hr><table><tr> <td> <ha-icon icon='mdi:cloud-alert'></ha-icon> {{
item.id }} <a
title="{{item.occurrences}}">{{item.occurrences.split('/')[-1].split(':')[0]}}</a>
</td></tr></table> {%- endfor %}
ildar170975 commented
In general, a code posted in Docs could be wrong/imperfect.
Suggest you to test a logic in Dev tools -> Template and add necessary changes.
kernelpanic85 commented
Thanks. I figured it out. Will make a PR to update the readme.