Alexa_Speak: Let Alexa speak

Hello everyone, I apologize in advance as this question has already been asked in a similar way - unfortunately, the previous discussions didn’t help me…
I am still very new to OH and am struggling with the basics - I can’t get my Alexa(s) to speak.
I have already set everything up and connected Amazon. I have also created a channel/item through the corresponding Amazon Thing: (The name of the Alexa is “Mainstage”)

I now want to create a rule that makes Alexa notify me when a window is opened. The rule works because I send a broadcast message that arrives every time. But Alexa remains silent…

I have now created a script (DSL) with only one line:
Mainstage_Speak.sendCommand("Bathroom window is still open!");

The events.log shows me the following:
2024-06-11 23:05:32.052 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘Mainstage_Speak’ received command Bathroom window is still open!

The openhab.log does not always log…

I have also tried the whole thing with Blockly, and in a function sent the broadcast message as well as asked Alexa to speak - but here too, Alexa remains silent.

Can someone help me with this?

Hi there,
Some quick ideas:

  • If nothing is coming out, check the Notification volume setting (Although for an Echo Dot the light should come on when you send the speak command anyway, not so sure about the Amazon ‘Show’ device though). You can create a NotificationVolume item, and then just set the Item volume manually first in OpenHAB via the UI. (You can also later add this to your script, a JS example:
    items[alexaItemName+"_NotificationVolume"].sendCommand(alexaNotificationVolume); (Just replace the variables with absolute values for testing)
  • What is the Metadata you have on your string item above? I have no metadata on my channels TO the Alexa, and they all work fine (However I have MetaData on the inbound commands from Alexa though). Perhaps try and remove this temporarily
  • Also try set the amazonechocontrol Binding into Trace mode (Settings → Add On management), for more info of whats happening under the hood, if the above steps don’t work

Given you are actually seeing the command being sent in the event log, to the item you have created, at a guess, I don’t think its your rule which is a problem, but more likely something between the Item->Channel->Thing->Binding etc…

However, if you still want to check rules (and you are willing to tinker in JS script) feel free to grab the following code for a Rule I know works, and modify it as follows:

  • Create the Rule (and give it a name and description)
  • Click on the code tab, and paste the following code in there
  • Replace the item name for the speak channel, with your own item name
  • Save the rule

Then the rest of the configuration can be done via the UI. Remove the example items I have in there, and add your own windows. Anything that triggers the rule, will be announced by Alexa, including the Item label name.

And then you can keep on adding items to the trigger list, without ever changing the underlying code. My actual rule has around 10 items as triggers, and works well.

Note I have a constraint to only announce when the House alarm is unset, and ‘night mode’ item is enabled. Feel free to delete those, for your testing - Just there as an example.

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: WindowLocked
      state: OFF
      previousState: ON
    type: core.ItemStateChangeTrigger
  - id: "2"
    configuration:
      itemName: DoorLocked
      state: OFF
      previousState: ON
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "4"
    configuration:
      itemName: night_mode
      state: ON
      operator: =
    type: core.ItemStateCondition
  - inputs: {}
    id: "6"
    configuration:
      itemName: AlarmArmed
      state: OFF
      operator: =
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "5"
    configuration:
      type: application/javascript;version=ECMAScript-2021
      script: >-
        //Script to send alerts to users when Alarm is unset, and Night Mode
        Enabled. Items to trigger alerts are selected via the rule config, and
        the "Alarm Set" and Night Mode constraint is also defined there too


        if(this.event != undefined) {

        //Stops script from running if triggered via OpenHAB console - Event would be undefined, and fail
            console.log("Rule Night Mode Notification triggered - Sending notification to OH Apps - Item triggered is",items[event.itemName].label);
            items["EchoDotBedroom1_Speak"].sendCommand(items[event.itemName].label + " Unlocked")
          ;
        }
    type: script.ScriptAction

This rule will only work when triggered by an item, so just go and open your window and see what happens !!

Hope this helps.

Thank you for your quick response.
I tried to follow your points, but nothing happens… Maybe we should start from the beginning:

  1. The settings of the Alexa Thing:

  1. I go to my Alexa Thing, select the TTS Channel, and create a link and a new item

  1. I also create a volume item through the channels and set a volume level:

  1. I perform a simple test using Blockly to see if Alexa says something:

I also haven’t quite understood which script type I should use (DSL or EMS-js) and what exactly needs to go into the script. When I trigger a script in a rule, theoretically one line should be enough, like (DSL):

Mainstage_Speak.sendCommand("Test Text");

Having the Amazon Binding in Tracemode the openhab.log gets a lot of informations:

2024-06-12 10:12:47.203 [DEBUG] [trol.internal.handler.AccountHandler] - updateSmartHomeState started with deviceFilterId=null
2024-06-12 10:12:48.108 [TRACE] [control.internal.handler.EchoHandler] - Command 'Test Text 1' received for channel 'amazonechocontrol:echo:f650e12dd1:G0922M0633470JT2:textToSpeech'
2024-06-12 10:12:48.109 [TRACE] [control.internal.handler.EchoHandler] - Command 'Test Text 1' received for channel 'amazonechocontrol:echoshow:f650e12dd1:G0B18W11245206VT:textToSpeech'
2024-06-12 10:12:48.609 [DEBUG] [mazonechocontrol.internal.Connection] - added 1221651189 device G0922M0633470JT2 G0B18W11245206VT 
2024-06-12 10:12:49.109 [DEBUG] [control.internal.handler.EchoHandler] - Handle updateState amazonechocontrol:echo:f650e12dd1:G0922M0633470JT2
2024-06-12 10:12:49.109 [DEBUG] [mazonechocontrol.internal.Connection] - Make request to https://alexa.amazon.de/api/np/player?deviceSerialNumber=G0922M0633470JT2&deviceType=A2DS1Q2TPDJ48U&screenWidth=1440
2024-06-12 10:12:49.110 [DEBUG] [control.internal.handler.EchoHandler] - Handle updateState amazonechocontrol:echoshow:f650e12dd1:G0B18W11245206VT
2024-06-12 10:12:49.110 [DEBUG] [mazonechocontrol.internal.Connection] - Make request to https://alexa.amazon.de/api/np/player?deviceSerialNumber=G0B18W11245206VT&deviceType=AIPK7MM90V7TB&screenWidth=1440
2024-06-12 10:12:49.306 [DEBUG] [mazonechocontrol.internal.Connection] - Call to https://alexa.amazon.de/api/np/player?deviceSerialNumber=G0922M0633470JT2&deviceType=A2DS1Q2TPDJ48U&screenWidth=1440 succeeded
2024-06-12 10:12:49.307 [DEBUG] [mazonechocontrol.internal.Connection] - Result of GET https://alexa.amazon.de/api/np/player?deviceSerialNumber=G0922M0633470JT2&deviceType=A2DS1Q2TPDJ48U&screenWidth=1440:{"playerInfo":{"hint":null,"infoText":null,"isPlayingInLemur":false,"lemurVolume":null,"lyrics":null,"mainArt":null,"mediaId":null,"miniArt":null,"miniInfoText":null,"playbackSource":null,"playingInLemurId":null,"progress":null,"provider":null,"quality":null,"queueId":null,"state":null,"template":null,"transport":null,"upNextItems":null,"volume":null}}
2024-06-12 10:12:49.575 [DEBUG] [mazonechocontrol.internal.Connection] - Call to https://alexa.amazon.de/api/np/player?deviceSerialNumber=G0B18W11245206VT&deviceType=AIPK7MM90V7TB&screenWidth=1440 succeeded
2024-06-12 10:12:49.576 [DEBUG] [mazonechocontrol.internal.Connection] - Result of GET https://alexa.amazon.de/api/np/player?deviceSerialNumber=G0B18W11245206VT&deviceType=AIPK7MM90V7TB&screenWidth=1440:{"playerInfo":{"hint":null,"infoText":{"header":null,"headerSubtext1":null,"multiLineMode":false,"subText1":"Cheat Codes","subText2":"Timmo","title":"Morning"},"isPlayingInLemur":false,"lemurVolume":null,"lyrics":null,"mainArt":{"altText":"Album Art","artType":"UrlArtSource","contentType":"image/jpeg","url":"https://i.scdn.co/image/ab67616d0000b273ab52572370890e7678735f9e"},"mediaId":"spotify:track:1KSknsaLLPqWKLlVRSu8BA","miniArt":{"altText":"Album Art","artType":"UrlArtSource","contentType":"image/jpeg","url":"https://i.scdn.co/image/ab67616d0000b273ab52572370890e7678735f9e"},"miniInfoText":{"header":null,"headerSubtext1":null,"multiLineMode":false,"subText1":"Cheat Codes","subText2":"Timmo","title":"Morning"},"playbackSource":null,"playingInLemurId":null,"progress":{"allowScrubbing":true,"locationInfo":null,"mediaLength":184,"mediaProgress":109,"showTiming":true,"visible":true},"provider":{"artOverlay":null,"fallbackMainArt":null,"providerDisplayName":"Spotify","providerLogo":{"altText":null,"artType":"UrlArtSource","contentType":"image/png","url":"https://music-service-provider-logos.s3.amazonaws.com/dms-gui-logos/wordmark-logos/Spotify.png"},"providerName":"Spotify"},"quality":null,"queueId":"","state":"PAUSED","template":null,"transport":{"closedCaptions":null,"layoutType":"MusicTransportLayout","lyrics":null,"next":"ENABLED","playPause":"ENABLED","previous":"ENABLED","repeat":"DISABLED","shuffle":"ENABLED"},"upNextItems":null,"volume":{"muted":false,"volume":27}}}

The “Timmo” is a Playlist on Spotify I heard like 2 hours before the log.

Ok, as per my previous comment, I dont think there is anything wrong on the rules side of the fence, given what is showing in the log. Nothing seems that unusual in your trace log either. I wont be in a position to do this until next week, but I will pop my binding into trace mode, and compare it with what you are seeing on yours. Just for completeness, what version of OH and binding have you got installed? Cheers

Ok, as promised, I have compared your log to my own (set to TRACE as well). Nothing seems to stand out in terms of differences:

  • I have a few extra entries in mine, but perhaps that is version specific?
  • The first and last line of the log (updateSmartHomeState) are not related to the actual command - They are just entries which turn up regularly with no activity occurring on the binding, when set to trace
  • I am based in NZ, so the call is made to the regional (Australia) Amazon server, as you would expect
  • There are some extra entries in there relating to ‘thread’
  • FYI - The XXXXX is substitution of my customer ID and device ID from log, etc (You may want to do same to edit your log submission)

Not sure where to from here - Perhaps search ‘OpenHAB Alexa TTS’ - There are people who have had issues in the past, fixed by a variety of interventions, albeit on older versions of the binding/openHAB.

And on that topic, I am running OPenHAB 4.1.3 (Binding is also 4.1.3). The devices I am using are Echo Dot(s).

2024-06-17 20:13:20.760 [DEBUG] [trol.internal.handler.AccountHandler] - updateSmartHomeState started with deviceFilterId=null
2024-06-17 20:13:21.225 [TRACE] [control.internal.handler.EchoHandler] - Command 'Test' received for channel 'amazonechocontrol:echo:amazon_ac:echo_bed:textToSpeech'
2024-06-17 20:13:21.726 [DEBUG] [mazonechocontrol.internal.Connection] - added XXXXXXXXXXXX device XXXXXXXXXXXX 
2024-06-17 20:13:21.738 [DEBUG] [mazonechocontrol.internal.Connection] - thread XXXXXXXXXXXX device 
2024-06-17 20:13:21.738 [DEBUG] [mazonechocontrol.internal.Connection] - Make request to https://alexa.amazon.com.au/api/behaviors/preview
2024-06-17 20:13:21.739 [DEBUG] [mazonechocontrol.internal.Connection] - POST: {"behaviorId":"PREVIEW","sequenceJson":"{\"@type\":\"com.amazon.alexa.behaviors.model.Sequence\",\"startNode\":{\"@type\":\"com.amazon.alexa.behaviors.model.SerialNode\",\"nodesToExecute\":[{\"@type\":\"com.amazon.alexa.behaviors.model.ParallelNode\",\"nodesToExecute\":[{\"@type\":\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\",\"type\":\"Alexa.DeviceControls.Volume\",\"operationPayload\":{\"deviceType\":\"A32DOYMUN6DTXA\",\"deviceSerialNumber\":\"XXXXXXXXXXXX\",\"locale\":\"\",\"customerId\":\"XXXXXXXXXXXX\",\"value\":25}}]},{\"@type\":\"com.amazon.alexa.behaviors.model.ParallelNode\",\"nodesToExecute\":[{\"@type\":\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\",\"type\":\"Alexa.Speak\",\"operationPayload\":{\"deviceType\":\"A32DOYMUN6DTXA\",\"deviceSerialNumber\":\"XXXXXXXXXXXX\",\"locale\":\"\",\"customerId\":\"XXXXXXXXXXXX\",\"textToSpeak\":\"Test\"}}]}]}}","status":"ENABLED"}
2024-06-17 20:13:22.225 [DEBUG] [control.internal.handler.EchoHandler] - Handle updateState amazonechocontrol:echo:amazon_ac:echo_bed
2024-06-17 20:13:22.226 [DEBUG] [mazonechocontrol.internal.Connection] - Make request to https://alexa.amazon.com.au/api/np/player?deviceSerialNumber=XXXXXXXXXXXX&deviceType=A32DOYMUN6DTXA&screenWidth=1440
2024-06-17 20:13:22.568 [DEBUG] [mazonechocontrol.internal.Connection] - Call to https://alexa.amazon.com.au/api/behaviors/preview succeeded
2024-06-17 20:13:22.694 [DEBUG] [mazonechocontrol.internal.Connection] - Call to https://alexa.amazon.com.au/api/np/player?deviceSerialNumber=XXXXXXXXXXXX&deviceType=A32DOYMUN6DTXA&screenWidth=1440 succeeded
2024-06-17 20:13:22.695 [DEBUG] [mazonechocontrol.internal.Connection] - Result of GET https://alexa.amazon.com.au/api/np/player?deviceSerialNumber=XXXXXXXXXXXX&deviceType=A32DOYMUN6DTXA&screenWidth=1440:{"playerInfo":{"hint":null,"infoText":null,"isPlayingInLemur":false,"lemurVolume":null,"lyrics":null,"mainArt":null,"mediaId":null,"miniArt":null,"miniInfoText":null,"playbackSource":null,"playingInLemurId":null,"progress":null,"provider":null,"quality":null,"queueId":null,"state":null,"template":null,"transport":null,"upNextItems":null,"volume":null}}
2024-06-17 20:13:27.169 [DEBUG] [mazonechocontrol.internal.Connection] - removed XXXXXXXXXXX device XXXXXXXXXXXX
2024-06-17 20:13:30.761 [DEBUG] [trol.internal.handler.AccountHandler] - updateSmartHomeState started with deviceFilterId=null

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