No enitie value during start

I have the following problem that some values ​​of the entities are not available during startup.
This has two problems:

  • There is an error message in the log
  • and the more important thing is that it causes jumps in the histories.

I tried two approaches and failed:

{% if states('sensor.1')  != 'unknown' %}
#or this condition
{% if states('sensor.1')}

{{ (states('sensor.1') * states('sensor.2}}
{% else %}

# With and Without this line
{{ (states('sensor.enitie') }} #this is the target enite of this template.
{% endif %}

The error in all variants above are that the values are empty or wrong about that the values during the start are not available.

Is there a way to only run the helper only when everything is loaded? Or to query the template to retain the original value if values ​​are missing (unknown, unavailable)?

BR
Bernd
(This is my first post, please be patient)

Yes there is. Use an availability template. It is evaluated before the state template.

Share your actual config if you want help with this.

1 Like

@tom_l thanks for your quick response. Where can I find this template? I can’t find is in a add helper or anywhere.

Thank
Bernd

It is part of the template sensor yaml config.

1 Like

Your YAML template entity needs an availability template that tests if the entities you use in the value template have values has_value(...).

Template entities created via the UI don’t have that ability, unfortunately.

1 Like
1 Like