Device Status Value Comparison

How to make the following configuration in the automation trigger condition? The value of the “a” device state is greater than the value of the “b” device state (both are digital values), and the trigger is successful.

You probably want a numeric state trigger.

Can you explain in detail? Thanks!

https://www.home-assistant.io/docs/automation/trigger/#numeric-state-trigger

The problem is that I need to compare the state values of the two devices with each other

For example: my two device ids are “counter.hghc” and “input_number.hg”, how to rewrite them?

Yes. That is what I linked you to.

You did not mention counters before though. You can’t use those.

For that you would have to use a template trigger.

https://www.home-assistant.io/docs/automation/trigger/#template-trigger

Could you write the following:

{% if states('counter.hghc') > states('input_number.hg')  %}
true
{% else %}
false
{% endif %}

Like this:

value_template: "{{ states('counter.hghc')|float(0) > states('input_number.hg')|float(0) }}"

This will return true when the counter is greater than the input number, triggering the automation.

Please have a read of this: Templating - Home Assistant

Is this how it is used?

English only please. Also that is a wait template, not a trigger template.

Tom’s response is what you’re looking for.


As per the example, it does not execute. Maybe my settings are wrong?

Also you don’t include the “value_template” part or the quotes if using the UI editor. Just this:

{{ states('counter.hghc')|float(0) > states('input_number.hg')|float(0) }}

:pray:thank you very much! The execution was successful this time. :+1: