Announcement

Collapse
No announcement yet.

How to capture Alexa commands

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to capture Alexa commands

    I'm trying to figure out/understand how to capture verbal commands given to an Alexa. Everything I have found so far seems very vague. I have the HS skill enabled and it is working. I have seen some posts making reference to a check_vcmb.vb script that is supposed to intercept Alexa commands sent to HS but nothing explaining how it is called when an Alexa command is sent to HS.

    How do I tap into the commands sent to HS from Alexa?

  • #2
    Have you looked at the script? It is a function, and "DATA" is the variable that contains the recognized VR word(s). So, from there you do whatever you want in script code.

    Since it is a function you will need to RETURN something back to the calling routine. The returned statement is what Alexa will say back to you.

    In the TRY/CATCH you can do a bunch of IF/Then logic or SELECT CASE logic to whatever you want.

    If you're not familiar with scripting, then Jon00's Alexa helper will make it a lot easier as you will not have to write code.

    It's literally that simple.

    Code:
    
    Function Main(ByVal Data As String) As String
        Try
            hs.writelog("From Alexa", Data)
            Return "I heard " & Data
        Catch Ex As Exception
            Return "There was an error processing your command within HomeSeer."
        End Try
    End Function

    What do you want to do with the speech that Alexa sends to HomeSeer?
    HomeSeer 2, HomeSeer 3, Allonis myServer, Amazon Alexa Dots, ELK M1G, ISY 994i, HomeKit, BlueIris, and 6 "4k" Cameras using NVR, and integration between all of these systems. Home Automation since 1980.

    Comment


    • #3
      Krumpy - thanks for replying. I guess my question should have been, what calls the function because I have a check_vcmb.vb file in my scripts folder that does basically what you provided above... writes to the log.... just nothing happens. Documentation is a bit sparse on this topic and gives the impression that HS will just recognize the check_vcmb script exists and process it. How is the script file initially called?

      As for what I want to accomplish... right now I'm in the exploring stage but ultimately would like to be able to identify which Alexa device the request originated from, parse the request and eventually process the request along a decision tree type concept.

      I looked at the Jon00 helper but could never get it to work.

      Comment


      • #4
        Interesting.... After you speak to Alexa, the Amazon cloud will process and convert the spoken words into JSON text which is sent to the HomeSeer cloud, and then back via myHS to your system. HomeSeer.EXE will then send the spoken text to the above script for further processing.

        Jon00's script does work. If it doesn't work for you then I would think that the above script will not send anything to you as well. If this is true, then you have an issue between Alexa and HomeSeer. You will need to resolve that issue before any downstream processing can occur within HomeSeer.

        My understanding is that with the latest beta of HomeSeer the device id code is being sent as well. Haven't played with that myself, but that is what tonight is for.
        HomeSeer 2, HomeSeer 3, Allonis myServer, Amazon Alexa Dots, ELK M1G, ISY 994i, HomeKit, BlueIris, and 6 "4k" Cameras using NVR, and integration between all of these systems. Home Automation since 1980.

        Comment


        • #5
          Krumpy - Sooooo.... after several hours of searching online I discovered the following.... I had a compounded configuration issue.

          I found a post stating that HS only allows one Alexa device to be linked to a HS account unless you purchase an annual license for additional accounts. We have three Alexa devices, each registered to separate accounts associated to each user. I originally added the HS Alexa skill to each one not realizing at the time that the configuration would switch to the last one configured.

          That would explain part of the issue... one of my daughters Alexa was the last configured and is in her room. When in the living room the Alexa in that area would not function when given commands for HS as the configuration was not associated to that device. I removed the Alexa skills from my daughter's devices and Alexa and HS functioned as expected with the exception of the check_vcmd script executing.

          Upon further research I discovered the check_vcmd script only works with one of the HS Alexa skills.... and yes, I didn't have the correct one enabled. When I switched over to the other HS skill the script functioned. I preferred the simplicity of just saying "Alexa... do x" instead of having to say "Alexa, ask HS to do x" and that is why I had the incorrect skill configured.

          Now my fun begins...

          Comment


          • #6
            Maybe you might want to research "account profiles" and have her learn voices. Then you may be able to use one account. Of course, not sure how well that works.

            I myself am starting all over to separate the Amazon account I use for purchases and the one which is used by Alexa. Here, the family will use one account with Alexa but potentially use multiple voice profiles. In the back of my mind a little voice is saying good luck.. Yeah. Not sure if it will work.
            HomeSeer 2, HomeSeer 3, Allonis myServer, Amazon Alexa Dots, ELK M1G, ISY 994i, HomeKit, BlueIris, and 6 "4k" Cameras using NVR, and integration between all of these systems. Home Automation since 1980.

            Comment


            • #7
              Starting with Homeseer version 3.0.0.478 you can also use check_vcmd2.vb which sends 3 parameters from Alexa to Homeseer as an array:

              Code:
              Function Main(ByVal Data As Object) As String
                  hs.writelog("Parm0",Data(0)) ' Alexa Voice Text
                  hs.writelog("Parm1",Data(1)) ' Alexa ID String
                  hs.writelog("Parm2",Data(2)) ' Alexa Source (normally Amazon)
                  Return ""
              End Function
              Now you have this running correctly, you should try using my Alexa helper again. I think it will do everything you want to do (if not let me know!).
              Jon

              Comment


              • #8
                Krumpy - during my searching last night I came across a couple of posts discussing the use of different accounts and the nuances associated. That seemed like a bit of a hassle having to switch accounts to perform certain tasks or ask Alexa which account was currently in use if a command didn't work.

                jon00 - I will give it another look.

                Comment

                Working...
                X