Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Alexa 'retrievable' (not all strictly Perl)

by Bod (Parson)
on Jan 02, 2021 at 13:47 UTC ( [id://11126138]=perlquestion: print w/replies, xml ) Need Help??

Bod has asked for the wisdom of the Perl Monks concerning the following question:

Happy New Year to all in and visiting the Monastery

This isn't all a strictly Perl question but I know that here we have a huge diversity of knowledge and skill and I am really hoping someone can point me in the right direction as I seem to be getting absolutely nowhere. I've hit the point where "it isn't doing what the documentation says it does" which usually means I am missing something obvious!

As part of the Controlling USB on Raspberry Pi project, I have connected the RPi to Alexa using ngrok to provide the tunnel to the remote device and HTTP::Server::Simple to handle instructions from Alexa. I specifically wanted to use Smart Home instead of a Skill so that we can use Alexa, open the curtains instead of having to use Alexa, ask the curtains to open. The major downside of this choice is having to use AWS Lambda to handle the calls. But...*sigh of relief*...it is all working and Alexa can open and close the curtains :)

What Alexa cannot do is report whether or not the curtains are open.

Within the Discovery.Response directive that I send to Alexa, I set "retrievable": true which should allow me to ask Alexa, are the curtains open?. When I ask that I get Sorry, curtains doesn't support that and no ReportState directive is passed to my code on Lambda.

This is the relevant part of the "capabilities" section of the Discovery.Response directive.

"capabilities": [ { "type": "AlexaInterface", "interface": "Alexa.ToggleController", "instance": "Curtains", "version": "3", "properties": { "supported": [ { "name": "toggleState" } ], "proactivelyReported": false, "retrievable": true, "nonControllable": false }, "semantics": { "actionMappings": [ { "@type": "ActionsToDirective", "actions": [ "Alexa.Actions.Close" ], "directive": { "name": "TurnOff", "payload": {} } }, { "@type": "ActionsToDirective", "actions": [ "Alexa.Actions.Open" ], "directive": { "name": "TurnOn", "payload": {} } } ] } } ]
Any suggestions of what I can try to debug the problem would be greatly appreciated.

Back to Perl - does anyone have any experience of using Perl within the AWS Lambda ecosystem using AWS::Lambda? Is it as easy an the documentation makes out? I can foresee all sorts of issues with creating an EC2 instance and trying to ensure all the paths are correct when deploying the Perl build.

Replies are listed 'Best First'.
Re: Alexa 'retrievable' (not all strictly Perl)
by shmem (Chancellor) on Jan 02, 2021 at 15:32 UTC

    With a lot of handwaving - I don't use Alexa or anything alike, don't endorse that and have no idea of the underlying stuff - could it be possible that you need to add another hash to the array keyed as "supported"? something like

    { name: "reportState" }

    or such?

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      There's nothing like that in the documentation...
      Not that necessarily means that it isn't what is needed!

      Part of the problem is the lengthy process of testing it. It needs the skill disabling in the Alexa app, then discovery have to happen which takes upward of a minute, then configuration followed by testing that the open/close functionality is working to prove that discovery happened right and then, finally, we get to ask "Alexa, are the curtains open" so we can check the Lambda logs to see if we have a ReportState directive...

Re: Alexa 'retrievable' (not all strictly Perl)
by 1nickt (Canon) on Jan 04, 2021 at 11:51 UTC

    Hello Bod, please update or let me know if you have any success with the Perl Lambda implementation. Certainly does make it look easy.

    Cheers
    -nick


    The way forward always starts with a minimal test.
      please update or let me know if you have any success with the Perl Lambda implementation

      I will do when I get around to trying it.

      For now I am using Node.js heavily modified from this blog. It took me an age to get it working but once I realised that is for v2 and I am using v3, it made more sense!

      Next time I do anything with AWS Lambda I will try the Perl implementation although I have no idea when that will be!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11126138]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 23:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found