I have 2 warnings in logswondering if anyone can help

Your first error can be solved by providing a default after first and you can build safety in it by filtering out media players without last_called

{{ states.media_player | selectattr('attributes.last_called', 'defined') | selectattr('attributes.last_called','eq',true) | map(attribute='entity_id') | first | default(none) }}

I believe someone else answered the second error.

2 Likes

using this example breaks the whole thing and the last call function doesnt work anymore

You’ll have to post everything. I have Alexa media player and the template works as expected.

Thank you Petro! I had the original version:

    - name: "Last Alexa":
      unique_id: last_alexa
      state: "{{ states.media_player | selectattr('attributes.last_called','eq',true) | map(attribute='entity_id') | first }}"

which I have been using successfully for a while which correctly worked as a templated sensor but failed to render in the template editor for some weird reason!

I’ve taken your code one step further now and applied it to the name:

  - name: "{{ states.media_player | selectattr('attributes.last_called', 'defined') | selectattr('attributes.last_called','eq',true) | map(attribute='name') | first | default(none) }}"
    unique_id: last_alexa
    state: "{{ states.media_player | selectattr('attributes.last_called', 'defined') | selectattr('attributes.last_called','eq',true) | map(attribute='entity_id') | first | default(none) }}"

image

  - type: entities
    entities:
      - entity: sensor.last_alexa
        type: custom:multiple-entity-row
        show_state: false
        secondary_info: sensor.last_alexa