Send voice commands FROM HASS TO Alexa using AVS

The idea is to allow HASS to send voice commands to Alexa. If there is a custom component that can send pre-recorded audio to Alexa, then HASS ends up inheriting all the skills that Alexa supports. Here are some ideas.

  1. Alexa Smart Home Component - If we support this, then HASS can send an audio file that says “Turn On Lights” to Alexa. As long as the lights support Alexa, it doesn’t matter who the manufacturer is or if there is a HASS component. This could be extended to all the Smart Home devices that Alexa supports including switches and Thermostats. In essence, I am suggesting that Alexa be treated like a Hub same as Wink or Smart Things. So you would have a Alexa Light component etc.

  2. Alexa Skill Component - There is already a request for AlexaPi, but this will allow a specific skill to be invoked. For example, HASS can do an automation like "When I turn on my coffee maker, ask Alexa “Give me flash briefing” .

I do not believe that there is support on the Alexa side for dynamically speaking without some user input first.

At this point, it is possible to send a phrase to Alexa with cURL - https://miguelmota.com/blog/alexa-voice-service-with-curl/ , so I am hopeful that this should be possible.

At the moment, I am working on a script that will use espeak (Text to Voice) to convert a text to a spoken MP3 and then I am planning to send that via cURL to Alexa as a proof of concept.

If that works, then all that needs to be done is to convert it to Python. While I am not familiar with Python, I think if I have a skeleton ready, hopefully someone can work with me to integrate with HASS

Sorry I misunderstood the original question then. You are correct.

So, the works.

My script converted the text “Tell me a joke” into MP3 and sent it to AVS and I got a joke back as a response. So basically this does work as a PoC.

Now I need to convert this to a Python script. will continue to work on this. The problem is identifying the response.

For e.g. if I create a Turn On Light command, I suspect I should be able to use the response code to see if the command was successful or not.

I visualize this as a component that you customize and add a phrase that performs an action.

bump. how did you get on with this, really looking to do this aswell! When I set my self to sleeping, I currently have tasker use google tts to say Alex play thunderstorm sounds. But I would love for it to just automatically happen, through a voice command!

Sorry… got busy and haven’t looked at this yet, but I still want to do it. My python skills are seriously lacking, so will take a while

I would like to see a similar capability perhaps that can be accommodated by sending Alexa a voice command as you have proposed. In my use case, I’d like Alexa to announce events unprompted. Something like “there is a visitor at the front door” if the front door motion detector is triggered, or “the garage door is still open”, etc.

I am aware that Alexa will play “Simon says” by repeating the whatever is said after “Simon says”. Perhap this can be used for unprompted announcements?

Alexa cannot have unprompted announcement. (except the new call / messaging feature which Alexa notify there is a message / call) The only way I know to do what you want is to do what I do, put a speaker right beside your alexa. This solution doesn’t work very well and frankly is redundant. Since I have a speaker right beside alexa, I get HA to use that speaker to say what I would want Alexa to say. I couldn’t get Alexa to act as a bluetooth speaker for HA either.

If we can use “Simon says” as the prompt (sending it silently) and have Alexa say what follows, the effect would seem like an unsolicited prompt to a casual user. I have thought of using the bluetooth remote mic for this purpose, but haven’t hacked into it yet.

I thought what kdvlr was doing was sending “Tellme a joke” to Alexa silently via some sort of mp3 file transfer. Did I misunderstand this?

I don’t think there is way to send mp3 files silently. Here is the remote idea.

1 Like

thats cool.
like that you can have Alexa say a welcome when she detects that you walk in the door.

I know this is old… but I found this:

I followed the instructions for sending HTTP requests and within 5 minutes I was silently sending commands to alexa using the RESTful command component within HA.

My ADT alarm has an Alexa skill, but no Google Assistant integration, and is not accessible by HA. But using the above I’m able to arm and disarm my alarm.

2 Likes

Hi, I found Bespoken being very useful to my project. However, I was unable to install it on my raspberry pi (getting error while using npm install bespoken-tools).

Is it possible to use RESTful platform to send commands to their server without installing bespoken?

How did you accomplish it?

There’s nothing to install if you use the HTTP method. Just follow the instructions here: https://read.bespoken.io/end-to-end/api/#http-api.

But for that why not use tts with polly or google. Must be much simpler and sound more natural

Thank you for this! I’ve been looking for this for a while now. But I am having an issue with my config. I’ve got everything setup with bespoken, but the command I’m trying to send isn’t getting to amazon, and I don’t get any error messages. Would you mind posting an example?

I no longer use this. But you can test in any browser by using a URL like:

https://virtual-device.bespoken.io/process?user_id=[BESPOKEN USERID]&message=Ask ADT to arm the system

You should get a response in JSON format right in the browser.

For example if I want to know the status of my alarm system that is linked to Alexa:

https://virtual-device.bespoken.io/process?user_id=[BESPOKEN USERID]&message=Ask ADT the status of the system

Response (see the “transcript” field item):

`{"streamURL": null, "sessionTimeout": 0, "transcriptAudioURL": null, "message": "ask ADT the status of the system", "transcript": "this system is disarmed", "display": null, "card": null}`

Your HA config would be something like:

rest_command:
  alexa_weather:
    url: https://virtual-device.bespoken.io/process?user_id=[BESPOKEN USERID]&message=Ask ADT to arm the system

Thanks. That makes sense, and is simpler than what I was trying to do. I was trying to use the GET method and use the payload variable of the Rest command. I’ll give this a shot.

you could also use the script that is out there and start alexa routines.

and when you only want alexa to speak you could use the alexa mediaplayer.

1 Like