Echo Devices (Alexa) as Media Player - Testers Needed

I have the show docking station for the echo, so it stays fully charged all the time. To be honest, I rarely use the table for much more than “show” like stuff. I bought it over the holidays when they were selling the dock and the tablet for less than the new show. I like it. it’s not quite the best of both worlds, but its close. The sound quality is definitely inferior to the actual show, but I dont use it for music anyway.

This basic info has been shared other place, but with the new notify setup I wanted to share this simple setup to allow you have alexa give you information on your sensors. For example, I ask her, where someone is, I get a tide report, etc. Once you get this component set up, the following can help

In your sensors.yaml
- platform: template
  sensors:
      last_alexa:
        entity_id:
          - media_player.kitchen
          - media_player.office
          - media_player.bedroom
          - media_player.livingroom
          - media_player.garage
          - media_player.guestroom
        value_template: >
          {{ states.media_player | selectattr('attributes.last_called','eq',True) | map(attribute='entity_id') | first }}

This is in my configuration.yaml, but if you have a lights.yaml, put this there
light:
  - platform: template
    lights:
      alexa_virtual:
        friendly_name: "Alexa Dummy Light"
        turn_on:
        turn_off:
        set_level:

in your automation.yaml		
- alias: "Alexa Report"
  trigger:
  - platform: state
    entity_id: light.alexa_virtual
    to: 'on'
  condition:
  action:
  - service: alexa_media.update_last_called
  - delay: 00:00:01
  - service: notify.alexa_media
    data_template:
      target: 
        -  '{{ states.sensor.last_alexa.state }}' 
      data:
        type: tts
      message: >-
        {% if (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 1  %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion.  For example Degreess
        {% elif (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 2 %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion. For example  miles
        {% elif (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 3 %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion For example minutes
        {% elif (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 4 %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion
        {% elif (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 5 %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion
        {% elif (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 6 %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion
        {% elif (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 7 %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion
        {% elif (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 9 %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion
        {% elif (states.light.alexa_virtual.attributes.brightness | int / 255 * 100 ) | round  == 10 %}
          Words.  What you want to say {{ states('sensor.name_of_sensor') }} follow on informtion
        {% else %}
         {{ states('light.alexa_virtual.attributes.brightness') }}
        {% endif %}
  - service: light.turn_off
    entity_id: light.alexa_virtual

You need to then expose the “light.alexa_virtual” to your alexas. This is the same as exposing any HA device to your alexa’s and not directly related to this component.

Once the light is exposed and you can turn it on/off, etc with your voice start the next steps
Use the alexa app to create a routine
Click + to create a new routine
Click the + next to “when this happens”
Click on Voice and enter what you want to say. For example “Alexa, give me the surf report”
Then click on add action
I recommend you add a step for “Alexa Says” and enter a short phrase “Let me check for you” is good example
Then add another step
Smart Home --> Control Device --> Select your Alexa Dummy Light and then select brightness
Select a value from 1 to 100, the number will correlate to the automation above
Click Save, give it a few minutes, and try it out.

If you have errors implementing the above, check your formatting. I am using this right now, and have been for several months without issue. The only changes recently were to update it for the new alexa media player notify capability. Enjoy

3 Likes

you forgot to add something to the top of your sensor:

In your sensors.yaml

- platform: template
  sensors:
    last_alexa:
      entity_id:
        - media_player.kitchen
        - media_player.office
        .

Yes, I did. :slight_smile: good catch, thanks. I’ve updated the post

1 Like

Many many thanks!!!
I half-installed the thing with the dummy bulb, but missed some info.
Very good tutorial !!!

Have a look at my parser script. Written in python. It use the same basic flow as your automation to trigger an Alexa response.

It will allow you to extract and manipulate any entity value and get alexa to say it by parsing a simple text line.

I really struggle (too lazy) to understand HA automation’s, if this can be reworked into your automation, be my guest

I guess you were right and the capability has not been released in German/Germany yet … so it is back to your original request to find a way to do it with this addon.

We’re pulling the locale in this case directly from Amazon, so I don’t think that’s the cause. We are planning to implement a locale fix for login, but I don’t think that is what sets that value.

That said, I’m not sure what the issue is. Your log to the API is sending exactly what should be sent. Can you confirm if you create a push using the Alexa App that it works?

This is a confirmed bug with a fix already staged. Probably push it by end of the week.

I need to correct the context. As an entity_id example, media_player.alexa is meant as a placeholder to someone’s actual entity_id.

My statement earlier was that for a service, media_player.alexa_tts is how you can do TTS, but that will be deprecated in 1.3.x.

We’re limited by what the App can do. Find it in the App, and then we can emulate it.

Do you mind adding this into the Wiki?

How can I do a Push thru the app?
Was the Push Mobile intended to push a message to the App from HA?

Create a Routine in the Alexa app which has an action to do the mobile push. General instruction here.

The mobile push notification just replicates the action that you can select in the Routine.

Yes, it works.
I’ve created a routine that starts at hh:mm and I’ve got the notification.

I’ve updated the wiki, thanks for the suggestion!

1 Like

The wiki says I can announce on a Alexa Whole House Audio group (WHA). How do I do that? I have all my echos in an “Everywhere” group but using announce with

target: media_player.everywhere

doesn’t work. If I list all the individual echos the announcement comes from each individual echo, not synced.

Instructions. If it still doesn’t work, can you please post the service call? WHA should work if you’re using announce. tts however won’t work with Everywhere and would have the symptoms you described when splitting the items up.

Sorry if that has been asked before. But , is this component gonna have room awareness ?

I mean, receiving the string of the last sentense spoken to an echo (so we now where it comes from) ?

Yes.

I’m up and working on 89.2 hass.io. One thing I did was I updated my Host System. I wonder if this might have had something to do with the alexapy issue for me. I was at version 1.11, and now I’m at 2.10. After that I had no issues.

Hass.io panel, System, Host System, Update.

I don’t think it updates when you update Home Assistant.

I’ve been playing around with this a bit. To clarify: I have 5 echos, 2 of them paired as a stereo pair. Using
{ "message":"test message to all echos", "title":"My title for Echo show", "data":{"type":"announce", "method":"all"}, "target":["media_player.everywhere"] }
at first only works with the echo that played last. Sending an announce to others individually makes them be included in the everywhere group. Except the stereo pair, I can sent an announce separately beforehand, but they get ignored in the everywhere group.

I’ve just managed to get last_alexa working today, but I’ve noticed a strange issue I can’t seem to figure out.

I’m using this sensor in an automation to ask Alexa what my pool temperature is, and it works flawlessly as long as I ask my basement echo dot, or my bedroom echo spot, but for some reason if I ask the echo dot in my spare bedroom, I get the wrong temperature.

My sensor is set up correctly, as when I update the sensor it gets the right device, and it replies to me on whichever device I’m asking, but in the bedroom and basement I get “The current temperature is sixty-four point four degrees”, while in the spare bedroom she responds with “The current temperature is 32 point zero degrees”

The TTS message is the same, regardless of which device is playing it, so I’m not even sure how one device could possibly get a different response than the rest:

message: The current temperature is {{states('sensor.converted_pool_temp')|replace('.', ' point ') }} degrees

Do you have that particular echo configured for metric in your Amazon configuration?