No that does not work I’m afraid as last_changed is not within attributes. So cannot be retrieved using the state_attr function.
My understanding is that I have to access the state object directly, rather than a function, to access last_changed. But not sure if I can do this dynamically.
The solution above is the right one for this use case IMO. But just as an FYI for future, if you pass an entity ID into the expand filter it gives you back the full state object to work with. The examples in the doc talk about the expand filter’s usage in groups but actually it works for anything. Here’s an example of how that works: