ESP Home: on_value_range - error: unable to find action

Dear all,

I have an issue with ESP Home and I am somehow unable to find the issue:
Idea is that based on a sensor value a different text is displayed. Hiere is my approach:

text_sensor:
  - platform: template
    name: "Car status"
    id: template_text
    
sensor:
  - platform:           adc
    pin:                GPIO17                  # A0
    icon:               "mdi:arrow-up-down-bold-outline"
    name:               "Position"
    unit_of_measurement: "%"
    update_interval:    1s
    on_value_range:          
      - below: 0.20
        id: template_text
        then:
          - text_sensor.template.publish:
            id:     "template_text"
            state:  "State A"
      - above: 0.20001
        below: 1.80
        then:
          - text_sensor.template.publish:
            id:     "template_text"
            state:  "State B"

I receive the following error during compilation:

INFO ESPHome 2024.7.3
INFO Reading configuration esp_garageControl.yaml...
Failed config

sensor.adc: [source esp_garageControl.yaml:57]
  platform: adc
  pin: GPIO17
  icon: mdi:arrow-up-down-bold-outline
  name: Position
  unit_of_measurement: %
  update_interval: 1s
  on_value_range:
    -
      Unable to find action with the name 'below'.
      below: 0.2
      id: template_text
      then:
        - text_sensor.template.publish:
          id: template_text

Any ideas?

Thanks a lot for your support!

Not sure id: template_text is valid line here. Try to remove it.

Try indenting in the ID and state



    on_value_range:          
      - below: 0.20
        id: template_text
        then:
          - text_sensor.template.publish:
              id:     "template_text"
              state:  "State A"

Thank you so much… There were still two error in the code (id at the wrong position nd intending)…

Now it is working as expected…

No problem, ESPHome is a bit particular about indentation, always worth checking documentation when compile issue’s arise.

Can you mark my post as solving your issue then others know.

Have fun