Retry failed restful command

Hi: my restful command sometimes timeout and would like to implement a retry, I have tried the below syntax but didn’t get it to work. My question is how to in the repeat loop to check if the previous response is not None (timeout) or status is not 200. Am I doing it wrong?

        - variables:
            response: null
        - repeat:
            until:
              - condition: template
                value_template: >
                  {{ (response is not none and response['status'] == 200) or repeat.index == 3 }}
            sequence:
              - service: rest_command.kitchen_camera_surveillance_mode
                response_variable: response
              - delay: "00:00:01"```