Question about Amazon Echo Control Speak Feature


I am currently trying to have Alexa answer with a specific sentence and I can not get it to work (Tr:

rule "Alexa Gas Price Rule"


    Item GasPrice received command ON


    val String formattedForAlexa = "'<speak>Current Gas Price is <say-as interpret-as="unit>" + GasStation_Diesel.state.toString + "</say-as></speak>'"




I am currently getting this error message:
Script execution of rule with UID ‘alexa_specific-1’ failed: The name ‘unit’ cannot be resolved to an item or type

I tried to follow: Amazon Echo Control - Bindings | openHAB and Supported SSML Tags - Amazon Polly and How to make Alexa speak currency (SSML) - Forums

Any suggestions on what can be done to make it work?

The error message is telling you exactly where the problem is. :wink:

Your quote marks don’t match.

I have just changed it to

val String formattedForAlexa = "'<speak>Current Gas Price is <say-as interpret-as="unit">" + GasStation_Diesel.state.toString + "</say-as></speak>'"

And get the same issue again:

Script execution of rule with UID ‘alexa_specific-1’ failed: The name ‘unit’ cannot be resolved to an item or type;

From what I understand the whole String needs to be in ’ ’ for the TTS.
This is how it looks like in the example on the Binding Documentation:

 Echo_Living_Room_TTS.sendCommand('<speak>I want to tell you a secret.<amazon:effect name="whispered">I am not a real human.</amazon:effect>.Can you believe it?</speak>')

Funny thing. I edited my response as I thought my first take was wrong, but it wasn’t. I believe:


Should be:


Hmm. You fixed that in your second version. Interesting.

I think you have to do it without the variable. The multiple " are confusing OH (and confused me).

You also have an extra + at the end that I don’t think is necessary.

Try this:

Alexa_SpeakTTS.sendCommand('<speak>Current Gas Price is <say-as interpret-as="unit"> + GasStation_Diesel.state.toString</say-as></speak>')

Actually, I don’t think that’ll work either since it won’t know what to do with + GasStation_Diesel.state.toString. We need an example that calls in an item state.

As per your suggestion I tried this and it sadly does not work.

Alexa_SpeakTTS.sendCommand('<speak>Current Gas Price is <say-as interpret-as="unit">' + GasStation_Diesel.state.toString + '</say-as></speak>')

Did you try that?


I was JUST thinking that. :wink:

All these quotation marks are making my head spin.

1 Like

This is how it shows up in the openhab log now:
Item ‘Alexa_SpeakTTS’ changed from to Current Gas Price is $2.099

So I think your solution would work!

The only issue now is that alexa is instead of saying the sentence is telling me:
“I’m having trouble accessing your Simon Says EU skill right now”

After googling about it is seems to be the amazons own skill they use for TTS see: OH 3.0.0.m2 Echo control "Simon says"? - #7 by mancer and see Test Adapter Alexa2 3.0.x

I guess theoretically it would work but currently there seems to be an issue on the Alexa Server Side or how would you guys interpret that answer ?

Works fine for me. Are you sure you used the correct "? Which channel is that item linked to? Which version gof the binding?

1 Like

Nevermind it works as it should! I had a typo in it. When I copied it I missed the last chracter: >

Thank you so much guys!

This works:

Alexa_SpeakTTS.sendCommand('<speak>Current Gas Price is <say-as interpret-as="unit">EUR' + GasStation_Diesel.state.toString + '</say-as></speak>')

Now the only issue is that Alexa is saying:
Current Gas Price is 2.139 Euro
(written down in words alexa says Current Gas Price is two thousand one hundred thirty nine euros)

The issue here is that GasStation_Diesel.state.toString has a DOT but I think it needs to be a Comma in order to work correctly in the EU. So instead of 2.139 it should be 2,139.

How can I replace the dot with an comma inside of this command?

I do not have java experience but instead of

you may try
GasStation_Diesel.state.toString.replace( ".", "," )


Thank you now everything works perfect!


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.