I want to dynamically store the state of the lights of my living room in a way that keeps between reboots. The scenario is that I have six buttons in my remote, I long press one to store the current state of the lights, and then I short press to recover it.
After some thought I have reached the conclusion that the best way to do that is by creating one virtual device per state and light, using templates or the virtual device. However, that means manually creating 18 elements in my lights.yaml file… And if I add another light to the living room, yet another 6…
Is there a way of creating devices in an iterative way? I would like to find something like this:
%% for i in range(0,15) - platform: virtual name: 'central-%i' initial_value: 'off' support_brightness: true support_color: false %% end for
I tried looking for templates, but I couldn’t find anything that would fit the bill. (I suck at templating, though)
Also, I know that the solution that HA offers for this kind of problem is typically scenes, and you can create dynamic scenes using the ‘scene.create’ service. But I gather from the docs that they are not persistent across reboots.