Turn light on/off at random time

trigger:
  - id: 'on'
    platform: time
    at: "15:45:00"
  - id: 'off'
    platform: time
    at: "19:00:00"
action:
  - delay:
      minutes: "{{ range(0,31)|random }}"
  - service: "light.turn_{{ trigger.id }}"
    target:
      entity_id: light.your_light_here

How it works:

It triggers at 15:45 and 19:00 then waits a random time between 0 and 30 minutes, then turns your light on or off respectively.

You did not mention when you wanted it turned off so I chose 19:00 which will mean it can turn off anywhere from 19:00 to 19:30.

2 Likes