Error in repeat script

Hello everyone. Could someone tell me what the error is? I need that sequence to repeat until the home theater is on. The problem is that sometimes I have to send the script several times. Thank you

  bdv_n9200w_on_off:
    - repeat:      
      until: "{{ is_state('media_player.bdv_n9200w', 'playing') }}"
      sequence: 
      - service: remote.send_command
        target:
          entity_id: remote.broadlink_m3_comedor
        data:
          command: b64:JgDsAE4VJBYVEyYVERUnFRMUExQSFBI+ERYmFhEXJRUSAALFThsgFRIWJxMVFCUhCRESFxEXEBQTFxAZIxURFSQYEgACxk8UJhUTFCgTEhYnExIWEhQTFREWDxgTFCYVEhohFxAAAs9MGiMTFBYnFBEWJRcRFhEVEhUTFxAUEhUnFQ8XJxURAALPTxUmFBMUJhUSGSMVExQSFhMdCRURFxAYIhgSFCYWEgACzU8VJRwKGCIYEBglFRIXEBUTFBMWEBYSFyMVExUmGA8AAs9PFCYVEhQlGw8TJRcTFhEUFBMTFRIVExYkFxEUJhURAA0FAAAAAAAAAAAAAAAA

I would imagine that there must be a delay between sending the IR command and the media player showing the state of ‘playing’ so maybe its firing multiple IR commands, maybe put a delay in to allow for this?

The problem is that sometimes it works when I send the command and sometimes it works when I try again

That’s kind of my point, if f I assume correctly that you are sending a power toggle command via IR as apposed to a dedicated power on IR command then the risk here is you are firing constantly the equivalent on, off, on, off, on, off and without a delay you run the risk of it not working as expected.

However if you were to look at the delay between sending the power command and the actual media player showing the state of playing and then add this delay to the repeat then you stand more chance of only ever sending the power command when it’s actually off to start with.

Exact. The best thing that could happen is that send wait a second to verify and then send the command again. The Home theater sometimes responds on the first send and in others I have to try one or two more times. This only happens to me with this device and not with the tv. I would also like to be sure that the ignition was achieved

I keep trying and can’t get it to work. I need to make sure that home has been turned on and if not, keep trying. Does anyone know what the error could be with this? Thank you

script:
  samsung_tv_on_off:
    - wait_template: "{{ is_state('media_player.bdv_n9200w', 'playing') }}"
      timeout: 10
      continue_on_timeout: false  
    - sequence:
      - service: remote.send_command
        target:
          entity_id: remote.broadlink_m3_comedor
        data:
          command: b64:JgDsAE4VJBYVEyYVERUnFRMUExQSFBI+ERYmFhEXJRUSAALFThsgFRIWJxMVFCUhCRESFxEXEBQTFxAZIxURFSQYEgACxk8UJhUTFCgTEhYnExIWEhQTFREWDxgTFCYVEhohFxAAAs9MGiMTFBYnFBEWJRcRFhEVEhUTFxAUEhUnFQ8XJxURAALPTxUmFBMUJhUSGSMVExQSFhMdCRURFxAYIhgSFCYWEgACzU8VJRwKGCIYEBglFRIXEBUTFBMWEBYSFyMVExUmGA8AAs9PFCYVEhQlGw8TJRcTFhEUFBMTFRIVExYkFxEUJhURAA0FAAAAAAAAAAAAAAAA
      - wait_for_trigger:
          - platform: state
            entity_id: media_player.bdv_n9200w
            to: "playing"
            for: 2
        timeout: "{{ wait.remaining }}"
        continue_on_timeout: false