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

ihf

Active Member
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).
 
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
 
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);
}
 
 
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.
 
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
 
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!
 
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.
 
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!
 
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 :)
 
Ok still not clear where to put this file that you offered.  Also I think it gets an ending > ? Just making sure
 
Thanks,
 
Neil
 
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://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-osx-10-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.
 
ihf said:
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://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-osx-10-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...
 
Back
Top