To integrate Amazon Alexa like "Media Player"On Home Assistant

5 minutes of reading
Guide purposes
  • To integrate Amazon Echo / Alexa which ripromultimedia producer at Home Assistant
  • Difficulty level: medium / low
Concepts dealt with:
  • Software configuration
Software components used:
Prerequisites
Physical devices used:
  • The device on which it resides Home Assistant
  • Amazon Echo (any model or any model of smart speaker you mount Amazon Alexa as integrated software)
GUIDE more indicated for:

All environments

Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere progettata ed effettuata da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (the contents of the present page are purely educational);
  • any changes implemented in proprior to a device it voids the guarantee, quality approvals and certifications.
Driving review: 2.0

Amazon Echo Dot - colors

Abstract

Amazon Echo It is one of device of wider and more recognized success. As we explained, this smart speaker uses the software to work Alexa, which is available, even for smart speakers proproduced by third parties, as well as how appstand-alone communication for Android and iOS smartphones / tablets.

This guide, we say it immediately, is not dedicated to the integration of Alexa devices with Home Assistant. This theme has already been addressed in two other specific guides:

this guide, on the other hand, illustrates how to integrate Alexa with Home Assistant as if it were (what it is, actually) a repromusic producer. This allows you to:

  • view the status of ri from frontendpromusic production;
  • set up the repromusical production, from frontend as street automation;
  • set the volume;
  • intercept its operational status;
  • use the smart speaker as a voice notification system (to which we have dedicated a guide ).

The integration it's pretty simple and involves the use of an unofficial component (custom component) Of Home Assistant, called "Alexa Media Player"

It starts

Installation

Like any custom component Home Assistant, starting from the 0.88 version of the latter it is necessary to create a folder containing the component files, which will be placed, in turn, inside the "custom_components"Inside the main folder of Home Assistant (ie the one in which they lie) the configuration files).

Download therefore the installation package e prosee decompress it: it will contain a folder called “alexa_media"Which rappresets the folder dedicated to the component; protherefore see to copy it inside the folder "custom_components”(Where the latter does not exist, prosee to create it).

ALTERNATIVE - preferable - VIA HACS

from version 1.3.0 the component provides a much easier alternative to install it: to use HACS.
To do this it is necessary have the HACS component installed once and then:

  • enter HACS;
  • click "SETTINGS";
  • under "ADD CUSTOM REPOSITORY" add - selecting the type "integration”- the path:
https://github.com/custom-components/alexa_media_player

and finally, returning to the entry "STORE", Search and find" Alexa Media Player", Click on it and then, on the page that opens, click on"INSTALL". At the end, restart Home Assistant.

Integration

Once the component is installed "Alexa Media Player" is prosaw when restarting Home Assistant, we are therefore proto integrate Alexa devices (associated with our account Amazon) to our home automation.

The data needed for proseeing this integration is theusername and password of our account at the national webstore Amazon (. It for Italy, . Fr for France and so on).

Go to the menu item Home Assistant "Settings"> "Integrations" and select the item "Alexa Media Player""

Home Assistant - Alexa integration Media Player

On the next screen, enter the user in the required fieldsname, the password and the national reference store:

Home Assistant - Alexa integration Media Player - Step 1

Click on "SUBMIT”To access the final captcha:

Home Assistant - Alexa integration Media Player - Step 2

Finally click on "SUBMIT”To complete the integration.
At this point, if all went well Home Assistant will list i device Alexa connected to profirst account and then, from this moment, integrated to theHUB:

Home Assistant - Alexa integration Media Player - Step 3

Integration details

At any time it is possible to consult the profirst list of devices integrated in the menu item “Settings">"Integrations">"Alexa Media Player"(Item"Configured"):

Home Assistant - Alexa Media Player Integration

Use

At the end of the restart, instead of the "Configurator" entity it will be appburned one (or more, depending on how many devices were included in the configuration) of type "Media Player"

Home Assistant - Alexa Media Player

The name of this entity will be the one set on proyour account Amazon. In this case of exemplary, "media_player.alexa"

Nb For integration to work is necessary that the status of the entity is different from "Unknown". In this case "standby”Indicates that the Smart Speaker has been integrated correctly and is in standby condition. In case of status "Unknown”Review the network configuration and status, because obviously something is working incorrectly.

Ripromusical production

At this point the entity can be controlled as a common device Media Player at the user interface Lovelace or by service media_player.play_media (via automations, scripts, etc.).

