Hey sorry... I missed your comment (the side effect of disabling all the notifications everywhere 😅).
Great to know you found a solution, but I'm surprised with the group it wasn't working.
Although I really like the setup, I could not get your script to work. Using Home Assistant's group helper what you create as a group is slightly different from a group like you created.
Using the following change it now works. Less elegant than via a group but I could not get that to work and this does the trick:
action:
- service: script.light_duration
data:
light: >-
light.{{["mini_dimmer","philips_lwa004_huelight","philips_lwa004_huelight_2","plug_10_werkkamer_lamp_switch"]|random}}
duration: 00:{{ '{:02}'.format(range(5,30) | random | int) }}:00
chutiloco
Random "time on" and trigger event should include seconds. Don't subestimate thieves recording pattern of a target house. Ligth switching on/off always at 00 seconds is very suspicious unless someone with a syncronized clock and a "toc" live in this house.
Another more realistic approach could be you record the pattern of an normal day with you at home and you move switch on/off some random minutes&seconds. Or you record all days patterns and you select a recorded day randomly.