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"
when
Item GasPrice received command ON
then
val String formattedForAlexa = "'<speak>Current Gas Price is <say-as interpret-as="unit>" + GasStation_Diesel.state.toString + "</say-as></speak>'"
Alexa_SpeakTTS.sendCommand(formattedForAlexa)
Dieselpreis.postUpdate(OFF)
end
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
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;
EDIT:
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>')
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.
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?