I’m pretty new to HASSIO so I may be missing something simple but I have been confused and unable to get jinja to parse and output the value of a light entity’s brightness attribute. I am using a template to accomplish this, and per the docs I am using the state_attr function rather than polling directly from the sates object which could be uninitialized on startup.
Something I am unsure of is the difference between value and value_template. I have seen both used. I thought jinja parsed everything and replaced all portions of yaml within the special brackets? If not does it only parse within the _template fields?
Also, is there an issue with how I have formatted the yaml below to grab the brightness into a variable? (Using the variables integration through HACS)
Thank you so much for helping me understand this more fully!
Is there a way to reference the value of an attribute as an input for a service call in a card?
I am trying to create a button that records the current brightness of a light as a preset on a hold click, and sets the light to the brightness preset on a normal click.
I’ll use a script if needed but it seems overkill for so simple a need. Do you know why templates are unsupported in cards?
I think I read an explanation once, but I don’t remember the specifics… it’s probably a combination of load order, dashboard stability, and efficiency.
While it’s not exactly the same, you may be able to get what you want by using the scene.create service to create a scene on the fly for your light then scene.turn_on to recall the state.
That works perfect! The only functionality that I can’t replicate is I was hoping to display the preset target brightness on the button as well, but that would require a template in the name field or a script to retroactively update the button name with the target percent. I might do it with a script later, unless you know a simpler way for that too!