Compare Values of separate Helpers... Input_Select, etc?

I did at least 10 searches and read multiple docs pages, including this… Input select - Home Assistant

I did not find mention of how Input_Select values are stored, and/or how to compare them except for one post from 7 years ago! (see below).

Assuming they are strings and there is no associated numeric ‘slot’ or ‘option’ or ‘index’ value?

I dont see a way using Automation Editor UI to compare non-numeric values of any entity type so we must use templates?

Will a template like this do a String compare using this…

{{states(‘input_select.house_mode’) == states(‘input_select.house_mode_selector’)}}

or do I need this (only found 1 post from 7 yrs ago showing this!?)…

{{states(‘input_select.house_mode’ | string ) == states(‘input_select.house_mode_selector’ | string)}}

Why arent simple compare conditions and triggers built into the UI. Very frustrating that something this basic is left out and even the numeric comparisons in the UI is greatly lacking.

Yes.

Dunno where you found that, but taking an explicit string and applying the string filter to it would not make any difference whatsoever. So no definitely do not do that.

2 Likes

Very helpful, thank you for the quick reply!

According to the documentation for a State Condition:

Finally, the state option accepts helper entities (also known as input_* entities). The condition will pass if the state of the entity matches the state of the given helper entity.

Example in the docs:

conditions:
  - condition: state
    entity_id: alarm_control_panel.home
    state: input_select.guest_mode

For this particular case, you can create a State Condition in the Automation Editor in Visual mode.

I don’t have a screenshot handy but the resulting YAML would look like this:

conditions:
  - condition: state
    entity_id: input_select.house_mode
    state: input_select.house_mode_selector

@123 I was commenting on the UI not exposing basic evaluation methods… <>; >=, <=, ==

example: Entity_A <> Entity_B

HA can do these comparisons in templates but it should 100% be UI based (no need for templates) as this is super common trigger and condition for automation.

The example in your first post showed a template checking if one entity’s state is equal to another. That’s why I qualified my reply “for this particular case”.

The Numeric State Trigger Condition can handle less/greater than.

I dont see any way to create a state condition to test == or <> two helper entities values that are strings. Please provide a screenshot of this example, I could not figure out how to do it in the UI (without using a template).

thx for helping.

Please read the documentation link provided.

  1. I didnt ask about Numeric values, I asked about NON-Numeric values (strings).
  2. The visual editor does -not- do what I asked about, even for Numeric State Conditions. I have not see ANY way in the visual editor to do EntityA <> EntityB without a template.

If Im wrong, and I’d be happy to be wrong, please show an exact screenshot of comparing two separate entities’ values against each other.

The Automation Editor in Visual mode assumes the State field of a State Condition will contain the value of the selected entity.

However, as explained in the documentation, it’s not limited to a value but can also be the entity_id of an Input helper.

If you type an entity_id in the State field, the Automation Editor will accept it.

Is it self-evident? Not at all; the Automation Editor’s Visual mode doesn’t provide visual guidance for everything that’s documented. (Yet another reason why experienced users eventually outgrow it.)

As for “not equal to”, that’s not possible with only a State Condition. You would need to combine a State Condition with a Not “Building Block” as it’s called in the Automation Editor. The resulting YAML that’s produced looks like this:

  - condition: not
    conditions:
      - condition: state
        entity_id: input_boolean.foo1
        state: input_boolean.foo2

NOTE

RE: screenshots. I don’t currently have access to my laptop and posting screenshots from my phone is miserable.

Thank you. Def not obvious. Comparisons like that are very needed, very useful when doing workflows to check states of helpers. I hope they make the Visual Automation Editor more robust… YAML and template coding is suboptimal in many ways so the visual editor helps ensure we dont mess up YAML (syntax, spacing, etc). Unfortunate that HA did not embed a real scripting language like JS… people like me would post 98% fewer questions :wink: