

Out of curiosity, is it something as simple as needing to wrap the template in quotes? I may be mixing up my YAML with the Ansible work I’ve been doing, but I think you need to have templates double quoted like this in order to resolve the jinja2 properly: "{{ state_attr('light.etc', 'brightness') }}
I don’t think you need the quotes in the Templates section of dev tools but you do in YAML files. I could be wrong though, let me know if you try it.
Definitely use the state_attr() form over states.etc.etc form. I think there’s something about how HA handles startup that may mess with templates if you use states.etc.etc
.
I specifically have two automations that I run as I’m getting in bed (manually, either through a widget on my phone or via voice command): one for if I’m the last person in bed and one of my wife is still up and hasn’t come to bed yet so it doesn’t turn out all the lights on her.