Firstly, please format code correctly for the forum. Either use the </> button or use three backticks before and after:
```
CODE GOES HERE
```
If you don’t do that, the forum software messes up quotes and indentation, and we can’t copy / paste your code for testing.
Your problem is caused by name being a direct property of the State object, but the friendly_name being in the attributes dictionary.
This is confusing when Jinja’s map filter uses attribute= — it’s a different use of the word “attribute”. You want this (line breaks optional just for ease of reading):
{{ states.light
|selectattr('state','eq','off')
|map(attribute='attributes.friendly_name')
|list }}
Note I’ve asked for attributes.friendly_name in the map filter.
