Errors on logfile

Do I have to take care of errors in the log file if everything is working ?

for example

ValueError: Template error: int got invalid input ‘unknown’ when rendering template ‘{{ ‘yellow’ if states(“sensor.energy_socket_5c2faf0313f6_active_power”) | int > 2 else [36,36,36] }}’ but no default was specified
homeassistant.exceptions.TemplateError: ValueError: Template error: int got invalid input ‘unknown’ when rendering template ‘{{ “mdi:dishwasher-alert” if states(“sensor.energy_socket_5c2faf0313f6_active_power”) | int > 2 else “mdi:dishwasher” }}’ but no default was specified

2024-01-08 16:51:22.492 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({{ states(‘sensor.indoor_temperature’) | round(1) }} °C) renders=2>
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/template.py”, line 1646, in forgiving_round
value = round(float(value), precision)
^^^^^^^^^^^^
ValueError: could not convert string to float: ‘unknown’

What is wrong here ?

Yes, you should.

You should always supply a default value for your float and int filters in case the entity is not available.

e.g.

{{ ‘yellow’ if states(“sensor.energy_socket_5c2faf0313f6_active_power”) | int(0) > 2 else [36,36,36] }} 

That example does not have the correct type of quotes because you did not format the error message for the forum and I can’t be bothered changing the fancy quotes. The important thing is the int(0) bit.

I did not know the log file had to be in preformatted text… What does the int(0) do ? Because i dont know

The 0 is what the filter will return if it cant convert a string to a number. e.g. if the state is unknown or unavailable.