Using Alexa Media Player “last called” service

Hi All,

Any change on this? Or is there some faster and reliable alternative to get the LastCalled information?

I’m using the Alexa Media Player (5.7.1) integration with 14 Alexa devices, but it is neither reliable (sometimes Alexa activity won’t be recognized) nor fast (takes up to 10 minutes to get the update) for me.

Strange, how do you go about it? The answer comes within a few seconds. However, I “only” have 7 devices. Very rarely does the answer come on the wrong device. It’s been like this here for a year.

Just the template sensor from the wiki, that’s enough. I use the DIY skill to activate the scripts via Alexa routine.

Yes, I’m also using the recommended template sensor(s):

  - sensor:
    - name: Last Media Player Called
      unique_id: last_media_player_called
      state: >
        {{ states.media_player | selectattr('attributes.last_called', 'true') | map(attribute='entity_id') | first }}

  - sensor:
    - name: Last Alexa Called
      unique_id: last_alexa_called
      state: |-
        {{ expand(integration_entities('alexa_media') | select('search', 'media_player')) | selectattr('attributes.last_called', 'eq', True) | map(attribute='entity_id') | first }}
      availability: |-
        {{ expand(integration_entities('alexa_media') | select('search', 'media_player')) | selectattr('attributes.last_called','eq',True) | first is defined }}      
      #state: >
      #  {{ expand('group.echos') | selectattr('attributes.last_called_timestamp') | map(attribute='entity_id') | first }}

  - sensor:
    - name: Last Alexa Called Summary
      unique_id: last_alexa_called_summary
      state: |-
        {{ expand(integration_entities('alexa_media') | select('search', 'media_player')) | selectattr('attributes.last_called', 'eq', True) | map(attribute='attributes.last_called_summary') | first }}
      availability: |-
        {{ expand(integration_entities('alexa_media') | select('search', 'media_player')) | selectattr('attributes.last_called','eq',True) | first is defined }}    

  - sensor:
    - name: Last Alexa Called Date
      unique_id: last_alexa_called_date
      state: |-
        {{ expand(integration_entities('alexa_media') | select('search', 'media_player')) | selectattr('attributes.last_called', 'eq', true) | map(attribute='attributes.last_called_timestamp')  | first | int | multiply(0.001) | timestamp_custom('%Y-%m-%d %H:%M:%S', true) }}
      availability: |-
        {{ expand(integration_entities('alexa_media') | select('search', 'media_player')) | selectattr('attributes.last_called','eq',True) | first is defined }}

In my configuration.yaml it looks like this:

template:
  - sensor:
      - name: Last Alexa
        state: |-
          {{ expand(integration_entities('alexa_media') | select('search', 'media_player'))
          | selectattr('attributes.last_called', 'eq', True) | map(attribute='entity_id') | first }}
        availability: |-
          {{ expand(integration_entities('alexa_media') | select('search', 'media_player'))
          | selectattr('attributes.last_called','eq',True) | first is defined }}

Thats all. Look here. I have simply adopted this. But I’m not an expert either. But it works perfectly. :slight_smile:
There you will also find lots of examples of what such scripts could look like.

Edit: I think you also have wrong indentations. And why so many sensors?

Yes, I have it also from there. You have the same, check it out :slight_smile:

Just out of curiosity I also just tested it (on 5.7.1) and mine never updated and when it finally did it was from an hour ago. Not sure why some people are having better success than others?!

I reinstalled Alexa Media Player few times, but there is no change in behavior.

The only fix I found for updating last_called in the Alexa devices:

  • Call the action node:
    • Action: alexa_media.update_last_called
    • Data: {"email":"your@email_for_amazon.here"}

It works immediately after the call.

Not quite, my indentations look different. I already wrote that in the edit of my post above. Maybe that’s the problem?