I am creating a blueprint which is going to generate a scene using the lights that the user specifies.
I will then adjust the brightness of the lights, and eventually restore them by activating the temporary scene that I created in the beginning.
I can easily do this with automations, but I’m trying to convert my automation into a blueprint to make it easier to repeat. The challenge is that I need to programmatically generate a unique name for the temporary scene that is created by the blueprint. If I code the name into the blueprint, it will conflict when the user has multiple instances of their blueprint in use.
Is there a simple way to generate a name from within a blueprint? Can I use the automation ID or something else that would be unique to each instance of the blueprint?
Copy-paste this into the Template Editor to see how it works:
{% set x = 'abcdefghijklmnopqrstuvwxyz' %}
{% set ns = namespace(name='') %}
{% for i in range(15) %}
{% set ns.name = ns.name + x | random %}
{% endfor %}
{{ns.name}}