Trying to compare two sensor states for if_state

So I have a backup that posts it’s date time and state to my MQTT server.

The issue is that i want to add it to my TTS alerts, so that if it failed, it reads it out in the morning to me as part of my morning script.

I’ve also got the current date being pushed to my MQTT server as i couldn’t work out how to take “states.sensor.rsync_date.state” and drop any thing but the date ( it out puts 19/03 01:06, RSync OK )

So this returns true.

{{ states(‘sensor.rsync_date.state’) == states(‘sensor.date.state’) }}

but i want to do something like

{% if is_state(‘sensor.rsync_date.state’, ‘sensor.date.state’) %}
Backup was compeleted
{% else %}
Backup failed
{% endif %}

but this always returns the else statement, even when i change the comparison part to the same sensor as the input.

I’m using the templates tester part at the mo as it means i don’t have to restart HASS every change.

{% if states.sensor.rsync_date.state == states.sensor.date.state %} 

should do

1 Like

That worked perfectly !

How did u tell that it needed to be
states.tee.bla
and not
states(‘tee.bla’)

Pointing me to the manual is good as well.

I guess states() is also okay and maybe even better as it has some basic error handling.