Thank you! That was actually the first thing I was trying, and kept getting nothing back. Tried several times, thinking I spelled something wrong. Looks like I did, because when I copied your syntax (which visually looks the same as mine), it worked.
For future reference, the word attribute in Jinja’s map filter doesn’t mean the same thing as the word attributes in Home Assistant. The two words refer to different things.
That’s what the template is extracting when you use map(attribute='name'). It’s getting the value of the name property from each supplied State Object.
You’ll notice that there’s another property in a State Object called attributes. The value of attributes is a dictionary containing one or more instances of what everyone commonly calls “an attribute” (which serves to make everything even more confusing because that word is being used so many different ways).
So if you want map to get the value of one of the keys that are in the attributes dictionary, such as color_mode, you would use map(attribute='attributes.color_mode')
Actually, please accept my apologies. I intended to reply directly to smarthome01824 yet mistakenly clicked the reply button in your post. My explanation was meant for smarthome01824; I am confident you know the details of attribute/attributes. Plus there’s nothing wrong with your language skills.
Also, keep in mind that not all entities within a group will have all the same attributes or defined values for those attributes, so make sure to select for the attribute type you want or your template may fail due to errors.
{{ expand('light.test_light_group')
| selectattr('attributes.icon', 'defined')
| map(attribute='attributes.icon') | list }}