How to compare a input counter state with a input number in a blueprint?

Hello everyone.

I’m trying to configure a new Blueprint to set actions when pressing a Philips Hue controller.

I’m facing a knowledge gap in here. My goal is be able to receive as input and counter and a number and in the actions compare the “state” of the counter (0, 1, 2…) with the received number (like a index number).

Blueprint:

blueprint:
  domain: automation

  name: Some action

  input:
    clickCounter:
      name: Click Counter
      selector:
        entity:
          filter:
            domain: counter

    scene_index:
      name: Scene Index (in Click Counter)
      selector:
        number:
          min: 0
          max: 10
          mode: box
          unit_of_measurement: index

triggers:
  # ...

actions:
  # - variables:
  #     selected_mode_var: !input scene_index

  - if:
      - condition: state
        entity_id: !input clickCounter
        state: !input scene_index
       # THIS VALIDATION IS WHAT I'M TRYING TO SOLVE
       # this not work, I've also tried with variable and template, but so far I wasn't able to figure it out

    then:
      # do something
      - stop: Nothing to do

I out of ideas in how to compare the counter with the number.
Could someone help me? Thanks a lot!

States are always strings, the number selector returns a number… you need to use templating to convert a number to a string, so you will need to define script variables for both inputs and use a Template condition.

blueprint:
  domain: automation
  name: Some action
  input:
    click_counter:
      name: Click Counter
      selector:
        entity:
          filter:
            domain: counter
    scene_index:
      name: Scene Index (in Click Counter)
      default: 0
      selector:
        number:
          min: 0
          max: 10
          mode: box

triggers:
  # ...
actions:
  - variables:
      counter_ent: !input click_counter
      index_num: !input scene_index
  - if:
      - condition: template
        value_template: "{{ is_state(counter_ent, index_num | string) }}"
    then:
      # do something
      - stop: Nothing to do
1 Like

WOW!

It works! Thanks a lot bro!
You were spot on.