Alexa TTS (Text-To-Speech) [and more] plug-in for Vera

So I can not use the plugin?

You cannot use features enabled by 7.32. TTS will work.

I have 2FA and when entering alexa.amazon.com from browser I get sms with OTP. So what am I doing wrong since I don’t get sms when I send command to the plugin? Instead it just gets this:

50 01/08/21 10:17:41.373 luup_log:607: VeraAlexa0.91@607:setVar(“urn:bochicchio-com:serviceId:VeraAlexa1”,“LatestResponse”,“cookie does not exist. logging in … ERROR: Amazon Login was unsuccessful. Possibly you get a captcha login screen. Try logging in to https://alexa.amazon.com with your browser. In your browser make sure to have all Amazon related cookies deleted and Javascript disabled! (For more information have a look at /etc/cmh-ludl/VeraAlexa/.alexa.login) To avoid issues with captcha, try using Multi-Factor Authentication. To do so, first set up Two-Step Verification on your Amazon account, then configure this script (or the environment) with your MFA secret. Support for Multi-Factor Authentication requires ‘oathtool’ to be installed.”,607) old value “cookie does not exist. logging in … ERROR: Amazon Login was unsuccessful. Possibly you get a captcha login screen. Try logging in to https://alexa.amazon.com with your browser. In your browser make sure to have all Amazon related cookies deleted and Javascript disabled! (For more information have a look at /etc/cmh-ludl/VeraAlexa/.alexa.login) To avoid issues with captcha, try using Multi-Factor Authentication. To do so, first set up Two-Step Verification on your Amazon account, then configure this script (or the environment) with your MFA secret. Support for Multi-Factor Authentication requires ‘oathtool’ to be installed.” <0x2daf1680>

I read here that I can’t have oathtool on Vera so I didn’t even try to read about it but from what I read I thought I should be able to use it with the sms code and the link you posted earlier:

http://veraIP :3480/data_request?id=variableset&DeviceNum=666&serviceId=urn:bochicchio-com:serviceId:VeraAlexa1&Variable=OneTimePassCode&Value=OTPVALUE

I checked the file .alexa.login and it has my email in it so it reads and sends username and password properly but in that file I see that amazon asks for captcha even though I have 2FA enabled. So what could be wrong?

As you can see here: Login requires captcha inspite of using MFA · Issue #101 · thorsten-gehrig/alexa-remote-control (github.com) you’re not alone.

I’m personally using it on a Linux box (via openLuup), so I’m running oathtool on a standard Ubuntu installation and it’s working flawlessly since 2+ years. It really depends on how lucky you are to have (or not) Amazon send you a captcha. Sometimes getting the cookie (see readme pointing to this thread) the first time will work, sometimes not.

I’ll probably go get some device to have oathtool on it but for now just for the test I read I should be good to go for like 14 days if I extract cookie from my browser into .alexa.cookie file.
So can you please tell me which one of these I need or do I need them all?

And is this the format it will accept and use or something else:

# Domain     Tailmatch  Path  Secure Expires Name  Value
www.example.com  TRUE        /    FALSE  0       id    1234

I’ve generated .alexa.cookie with cookie values that I have in my browser but since I have never logged with the script I don’t know the format that it expects. So I get this response from Amazon Sign-In to my generated cookie file:

Error while parsing cookie header

So if it is possible please give me an example of that .alexa.cookie file, please!

It should be netscape format .alexa.cookie.zip (1.3 KB)

i clear amazon cookies, then log in to layla.amazon.co.uk (uk area), then use firefox addon export cookie to export the amazon domain.

1 Like

Thank you ! I finally made it through :slight_smile:

I’m so happy now.

Just one thing I found out. I have Sonos devices with Alexa on them. If I try the command with “Living Room” what’s my Sonos Beam nickname no speech comes out, only the volume gets changed. But when the same command goes with “Sonos Beam” - voice comes out. So I checked the .alexa.devicelist.json and saw it - for some reason the very same device has 2 instances with different capabilites.

I’ll be playing with this new addition to my smart home this weekend :slight_smile:

Thank you very much therealdb

Just one more thing - is there a way NOT to change the volume? At the moment I’m listening at a very low volume since I’m alone at home and I’m working so if Vera has something to say to me that will change the volume to the preset one which when I listen to some music streming services is not good - Soundcloud is kind of very loud compared to some others. I’m listening to Soundcloud right now and the volume is set to 10% and it is fine but if I’m watching TV it should be at least 40 or 50%. So any way to have the command run at the volume of the speaker without changing it?

1 Like

I found another interesting bug for Sonos with Alexa - that it returns weird values for volume. As I said it has 2 instances of 1 device - trying to get its volume the way alexa sh script does I get:
{“clientId”:null,“contentId”:null,“contentType”:null,“currentState”:“IDLE”,“imageURL”:null,“isDisliked”:false,“isLiked”:false,“looping”:false,“mediaOwnerCustomerId”:null,“muted”:false,“programId”:null,“progressSeconds”:0,“providerId”:null,“queue”:null,“queueId”:null,“queueSize”:0,“radioStationId”:null,“radioVariety”:0,“referenceId”:null,“service”:null,“shuffling”:false,“timeLastShuffled”:0,“volume”:1}

and for the other instance of the same device I get:
{“clientId”:null,“contentId”:null,“contentType”:null,“currentState”:“IDLE”,“imageURL”:null,“isDisliked”:false,“isLiked”:false,“looping”:false,“mediaOwnerCustomerId”:null,“muted”:false,“programId”:null,“progressSeconds”:0,“providerId”:null,“queue”:null,“queueId”:null,“queueSize”:0,“radioStationId”:null,“radioVariety”:0,“referenceId”:null,“service”:null,“shuffling”:false,“timeLastShuffled”:0,“volume”:50}

And the bad thing is none of these is true. It is at about 20-25% at the moment :frowning:

So I edited the alexa_remote_control_plain.sh and now it just executes TTS at the volume that it is at that moment without changing it for the TTS or after it.

Offtopic: I’m sorry for this offtopic but I’ve been trying to find this out for a while and since everyone here is using both Vera and Alexa maybe someone knows:

I have a few scenes in Vera that I start with voice from Alexa. Is there a way (command or a variable) that will tell me which Alexa device has initiated the scene run?

What I have found from logs is that when such action is triggered it runs Homegateway module. So in S_HomeAutomationGateway1.xml I found this part:

<action>
  <name>RunScene</name>
  <argumentList>
    <argument>
      <name>SceneNum</name>
      <direction>in</direction>
      <relatedStateVariable>DeviceNum</relatedStateVariable>
    </argument>
  </argumentList>
</action>

The rest is pretty clear but this DeviceNum … maybe that holds the Alexa device identifier? Anyone knows how to retrieve it in the scene’s code?

The main goal of course is to trigger Alexa TTS plugin to answer on the same device that was asked. I have 5 devices with Alexa on them so I really would like to target Alexa TTS based on where the voice command was given from.

No, the only way to get the device you’re speaking with is lastalexa command. unfortunately you’ll need jq and it won’t be ready until firmware 7.32 is out.

Or if you execute this script on a Linux machine. In fact I have a coupe of virtual switch to ask things and via lastalexa I get the reply on the device where I’ve asked the question.

1 Like

Thank you very much once again. I just tested querying /etc/cmh-ludl/VeraAlexa/alexa_remote_c
ontrol_plain.sh -lastalexa and I got the serial number of Alexa device. So nice :slight_smile: I don’t have jq nor I will ever be able to update to firmware 7.32 so I don’t know what will that jq bring as features but this “lastalexa” is available even now. So thank you for givin me that keyword “lastalexa” to search for.

P.S. Once again using Alexa with Sonos (and probably other 3rd party devices) will give wrong result with default library so it will need editing for me (and for anyone using such 3rd party devices). This command gives me the serial number of device called “Living Room” which if I target for TTS doesn’t “speak out”. Same physical device has another instance called “Sonos Beam” that works when targeted with TTS command but it is with different serial number. I doubt it will be fixed in the official alexa remote script ever.

So, 7.32 beta added jq support :tada::partying_face:

ssh to your unit, then run

opkg update
opkg install jq

or simply set Configured to 0. Enjoy announcments, routines and all the features! :slight_smile:

Hello All -

I’m trying to groupzones=“ALL” to work even if it plays on all devices sequentially. However, it doesn’t appear to work. If I choose just one device, it works fine. I’ve tried All, ALL, and all. Am I missing something. I’ve thumbed through the ~670 messages here but may have missed something. Apologies.

All is hit or miss. Groups are available with jq and announcements.

Thanks. May just have to wait for 7.32

1 Like

Remind me please where one finds the ‘jq’ package, and how to install it? (I feel as though this vital step is being glossed over in the documentation)

Thanks!

jq is automatically supported under 7.32 beta and the plugin will try to install it. Just set configured variable to 0, luup.reload and it should be auto-configured.

2 Likes

Hi,

I have now got a spare VeraPlus, so upgraded it to 7.32 Beta, uploaded the latest TTS files, and cleared the config flag. I can see in the logs that JQ is now installed :slight_smile:

I have changed the lua to send a TTS command " -lastalexa -e speak:“Generating–0-watts,-battery-is-at-21-percent,” instead of "-d “Lounge” -e “…etc.”

The Debug log shows that the LatestResponse is …“to dev:Lounge type:A4****** serial:^^^^ customerid:***”
so it seems to have picked up the lastalexa id string, but then it shows:

0 04/28/21 0:14:23.551 luup_log:391: VeraAlexa0.95@391:Response from Alexa.sh: “setting default device to: Echo Auto sending cmd:speak:Generating–0-watts,-battery-is-at-21-percent, to Echo Auto type:^^^ serial:^^^ customerid:^^^” <0x6e1ec520>

So something appears to not like the string it returned, and has picked another Alexa device (NOT the one I have set as default in the device config).
Am i doing something wrong, or is it a feature of the TTS driver code?

Thanks
Octo

LastAlexa is an action, not a device endpoint. But, I’ve just added a new feature di 0.97 (get it at GitHub) to get support it directly:

luup.call_action("urn:bochicchio-com:serviceId:VeraAlexa1", 
  "Say",
  {Text="Hello from your last used Alexa device", Volume=50, GroupZones="LASTALEXA", Repeat = 3}, 666)

This is handy when sending a command via a virtual switch or something (a routine), and reply back via Vera to the command you’ve asked your initial question.