One script type is the following:

script:
  remco_awake:
    alias: Ascolto musica
    sequence:
    - data:
        entity_id: media_player.alexa
        media_content_id: "Radiofreccia"
        media_content_type: "TUNEIN"
      service: media_player.play_media

evoking this script, the Media Player indicated ("media_player.alexa") Will begin to reproset the "Radiofreccia" radio station via the service Tune IN.

Other examples of services are:

APPTHE MUSIC
{
  "entity_id": "media_player.alexa",
  "media_content_id": "7 rings",
  "media_content_type": "APPLE_MUSIC"
}
>AMAZON MUSIC
{
  "entity_id": "media_player.alexa",
  "media_content_id": "Concrete and gold",
  "media_content_type": "AMAZON_MUSIC"
}
{
  "entity_id": "media_player.alexa",
  "media_content_id": "La mia playlist",
  "media_content_type": "AMAZON_MUSIC"
}
Deezer
{
  "entity_id": "media_player.alexa",
  "media_content_id": "Falco",
  "media_content_type": "DEEZER"
}
TuneIn
{
  "entity_id": "media_player.alexa",
  "media_content_id": "BBC one",
  "media_content_type": "TUNEIN"
}

Groups

Through the integration of multiple Smart Speakers it is possible to automate the riproin chorus (synchronized) music content:

{
  "entity_id": "media_player.alexa",
  "media_content_id": "boyz ii men in tutti i dispositivi",
  "media_content_type": "AMAZON_MUSIC"
}

The trick is to indicate in the media_content_id the suffix "in all devices"

Sequences

The integration also supports the control of typical Alexa sequences, specifically:

  • Alexa.Weather.Play (weather information)
  • Alexa.Traffic.Play (traffic information)
  • Alexa.FlashBriefing.Play (short summaries)
  • Alexa.GoodMorning.Play (good morning)
  • Alexa.GoodNight.Play (good night)
  • Alexa.SingASong.Play (plays a cazone)
  • Alexa.TellStory.Play (tells a story)
  • Alexa.FunFact.Play (tells a funny fact)
  • Alexa.Joke.Play (tells a riddle)
  • Alexa.Music.PlaySearchPhrase
  • Alexa.Calendar.PlayTomorrow
  • Alexa.Calendar.PlayToday
  • Alexa.Calendar.PlayNext
  • Alexa.CleanUp.Play
  • Alexa.ImHome.Play ("I'm back")

The service used is always media_player.play_media; to change is the "media_content_type", for example:

{
  "entity_id": "media_player.alexa",
  "media_content_id": Alexa.FlashBriefing.Play
  "media_content_type": sequence
}

In this example we ask Alexa to reproduce quick summaries (flash briefing).

Volume

Finally it is also possible adjust the volume of the various integrated Smart Speakers.

Let's look at the example of a script that sets a default volume to 50%:

alexa_imposta_volume:
  sequence:
    - service: media_player.volume_set
      data: 
        entity_id: media_player.alexa
        volume_level: 0.5

automations

At this point all that remains is to wire these possible calls to ours automations.
A trivial example can be that of configuring an automation which, when opening the front door - interpreted as a return home - isproduke a quick summary (maybe default in home automation):

automation:
- alias: "Bentornato"
  trigger:
  - platform: state
    entity_id: sensor.sensore_apertura_porta
    to: 'on'
  condition: []
  action:
    service: media_player.play_media
    - data:
        entity_id: media_player.alexa
        media_content_id: Alexa.FlashBriefing.Play
        media_content_type: sequence
      service: media_player.play_media

At this point it is possible to use the automations both to control Alexa as explained above, and for unleashing events in the face of riproduction of some content triggered perhaps by voice command.

For example it might be nice to set a foolish color sensitive to the music of a panel lumiI do not know Nanoleaf opposite of the start of the reproduction of a piece:

automation:
  - alias: "Riproduzione musicale"
    trigger:
      platform: state
      entity_id: media_player.alexa
      to: 'playing'
    condition:
      condition: state
      entity_id: light.nanoleaf
      state: 'off'
    action:
      service: light.turn_on
      entity_id: light.nanoleaf
      data_template:
        effect: 'Music schema'

The limit, as always, it's fantasy.


Home Assistant Official LogoATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Home Assistant, for any doubt, question, information on the specific merit of these components.


Please comment below

"Make people talk" Amazon Alexa as a home automation notification system on Home Assistant