#Strange Issue in Automation

1 messages · Page 1 of 1 (latest)

keen basin
#

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

vapid prairie
#

That's not a strange issue... it's the expected outcome when you just make things up.

First, the entity ID in the template needs to be in quotes, otherwise the template engine thinks it's a variable... but you haven't defined a value for that variable; which is what th error message is saying.

Second, to get the value of an attribute you need to use one of the functions that do that, such as state_attr() or is_atate_attr():

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

{{ is_state_attr('vacuum.robovac','mode','auto') }}