On_value repeats constantly

I want to read in a value for 'deep sleep via mqtt, then set it and delete the topic. This value is set via an automation at a certain time.
My problem is that on_value is executed all the time (loop) and does not exit. Is there any way to solve this? Also the attempt to solve it via on_value_range does not work.

log:

[22:38:18][D][sensor:124]: 'Sleep time long': Sending state 1.00000 min with 0 decimals of accuracy
[22:38:18][V][mqtt:414]: Publish(topic='esp-dht11-01/sensor/sleep_time_long/state' payload='1' retain=1)
[22:38:18][V][sensor:074]: 'Sleep time long': Received new state 1.000000
[22:38:18][D][sensor:124]: 'Sleep time long': Sending state 1.00000 min with 0 decimals of accuracy
[22:38:18][V][mqtt:414]: Publish(topic='esp-dht11-01/sensor/sleep_time_long/state' payload='1' retain=1)
[22:38:18][V][sensor:074]: 'Sleep time long': Received new state 1.000000
... ...

esphome:

sensor:
  - platform: mqtt_subscribe
    name: "Sleep time long"
    id: sleep_time_long
    unit_of_measurement: min
    accuracy_decimals: 0
    topic: esp-dht11-01/sensor/sleep_time_long/state
    on_value_range:
      - above: 0
        then:
         - logger.log: "neue sleep_time_long!"
         - mqtt.publish:
              topic: esp-dht11-01/sensor/sleep_time_long/state
              retain: true
              payload: ""
         - delay: 1s
         - lambda: |-
            id(this_deep_sleep).set_sleep_duration(id(sleep_time_long).state * 1000 * 60);

Try on_value as the trigger with an if condition to check if your value is above 0.

On value should only trigger when a value is received.

I have tried several variations and am now pretty sure that it does not recognize the value as INT. Therefore the condition does not work. For payload: '' the topic is not deleted, but described with nan, which I also cannot query.

sensor:
  - platform: mqtt_subscribe
    name: "Sleep time long"
    id: sleep_time_long
    unit_of_measurement: min
    accuracy_decimals: 0
    topic: esp-dht11-01/sensor/sleep_time_long/state
    on_value:
      if:
        condition:
          lambda: 'return id(sleep_time_long).state != 0;'
        then:
          - logger.log: "new sleep-long"
          - lambda: |-
             id(this_deep_sleep).set_sleep_duration(id(sleep_time_long).state * 1000 * 60);
          - mqtt.publish:
              topic: esp-dht11-01/sensor/sleep_time_long/state
              payload: '0'
              retain: true