Troubleshooting an automation usint data template

actually scratch that, it’s because they were off. If I turn the light on, I get a number. They are lutron caseta switches.

Maybe the issue is that the brightness attribute is not set at the exact moment the light state changes. Does it make any difference if you make the delay longer, or set the brightness in a separate automation?

Another wild guess would be to get the trigger object after it has changed state, and getting the attributes from it. I don’t know if that would work at all but perhaps worth a try:

{{ trigger.to_state.state.attributes.brightness | int }}

Try double quotes instead of single?