Attribute Mapping, Give last item of list

Hey there,

I’m very new to attribute mapping and I got this working the way I wanted to:

data:
  datetime: >-
    {{ workevents['calendar.work'].events | selectattr('summary', 'eq',
    'Urlaub') | map(attribute='end') | list | first }}

Unfortunately, I’m aiming for the function to result in the ‘end’ attribute of the last list item instead of the first. Simply changing to | last gives the following error:

Error rendering data template: TypeError: ‘generator’ object is not reversible

I’m sure, it’s rather silly but I couldn’t find anything online. Thanks in advance.

You should only get that error if you are also removing | list. If you have | list | last it should work.

Huh, I must have accidentally overlooked that due to the similar words. It’s working now, thanks a lot!