prefixkit Ask an engineerAsk Support RU

Error reference · Home Assistant

Home Assistant: Template variable warning: 'dict object' has no attribute 'to_state' when rendering '{{…

Template variable warning: 'dict object' has no attribute 'to_state' when rendering '{{ trigger.to_state.state }}'

What it means

A template used a variable or attribute that does not exist at that moment, and rendered it as empty.

Why it happens

  • The automation was run by hand (Run actions) or by another trigger type, so trigger.to_state does not exist.
  • A typo in an attribute name, or the entity has no such attribute.
  • The entity is unavailable and has no attributes yet.

How to fix it

  1. Guard the template: {{ trigger.to_state.state if trigger.to_state is defined else "" }}.
  2. Check the attribute names in Developer tools → States.
  3. Test the template in Developer tools → Template.

Useful tools

/home-assistant-yaml-checker/

Other Home Assistant errors

Idea?