Sub state image

Hi to all, i want to set background picture with a random Number but some doesn’t work.
The random function work good.
I use 2 differenti ways but some was wrong

entity: input_boolean.natale
state_image:
  'on': local/Natale_2022.jpg
  'off':
    entity: sensor.random_sensor
    state_image:
      '1': local/1.jpg
      '2': local/2.jpg
      '3': local/3.jpg
      '4': local/4.jpg
      '5': local/5.jpg
      '6': local/6.jpg
entity: input_boolean.natale
state_image:
  'on': local/Natale_2022.jpg
  'off': local/sensor.random_sensor.jpg