How to collect a randomized list into a variable within a script?

I’m trying to create a script for randomized vacation lighting. I want to collect a list of lights, pick one random, set it to a random dim_level and turn it off after a random period. Keeping the same light within the variable throughout the script.

The "result_template gives me the “Property result_template is not allowed”. Can anyone see anything obvious here?


      # Select a random light entity
      - condition: template
        value_template: >
          {% set lights = ['light.bedroom_light', 'light.kitchen_light', 'light.living_room_light'] %}
          {{ lights | random }}
        result_template: "{{ item }}"
      # Set a random dim level for the selected light
      - service: light.turn_on
          entity_id: "{{ result }}"
          brightness_pct: "{{ 100 | random }}"
      # Set the light to turn off at a random time no shorter than 10 minutes and no longer than 60 minutes
      - delay:
        minutes: "{{ 10 | random(start=10, end=60) }}"
      - service: light.turn_off
          entity_id: "{{ result }}"
  mode: single

You can try this, it is working.

’ ’ ’
delay: “{{ ‘00:%02i:00’%range(10,59) | random }}”

’ ’ ’

The delay part seems to work. It’s the condition part that gives me problems. More specifically the result_template. This should be the right syntax for YAML, but there is obviously something that Home Assistant doesn’t like about it.