Text sensor from two binary sensor. What's needed here?

I have two binary sensors that track another sensor’s trend:

binary_sensor.balance_pump_rate_rising
binary_sensor.balace_pump_rate_falling

I need to create a sensor that shows the trend as text:

IF binary_sensor.balance_pump_rate_rising
“Rising”
IF binary_sensor.balace_pump_rate_falling
“Falling”
IF NOT binary_sensor.balance_pump_rate_rising AND NOT binary_sensor.balance_pump_rate_falling
“Steady”
ELSE
“Unknown”

So far, I have:

        {% if (states.binary_sensor.balance_pump_rate_falling) %}
          Falling
        {% elif (states.binary_sensor.balance_pump_rate_rising) %}
          Rising
        {% else %}
          Steady
        {% endif %}

However, in Dev tools it says “This template does not listen for any events and will not update automatically”.

I confess to being lost!

Any ideas that’ll point me in the right direction?

Like this:

        {% if is_state('binary_sensor.balance_pump_rate_falling', 'on') %}
          Falling
        {% elif is_state('binary_sensor.balance_pump_rate_rising', 'on') %}
...etc

Thank you, Tom.

I’ve changed to using input_booleans to test, and now have this:

        {% if is_state('input_boolean.falling_trend', 'on') ++ is_state('input_boolean.rising_trend', 'off') %}
          Falling
        {% elif is_state('input_boolean.rising_trend', 'off') ++ is_state('input_boolean.rising_trend', 'on') %}
          Rising
        {% elif is_state('input_boolean.falling_trend', 'off') ++ is_state('input_boolean.falling_trend', 'off') %}
          Steady
        {% elif is_state('input_boolean.rising_trend', 'on') ++ is_state('input_boolean.falling_trend', 'on') %}
          Undetermined
        {% else %}
          Unknown
        {% endif %}

This should, to my mind, cover all four possible combinations but only works as an either or.

I think it’s just my syntax though.

Change ++ to and

Brilliant!

Thank you.

1 Like