I'm trying to figure out the best way to save device states so I can restore them later. For example, an automation that turns everything off when I leave the house, then turns back on only the devices that were on before when I get back. Currently, I'm doing this with input booleans, but it's not ideal since I need to maintain one for each device, create them manually, and can't store complex states (such as an AC setup with temperature, mode, etc.).
How can I do this most efficiently? Is there a way to get a full "dump" of a device's states and then apply it later?