Repeat until does not stop when conditions met

Hello,

I’m trying to automate my covers. I have no sensors to measure the cover position. Instead, i want to use a timer script to simulate the position of the cover. I configuerd a input_number as sensor to simulate the position. I made a script that executes when a switch is pushed or activated with the cover buttons on the dashboard.

The function of the script is simple. When a relay is activated to open or close, the sensor will decrement or increment every 500milliseconds and this in a repeat untill loop. This works all fine but when the sensor reaches 0 or 100, the script does not go to the next line witch is to stop the cover.

When i check the trace of the script, the last line is not excecuted and if i check the information button on that page, the script is still running.

There are no logbookentries that indicate for an error.

What do i miss here ?

The script was made with the visual editor.

alias: Timing cover
sequence:
  - alias: Repeat until poscover  >99 of < 1
    repeat:
      sequence:
        - delay:
            hours: 0
            minutes: 0
            seconds: 0
            milliseconds: 500
        - alias: Increment bij relay2_2 on
          if:
            - condition: state
              entity_id: input_boolean.relay2_2
              state: "on"
          then:
            - service: input_number.increment
              target:
                entity_id:
                  - input_number.poscover
              data: {}
        - alias: Decrement bij relay2_1 on
          if:
            - condition: state
              entity_id: input_boolean.relay2_1
              state: "on"
          then:
            - service: input_number.decrement
              target:
                entity_id:
                  - input_number.poscover
              data: {}
      until:
        - condition: numeric_state
          entity_id: input_number.poscover
          above: 99
          below: 1
    enabled: true
  - service: cover.stop_cover
    metadata: {}
    data: {}
    target:
      entity_id: cover.cover_bedroom
mode: restart

You could just use this:

2 Likes

Ok, thanks. I"ll give it a try.

Hey, yes my integration should work. I have tested it on my blinds and it works fine. But if you found something just let me know. :slight_smile:

Looks like you got a different solution but for future reference the issue is with combining your numeric state conditions, which is treated like “and”. The value will never be both above 99 and below 1. You would need to separate those with an or condition.

2 Likes

Indeed that’s the problem, thanks for the info.

This integeration works fine with great options. Good job. I gonna use it.