Getting Alexa to speak

I have the Amazon Echo Control Binding installed. I have added a Thing for one of my Echo devices. Then the TTS:

From there, I am struggling with what to do in a Script to actually make the Alexa speak. I have tried:

amazonechocontrol:echo:981f76546f:G090LF1180420BT1:textToSpeech.sendCommand("Hello World")

That gives this error:

2021-12-29 19:52:36.220 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '08f372574e' failed: <eval>:1:26 Missing space after numeric literal
amazonechocontrol:echo:981f76546f:G090LF1180420BT1:textToSpeech.sendCommand("Hello World")
                          ^ in <eval> at line number 1 at column number 26

I have also tried:

LoungeEcho_Speak.sendCommand("Hello World")

And that does this:

2021-12-29 19:52:49.943 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '08f372574e' failed: ReferenceError: "LoungeEcho_Speak" is not defined in <eval> at line number 3

It feels like I am very close, but yet so far. Any pointers to where I am going wrong would be very welcome.

Thanks, Nick

Please provide the full rule (from the “Code”-Tab). The first example looks wrong, the second should work. A similar test works for me:

configuration: {}
triggers: []
conditions: []
actions:
  - inputs: {}
    id: "1"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: EchoEsszimmer_Ankundigung.sendCommand("Test")
    type: script.ScriptAction

Thanks Jan. Some progress! The configuration type was set to JavaScript rather than vnd.openhab.ds1.rule.

Having fixed that, I am now seeing the rule taking longer to run, presumably as it is “conversing” with Alexa. I then see this in the log:

2021-12-29 20:31:55.310 [INFO ] [control.internal.WebSocketConnection] - Web Socket close 1005. Reason: null

I can also see this in the Event log:

2021-12-29 20:38:06.595 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'LoungeEcho_Speak' received command Hello World
2021-12-29 20:38:06.595 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'LoungeEcho_Speak' predicted to become Hello World
2021-12-29 20:38:06.595 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'LoungeEcho_Speak' changed from  to Hello World
2021-12-29 20:38:14.463 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'LoungeEcho_Speak' changed from Hello World to

That repeats each time I execute the rule. I’m still not hearing anything from Alexa though - but that feels like it’s going to be an Alexa issue rather than OpenHAB.

Any more thoughts very welcome, but thank you for the pointer that’s got me this far.

Thanks, Nick

The websocket Message is unrelated. There are several threads on the forum dealing with that.

Thanks again,

Yes I found those various threads later. Just tried and it looks like an OpenHAB restart has fixed it for me too.

Out of interest, I now have a rule created with the new builder - which I think gives Javascript:

events.sendCommand('LoungeEcho_Speak', 'It\'s sunset. Closing the curtains.');

And the same crafted following your example:

LoungeEcho_Speak.sendCommand("Opening the curtains.")

Hopefully that may help others in the future.

Thanks for the help and pointers!