bedtime:
  alias: Bedtime
  sequence:
    - delay: '00:{{ (range(8, 13) | random) }}:00'
    - service: light.turn_off
      data:
        entity_id:
          - group.kitchen_lights
          - group.living_room_lights
    - delay: '00:{{ (range(25, 36) | random) }}:00'
    - service: light.turn_off
      data:
        entity_id: group.hall_lights

occupancy_simulation_start:
  alias: Occupancy Simulation Start
  sequence:
    - service: scene.turn_on
      data_template:
        entity_id: 'scene.occupancy_simulation_{{ (range(1, 4) | random) }}'
    - service: script.turn_on
      data:
        entity_id: script.occupancy_simulation_loop

occupancy_simulation_stop:
  alias: Occupancy Simulation Stop
  sequence:
    - service: script.turn_off
      data:
        entity_id: script.occupancy_simulation_loop

occupancy_simulation_loop:
  alias: Occupancy Simulation Loop
  sequence:
    - delay: '00:00:{{ (range(20, 41) | random) }}'
    - service: script.turn_on
      data:
        entity_id: script.occupancy_simulation_start

bedtime:
  alias: Bedtime
  sequence:
    - delay: '00:{{ (range(8, 13) | random) }}:00'
    - service: light.turn_off
      data:
        entity_id:
          - group.kitchen_lights
          - group.living_room_lights
    - delay: '00:{{ (range(25, 36) | random) }}:00'
    - service: light.turn_off
      data:
        entity_id: group.hall_lights

occupancy_simulation_start:
  alias: Occupancy Simulation Start
  sequence:
    - service: scene.turn_on
      data_template:
        entity_id: 'scene.occupancy_simulation_{{ (range(1, 4) | random) }}'
    - service: script.turn_on
      data:
        entity_id: script.occupancy_simulation_loop

occupancy_simulation_stop:
  alias: Occupancy Simulation Stop
  sequence:
    - service: script.turn_off
      data:
        entity_id: script.occupancy_simulation_loop

occupancy_simulation_loop:
  alias: Occupancy Simulation Loop
  sequence:
    - delay: '00:{{ (range(20, 41) | random) }}:00'
    - service: script.turn_on
      data:
        entity_id: script.occupancy_simulation_start

Fix loop delay in occupancy simulation
Fix loop delay in occupancy simulation
