So I’m new to HA scripting, and I’m finding the documentation to be pretty lacking.
What I’m trying to do seems simple enough: at the start of the script, save the state of an entity (light) and, after all the other actions, restore that light to its previous state.
To be fair to the numerous volunteers who create and maintain the documentation, it focuses on explaining how to use the tools, not necessarily how to build things with them.
I suggest you review the section on Templating - States because the second example is incorrect and suggests you may have missed the part explaining how to get an entity’s state value.
In addition, the template needs to be redesigned because if the light’s state value is noton the template reports nothing for entity_id. That’s invalid and will cause the service call to fail (i.e. it will generate an error).
You didn’t get my proposal, you don’t have to create a scene manually, you can call a scene service just to store the state of specific entities. Moreover, your current use case is basic (on/off), what would you do to include brightness and rgb values?
I suggest reviewing the following section in the documentation: Templating
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.
That’s cool and I learned something here.
However, this is just for the use case that I want to save a state inside a script.
What if I want to save a state of, say, an input_boolean helper to another global input_boolean entity. Outside the script, so to speak.