Ultrasonic automation

Hello, I want to automate a Lamp that turn on when the Ultrasonic Sensor is measuring a distance for 25 seconds under 30cm.

automation 1:
alias: Kaffe Licht einschalten wenn Tasse zu lange steht.
trigger:
platform: numeric_state
entity_id: sensor.ultrasonic_sensor_2
below: 0.30
for:
seconds: 25
action:
service: switch.turn_on
entity_id: light.kaffee_licht

automation 2:
alias: Kaffe Licht aus.
trigger:
platform: numeric_state
entity_id: sensor.ultrasonic_sensor_2
above: 1.2
action:
service: switch.turn_off
entity_id: light.kaffee_licht

Hi @Denis1!

Please format your YAML code according to the instructions at the top of the page. YAML is very sensitive to indentation, and we can’t see if you made a mistake if the code is not properly formatted.

Also, can you tell us a bit about what is or isn’t happening as you expect? Are you seeing any errors on the Info page or in home-assistant.log?