Variable Condition Variable Range

Is my_range only a constant?
2024

# in a trigger:
on_...:
  if:
    condition:
      number.in_range:
        id: my_number
        above: my_range        # Is this really limited to a constant ??
    then:
      - script.execute: my_script

I can’t wrap my head around that.

Is this really only a lambda thing? If so anyone know why the limitation?

If you look closely most configuration option in ESPHome (and Home Assistant for that matter) are set once and once only. They do not take variables.

Having said that in your case it is easy to solve. Use a lambda condition.

Oh I looked closely for hours and hours.

This is an example using the lambda. In hopes someone can use it.

# Optical Sensor
  - platform: gpio
    pin:
      number: D7 #GPIO13
      mode: INPUT_PULLUP
      inverted: True
    name: InPlace    
    filters:
      - delayed_off: 20ms
    on_press:
      then:
        - number.increment:
            id: current_number
            cycle: false
        - number.increment:
            id: total_done
            cycle: false
        -  if:
            condition:
              lambda: 'return id(current_number).state = id(amount_to_send);'
            then:
              - logger.log:
                  format: "sensor reports value current_number = %.1f and amount_to_send = %.1f"
                  args: [ 'id(current_number).state', 'id(amount_to_send).state' ]

              - switch.turn_off: the_switch 
            else:
              - logger.log: "Not Done Yet"

Yeah they’ve recently stuffed up the documentation.

The section called “All Conditions” no longer lists all conditions. There’s a “Common Conditions” list as well. Same for the actions lists. Bloody stupid.