Hi there! First time commenter, long time user and fan of AppDaemon and HomeAssistant. I have a small conundrum about how to store state using AD, hope that someone can give me a hand.
I have three lights and a zigbee remote in the living room, this remote has 5 buttons reserved to store and restore states, and I use AppDaemon to handle all zigbee actions related to the remote.
My aim is, when I long press a state button, I want to store somewhere the state of all three lights as they are in that moment , and when I short press the same button, I want to restore the lights to that previous state.
Now, my question is “where and how to store that state?”. For other automations, I create a sensor or whatever in HA (statically in the .conf files if I want the state to persist across HA reboots, or dynamically in AppDaemon, if I don’t need that). However, this time, I feel like creating 15 different virtual lights in my conf files is a terrible hack. Ideally I would like to do something programmatically in AppDaemon. Does someone have a better idea?
I could be convinced to use the AppDaemon namespaces. However, I don’t like it much from the aesthetics POV (state should be a HA thing). Also, the last time I tried to use them, it worked well for a while, and then an update to AppDaemon hosed my whole system until I managed to work out that the issue was in the namespace I was storing state in, so after some hours of very frustrating debugging, I deleted the namespace and never looked back.
Thank you for your answer! I kind of wanted to avoid having to create an entry for each light and state as I would have to create 15 of them, and my yaml files are dirty enough as they are. Though TBH I hadn’t thought of using templates for that. Would that store other states beyond ’ on/off’? Like brightness or color.
I’m afraid I didn’t, the templating solution @tjntomas proposed does not persist through reboots of HA, which doesn’t work for my usecase.
I’ve been experimenting with the virtual components extension which looks like it should do what I want, but it’s quite unstable. Right now there is bug open due to the stable version not working with the 2023.11.2 version of HA. I’ll be waiting until the v0.9 of virtual components goes out of alpha to try again.