Announcement

Collapse
No announcement yet.

Amazon's Alexa and HS2Pro - working well!

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Amazon's Alexa and HS2Pro - working well!

    Hi all, not sure how much traffic this subforum gets now that hs2 is old news. I still happily run it and its been great for me all of these years.

    Recently, I've acquired an Amazon Echo Dot and have looked on the forums if anyone has connected it to HS2/Pro. It seems the HS3 methods don't work since they require the myhomeseer connection/service that connects with the amazon lambda function and associated skill.

    Well after some searching on the interwebs, I've discovered a pretty good way to allow Alexa to send queries to my home automation system (Jarvis) without sending any of my home automation information over the internet.

    The process is alittle complicated but basically it goes like this:
    1) Create a "dummy" skill and "dummy" lambda function on the amazon's developer and web services. I say "dummy" since the only thing the skill does is have Alexa always reply with "OK." You can have her say whatever or nothing.
    2) In a chrome/firefox browser on your home automation computer (that I assume is running 24/7), open up and sign-in to http://alexa.amazon.com/spa/index.html#settings/dialogs
    3) press ctrl+shift+i to open developer tools in chrome, then click console tab
    4) Inject javascript copy/paste (See below) into page. What this does is monitor each query you make to alexa via the alexa history webpage and if if finds your query to comprise a keyword (in my case "jarvis") it sends the query to my HS software
    5) In HTML folder of HS, create an ASP page that receives GET request and processes the request based upon string of commands.

    So yeah thats basically it. Step 5 isn't an easy thing to whip up but if you start slow and add one command function at a time you can append commands and ultimately end up with alot of functions.

    Here is the javascript I referred to above:
    Code:
    var lastCommand;
    $(document).ajaxComplete(function(){
      command = $(".dd-title.d-dialog-title").first().text()
      if(lastCommand != command){
        var pos = command.search("jarvis")
        if(pos >= 0){
    	  var res = command.split("jarvis",2)
          $.get("http://username:password@localhost:port/jarvis.asp?command="+res[1])
          lastCommand = command;
    	}
      }
    })
    Here is a sample of the ASP page I use:
    Code:
    <% 'VBSCRIPT - get
    
    jcommand = Request.QueryString("command")
    hs.writelog "Alexa","Received command: " & jcommand 
    if InStr(lcase(jcommand), "second floor temperature") > 0 then
    			hs.writelog "Alexa","Speaking: The current second floor temperature is " & int(hs.DeviceValue("Q61")) / 100
    			hs.speak "Hello, the current second floor temperature is " & int(hs.DeviceValue("Q61")) / 100 & ".  Have a splendid day!", True
    end if
    
    %>

    #2
    Superstar.

    I like this approach and may try it in HS3.

    Comment


      #3
      I am developing my own Alexa and Google integration w/ HS2

      I am developing actively developing an Alexa skill to talk with both my rooted wink hub and my HS2 installation. I also integrated Google Now to control both controllers. I'm using Node-Red on a RPi to tie everything together. I also have MQTT integration working between my HS2 environment and my Wink Hub / MQTT devices. So far I can control devices and run events from my Echo's and from my android devices. My setup is not for the faint of heart as it does take considerable development and maintenance time but I am a tinkerer and don't mind.

      Best,
      Frank

      Comment


        #4
        HS2 mqtt

        Would you share your achievements for us die hard HS2 users.
        I do own HS3 however migration scares me as I have too many devices, events and most importantly custom scripts.
        Like you I'm home automation enthusiast and now I'm looking for MQTT plug-in for HS2.
        I did manage to integrate HS2 with Siri and now I talk to my HS2. Interested to see how integration with Alexa and Google work.

        Cheers,

        RISquare

        Comment


          #5
          I just came across this. I've been looking for an HS2 solution and had thought I'd be on my own. It's nice to see I'm not the only hard boiled HS2 user left. While I do have an HS3 license, I intend to stick with HS2 because it serves my needs well, the time required to convert my system and the cost of replacing needed plugins would be prohibitive.
          Questions however before I venture into the rabbit hole:
          Does this solution still work given that the Echo API I believe has since changed?
          Is this going to require me to start Firefox and inject the Java code each time I reboot the machine, and if so is there a method available to automate that process?
          And finally, has anyone at all developed another, perhaps more elegant solution?
          Thanks.
          Real courage is not securing your Wi-Fi network.

          Comment


            #6
            Since Amazon have changed their URL from http to https, this no longer works. The only way around this would be to switch your HS2 web server to https.
            Jon

            Comment


              #7
              Knew it was too easy. Thanks Jon
              Real courage is not securing your Wi-Fi network.

              Comment


                #8
                Actually, this still works for me fine even with the change to HTTPS. The modification that had to be done is quite simple. You cannot use the GET command due to chrome not liking the use of mixed http vs. https calls so, I just open up a new window with the url of the command to hs2 instead. Works still to this day!

                Comment


                  #9
                  Originally posted by juve021 View Post
                  Actually, this still works for me fine even with the change to HTTPS. The modification that had to be done is quite simple. You cannot use the GET command due to chrome not liking the use of mixed http vs. https calls so, I just open up a new window with the url of the command to hs2 instead. Works still to this day!
                  Would you provide more detail/example?
                  Jon

                  Comment


                    #10
                    Originally posted by jon00 View Post

                    Would you provide more detail/example?
                    Something like this:

                    Code:
                    var actualCode = '(' + function() {
                        var lastCommand;
                        $(document).ajaxComplete(function() {
                          command = $(".dd-title.d-dialog-title").first().text();
                          if(lastCommand != command){
                            var pos = command.search("jarvis");
                            if(pos >= 0){
                                var res = command.split("jarvis",2);            
                                // $.get("http://username:password@hs2url/jarvis.asp?command="+res[1]);
                                window.open("hs2url/jarvis.asp?command="+res[1]);
                                lastCommand = command;
                            }
                          }      
                        });
                    } + ')();';
                    var script = document.createElement('script');
                    script.textContent = actualCode;
                    (document.head||document.documentElement).appendChild(script);
                    script.parentNode.removeChild(script);
                    replace 'hs2url' with the port and url to your hs2 and username password

                    of course I'm using an older version of chrome, version 31.xxx

                    Comment


                      #11
                      Now he tells me. I'm a week into migrating to HS3. This was one of the reasons for doing so. Perhaps though I can adapt this to HS3 and avoid having to use MyHS.
                      Real courage is not securing your Wi-Fi network.

                      Comment

                      Working...
                      X