Strange Issue in Automation

I am having a strange issue in an automation.

  • I have a vacuum robot named vacuum.robovac
  • I have a template condition in an automation {{ states(vacuum.robovac.mode) == "auto" }}
  • My vacuum.robovac has attributes as shown on screenshot.
  • When I run the automation, error messages are displayed in HA container and I need to manually restart the container.

I then tried debugging the issue by adding a persistent notification with {{ states(vacuum.robovac.mode) }} and it shows this error.

Clearly, the vacuum exists and is working

Use state_attr() to access an entity’s attributes, and you need quotes around the entity ID:

{{ state_attr("vacuum.robovac", "mode") == "auto" }}

See here: Working with states - Home Assistant

Also make sure the mode value is "auto" not "Auto": the test is case-sensitive.

2 Likes