Jump to content


Photo
- - - - -

Using Amazon Alexa devices (Echo, Dot, Tap, etc.) with HAI


  • Please log in to reply
299 replies to this topic

#1 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 14 September 2016 - 01:22 PM

I don't know how much interest there is in using the Amazon Alexa powered devices to control the HAI but I have successfully been doing this for quite some time. In a nutshell, I run the Amazon Echo Bridge on the server with HH. The bridge permits you to control devices that you define by recognizing a name (e.g. garage door) and opening a URL that you specify. I have some devices defined and URL's which when opened run the code to authenticate to HH and call any API feature. If anyone needs more information, let me know.

It would be lovely if the next version of HH/Spaces had this functionality built-in using an Alexa app (as well as Siri integration).



#2 networkcrasher

networkcrasher

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 177 posts
  • Location:Atlanta

Posted 14 September 2016 - 02:22 PM

What are you using for --upnp.config.address and --server.port?  I'm assuming port is arbitrary, but is the ip address supposed to be the local box's IP?  The docs are a bit lacking.

 

would also be cool if you posted some of the rest url's as an example



#3 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 14 September 2016 - 02:42 PM

As you surmised, the upnp address is the local IP. Using the bridge, you point a device to an open and close url (open and close being Alexa verbs---there are synonyms such as turn on/off). The URL can look like this:

 

<?php
define('HHAPI_URL', 'local IP:HH port/api');
define('HHAPI_USER', 'XXX');
define('HHAPI_PASS', 'YYY');

//  hhapi calls


function hhapi($cmd) {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, HHAPI_URL);
        curl_setopt($ch, CURLOPT_USERPWD, HHAPI_USER . ':' . HHAPI_PASS);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $cmd);

        $result = curl_exec($ch);
        $error = curl_error($ch);

        curl_close($ch);

        if($error) echo $error;

        return json_decode($result);
}
 



#4 networkcrasher

networkcrasher

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 177 posts
  • Location:Atlanta

Posted 14 September 2016 - 02:59 PM

have you tried https://github.com/bwssytems/ha-bridge?  Seems like it's actually being maintained



#5 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 14 September 2016 - 03:07 PM

If that isn't exactly what I am using, it is functionally identical in that it emulates a Hue bridge. By the way, I have never gotten "brightness" to work correctly but the problem seems to be in the Echo and not the bridge.



#6 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 06:49 AM

This is great! I wish more people shared the cool stuff they were doing with Haiku Helper!  I noticed on Amazon's site this morning they have the Echo Dot and sell them for buy 5 get one free.  At first I thought that was crazy but I watched the video and if we can really control things I might put one in almost every room of the house!  I have to get testing this ASAP!

 

Thanks!

 

Neil



#7 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 07:17 AM

Ok I installed the bridge but it looks like I have to run on the command line.  Am I wrong about this?  How can I get it to run constantly.  That is about as far as I have gotten.  I don't know what to do next specifically.  I am a little dense when it comes to the PHP Linuxy stuff.  I am proud I got it running without any help :) Yay for me!

 

If I could get some pointing - and I will keep trying, that would be great!



#8 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 07:26 AM

Yes, you typically run it from the command line. If you follow the command with & it will run in the background. In order to get it to start every time you reboot takes a bit more effort but I would get it all working before taking that step. You need to add devices and open and close URLs. For each URL you will need a php file (it could be done with other languages as well) that does the authentication and the hhapi calls. After you have the URLs setup, you tell Alexa (Echo) to look for devices on your network.



#9 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 10:52 AM

Ok I have a lot to learn here.  I don't know how you link up the PHP scripts with Haiku.  Also I don't know how to make the PHP files.  I will do more reading! Tanks for the help!



#10 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 10:54 AM

On the page for the project he talks about the configurator webpage but I don't see it.  I am going to my server at 8080 but I get 

Whitelabel Error Page

 

Which is cute but not helpful :)



#11 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 11:30 AM

Ok so if you go to: http://192.168.1.203...nfigurator.html where 1.203 is my server (for the sake of example) that is the configuration page.  Now to play!



#12 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 12:20 PM

Ok still not clear where to put this file that you offered.  Also I think it gets an ending > ? Just making sure

 

Thanks,

 

Neil



#13 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 12:52 PM

I re-checked and the file is as I have shown it. There is no closing >. Maybe that is added automatically (or ignored) but it is working without it. That file goes into Library/Webserver/Documents. You then need to start the webserver. If you are running El Capitan, Apple removed the simple GUI in System Preferences/Sharing/Web Sharing. In that case, you need to use the terminal. Here are some instructions <https://coolestguide...-11-el-capitan/>. Once the file is in place and the web server (apache) is running, you can go to the URL (the php file) and it should talk to HH.



#14 networkcrasher

networkcrasher

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 177 posts
  • Location:Atlanta

Posted 15 September 2016 - 03:37 PM

the php interpreter has an option to automatically close the php stanzas, but it's better code to put the ?> at the end anyway.



#15 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 04:06 PM

I re-checked and the file is as I have shown it. There is no closing >. Maybe that is added automatically (or ignored) but it is working without it. That file goes into Library/Webserver/Documents. You then need to start the webserver. If you are running El Capitan, Apple removed the simple GUI in System Preferences/Sharing/Web Sharing. In that case, you need to use the terminal. Here are some instructions <https://coolestguide...-11-el-capitan/>. Once the file is in place and the web server (apache) is running, you can go to the URL (the php file) and it should talk to HH.

I don't have Library Webserver.  I got to the library directory (which can be tricky ;) ) but I don't have a webserver directory.  I will continue searching...






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users