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

5 minutes of reading

`

Guide purposes
  • Make Amazon Alexa a domotic verbal notification system on Home Assistant
  • Difficulty level: 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: 1.3

Amazon Alexa speaks

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.

First, Alexa is able to execute orders at the centralized personal domotics e based on Home Assistant thanks to its ability to be integrated as an assistant:

Secondly, Alexa can also be integrated to Home Assistant how to repromusic producer (Media Player), thanks to'integration provided by an ad hoc designed component, so as to be able to trigger automation linked to listening to content.

Finally, the third possibility - which derives integration as Media Player above - is to integrate Amazon Alexa as a notification system, in order to generate a service "Notification"Which allows us to make him" have his say "in the face of specific situations.
Let her talk, in short:

"Hey, I detected a flood in the bathroom!
"The washing machine has completed the washing cycle.
"Alarm system activated in night / presence mode. "
"Welcome home!"

And so on. The limit, as always, it's fantasy.

Prerequisites

Integrating Alexa which notification element at Home Assisatant it is quite simple, but first it is necessary prosee to the integration of the same which ripromultimedia producer (Media Player). It is not obligatory, instead, to have already prosaw its integration on Home Assistant as a personal assistant.

For prosee the integration necessary as Media Player, the guide is this.

Configuration

Downstream of the successful integration as Media Player, adopt a notification element It is simple. It is in fact sufficient to add to the configuration Home Assistant the following block:

notify:
  - platform: alexa_media
    name: alexa_media

then restart Home Assistant.
After successful reboot, in the list of services ("Developer Tools / Services") appa new type entity willNotification"Call"notify.alexa_media". In reality the component also generates others, but for the purposes of this guide we will concentrate on this.

Funcnamento and test

The supported notification methods are three:

  1. TTS - This is the old feature text-to-speech. UPDATE: This mode is deprecated and no longer functional.
  2. Announce - This is the new text-to-speech feature to allow us to "make people talk" Alexa. It also allows you to view (only on models Echo Shows / Spots) a message on the display. It is possible to reprodurare messages on a single smart speaker or on all those present in the house, in unison, indicating in a more target configuration.
  3. Mobile Push - Allows you to send notifications push on 'app Alexa connected to the smart speaker.

To test the functionnameof the "Announce" mode (therefore to make people talk Alexa) select the service “Developer Tools / Services”notify.alexa_media"

In the "Service Data" field insert a test payload like the one below (further details to follow):

{
"message":"Questo è un messaggio di test.",
"title":"Titolo",
"data":{"type":"announce", "method":"spoken"},
"target":["media_player.alexa"]
}

explanation of the fields:

messageThe message to make proannounce to Alexa.
titleTitle to be displayed in the presence of displays (only models that have them) and / or as the title of any notification push
dataContains type of notification ("type") And method ("method“).

typeType of notification. Could be tts, announce (emits a sound before messages and accepts language formatting SSML markup) or push (towards app mobile).

IMPORTANT: so that the mode "announce”Functions, in the settings of the target device at theapp Alexa the voice "Communications" must be active.

methodValid only for type:announce. Could be spoken (makes Alexa talk), show (show on display, if present) or all (Both).
targetThe Alexa device to which the notification is directed. It can be a list. Friendly can be used to indicate the device (s) name, the serial number, the entity_id, or a group Home Assistant. We recommend using the name of the entity Media Player generated through the appropriate integration (eg. "media_player.alexa"). In case you use a type:push (Or even type:all), the notification will also arrive atapp mobile Alexa connected to the indicated target.

Nb for this guide we will always use the usual target entity, or "media_player.alexa". Obviously the user will have the freedom to customize the target as explained above.

Now, by clicking on "Call Service", Alexa dovrebbe proannounce the message set in the field "message"

Notification push

An example of a payload to ensure that the notification is sent to theapp mobile instead of riproverbally produced by the smart speaker, is the following:

{
"message":"Questo è una notifica di test.",
"title":"Notifica push",
"data":{"type":"push"},
"target":["media_player.alexa"]
}

Use

In automation

Now let's see how to implement a voice notification when someone returns via someone's home automation apposita.
Let's assume we have the following entities in configuration:

  • group.famiglia (a set of "Device Tracker"That rappconfirm tenants' position);
  • scene.ritorno_a_casa (a scene that, if triggered, turns on the entrance lights);
  • binary_sensor.contatto_ingresso (a door sensor placed on the front door);
  • notify.alexa_media (the service generated with the component used in this guide);
  • media_player.alexa (the target smart speaker).

We therefore implement an automation so structured:

automation:
- alias: "Ritorno a casa"
  trigger:
    platform: state
    entity_id: group.famiglia
    to: 'home'
  condition: []
  action:
    - service: scene.turn_on
      entity_id: scene.ritorno_a_casa
    - wait_template: "{{ is_state('binary_sensor.contatto_ingresso', 'on') }}"
      timeout: '00:30:00'
      continue_on_timeout: 'false'
    - delay:
        seconds: 5
    - service: notify.alexa_media
      data:
        target:
          - media_player.alexa
        data:
          type: announce
          method: spoken
        message: "Bentornati a casa."

We therefore explain automation.

Il trigger it is the change of state of the entity group.famiglia from any state to "home"- which triggers when even one of the tenants has returned to the perimeter of the house (see component"Device Tracker“).

None condition occurred; the action, instead, they are varied and as always sequential:

  • activates the scene scene.ritorno_a_casa (whatever it does: turn on the lights, turn off an alarm, etc.);
  • puts you on hold for 30 minutes waiting for the sensor binary_sensor.contatto_ingresso detect the door opening (after 30 minutes the automation stops);
  • upon detection of the door opening, it waits five seconds;
  • finally, it causes Alexa proannounce a welcome back message.
RANDOM MESSAGES

To make minimally less robotic Alexa you can use a randomness in the messages from it pronunciati.
Modifying the above example as follows:

    - service: notify.alexa_media
      data:
        target:
          - media_player.alexa
        data:
          type: announce
          method: spoken
        message: {{ ["Bentornato a casa!","Guarda chi si vede!","Ciao","Casa dolce casa."] | random}}

the use of the list together with the parcel "random”Means that each time the service is called in mode announce one of the four messages in the example is chosen.

OTHER IMPLEMENTATIONS

Obviously, as always, the limit it's fantasy. Being a service, this notification entity can be used not only in automation but also in script and in other areas of Home Assistant.

Making Alexa talk can be comfortable in many situations: not only to notify specific conditions in home automation, but also to notify information not strictly related to home automation but surveyed by it (for example to point out when it decreases the price of petrol from the distributor under the house, rather when it is expected that change weather conditions, and much more).


Traditional refrigerator under control via home automation Home Assistant


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