Home Assistant Switch ON TV & Decoder

Hi all,
I’m using these script and automations:

script:
  sequenza_on_tv:
    alias: "tv"
    sequence:
      - service: media_player.turn_on
        entity_id: media_player.oled_lg
      - service: media_player.turn_on
        entity_id: media_player.skyq_living_room

  sequenza_off_tv:
    alias: "tv"
    sequence:
      - service: media_player.turn_off
        entity_id: media_player.oled_lg
      - service: media_player.turn_off
        entity_id: media_player.skyq_living_room



automation:
- alias: "rileva TV ON"
  trigger:
    platform: state
    entity_id: media_player.oled_lg
    to: 'on'
  condition:
    condition: state
    entity_id: input_boolean.tv
    state: 'off'
  action:
    service: input_boolean.turn_on
    entity_id: input_boolean.tv
- alias: "rileva TV ON"



- alias: "rileva TV OFF"
  trigger:
    platform: state
    entity_id: media_player.oled_lg
    to: 'off'
  condition:
    condition: state
    entity_id: input_boolean.tv
    state: 'on'
  action:
    service: input_boolean.turn_off
    entity_id: input_boolean.tv

- alias: "tv"
  trigger:
    platform: state
    entity_id: input_boolean.tv
  condition: []
  action:
    service: script.turn_on
    data_template:
      entity_id: >
        {% if trigger.to_state.state == 'on' %}
        script.sequenza_on_tv
        {% elif trigger.to_state.state == 'off' %}
        script.sequenza_off_tv
        {% endif %}

And it works:
-If I use the input_boolean the tv and decoder switch on/off
-If I switch ON/OFF the tv by the remote controller the input_boolean change state
-If I switch ON/OFF the tv by the remote controller the decoder also switch ON/OFF

BUT sometime happens that the decoder turn off and on quckly when I watch TV… Only the decoder but not the TV. Infact the TV shows: “input not signal”

What could be the problem?