Error returns

Could somebody help. Or is somebody with the same issue.
I’ve got an error for long time. It always return when I restart. But can’t place the error.

Logboekdetails ( ERROR )
Logger: homeassistant.core
First occured: 21:49:44 (1 occurences)
Last logged: 21:49:44

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 379, in async_trigger
    and not self._cond_func(variables)
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 551, in if_action
    return all(check(hass, variables) for check in checks)
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 551, in <genexpr>
    return all(check(hass, variables) for check in checks)
  File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 389, in template_if
    return async_template(hass, value_template, variables)
  File "/usr/src/homeassistant/homeassistant/helpers/condition.py", line 369, in async_template
    value = value_template.async_render(variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 221, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
TypeError: '>' not supported between instances of 'str' and 'int'

is this only when you restart ha?
if so you’re most likely testing the difference between 2 numbers, which fails because at start your entity has a state of unknown or unavailable (string) instead of a number (int)

You’re also possibly using states.domain.entity.state instead of states("domain.entity").
I’d recommend states("domain.entity") | int so that the error no longer shows up
Note that the |int will convert the unknown or unavailable state to 0…

Thanks for your reply. Unfortunately I don’t know where to look. I have not set anything else to compare anything with 2 numbers.

Is this something in my automations?

well it could be in many places depending on how keen you are with templates :slight_smile:
Check your automations, template sensors, template binary_sensors, template switches, …
if you use Notepad++, you can try ctrl+shift+f to search for text in any file.
Set your filters to *.yaml and the directory to your config folder:
image

Well, not found something that’s will be related to the error. But will checking further…

These were the hints when I searched.

Your unify automation. You’re comparing a string to a string yet expect them to be a number.
It’s no big deal as they’re only messages but they’re why you’re getting errors
Like I said earlier

And you’re comparing this number to a string (‘0’)

Paste this into the Template Editor to understand the differences in behavior:

{{ states('sensor.does_not_exist') }}
{{ states('sensor.does_not_exist') > '0' }}

{{ states('sensor.does_not_exist') | int }}
{{ states('sensor.does_not_exist') | int > 0 }}

In the first example, when the sensor doesn’t exist, the states function reports unknown. Notice that if you check if unknown is greater than the string '0' the result is True. That’s because it’s a string comparison.

In the second example, the int filter converts unknown to an integer 0. Now when 0 is checked if it is greater than 0 (numeric comparison) it reports False.

1 Like