Jump to content


Photo
- - - - -

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


  • Please log in to reply
299 replies to this topic

#16 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 04:13 PM

I have to admit I am not very well versed in this but I've spent a couple hours and perhaps I am getting older and I am not further than when I started.  I would love to see some documentation on how to get this working.  I am still a bit unclear how to make the transition from this program to Haiku or how to even use it afterwards.  I think I got the bridge working.  I can't find a place to put this file but once I do, then what?



#17 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 04:14 PM

To get to the Library Directory without much fuss, go to Finder, Go,Go to Folder.... Type  /Library/Webserver and see what you get.



#18 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 04:17 PM

Son of a gun! You got it. Let me try this stuff now.



#19 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 04:38 PM

Yeah ok I have the directory but im really lost.  Let me know if you can explain in dummy terms for me.  Do I need a file for each button or switch? Where are you specifying that in the file?  Very confused  :wacko:



#20 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 04:55 PM

You need to replace the IP and port of the HH server, HH userid, HH password. Then where it says hh api calls, you need to insert the calls that do what you want on the HAI. You will have to refer to the HH Javascript API documentation but here is a full example that can turn a unit (number 3) on/off and  set level:

 

<?php
define('HHAPI_URL', 'http://IP address:port/api');
define('HHAPI_USER', ‘XXX’);
define('HHAPI_PASS', ‘YYY’);

// Grab the name and date properties from the controller object
if (isset($_GET["dim"])) {
    hhapi('controller.unitWithNumber(3).setLevel('.$_GET["dim"].')');
}
else{
   hhapi('controller.unitWithNumber(3).toggle()');
}


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);
}
 

Once this file is in the Webserver directory and the Webserver is started. You can add this device using the bridge's configurator and the URL should point to this file. In the configurator, try clicking the test button to see if the URL is correct and the file works (I.e. controls the device). You will then have to use the Alexa app on your phone and go to Settings, Smart Home, Discover Devices. If the bridge is working, it should say it found devices. At that point you can ask Alexa to turn on/off the device. 

 

Don't give up :-)



#21 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 04:59 PM

Oh, sorry, didn't answer your question...yes there is a file for each device defined in the configurator and possibly a separate file for on or off. The only real difference between these files is the HHAPI calls which are defined int he HH Javascript API doc. If you have a specific thing to do, I can try to construct the call.



#22 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 05:01 PM

Wow I am getting old :)  You're a smart dude.  Now that I have some directions I can actually try this.  Thanks!

 

Neil



#23 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 06:30 PM

The file just goes in the root of the Webserver directory right and named .php?  I get a file not found.  I must be missing something else.

 

I tried test.html test.php and still can't find them.  Im lost and I Know this shouldn't be so hard...


Edited by heffneil, 15 September 2016 - 06:43 PM.


#24 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 07:24 PM

No, it goes in /Library/Webserver/Documents



#25 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 08:27 PM

http://192.168.1.203...ue=1&DeviceNum=

 

This look right?  Because I get a 404



#26 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 08:43 PM

I can't really comment about the full URL since I am using a different (probably older) bridge and the parms may be different. If you are getting a 404 then the webserver must be running at that address and it thinks you do not have a file in the /Library/Webserver/Documents directory that is called HaikuHelper.php. I assume the filename has the correct case and the .php suffix?


Edited by ihf, 15 September 2016 - 08:43 PM.


#27 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 08:45 PM

yeah I mean I put test.html in that directory and it isn't showing either.  This is why I am so confused.  How in the world is anyone figuring this out?  I need some docs for this thing and I can't find anything but dribs and drabs?



#28 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 08:47 PM

What do you get if you go to http://192.168.1.203:8080?



#29 heffneil

heffneil

    Dedicated Cocooner

  • Registered
  • PipPipPip
  • 635 posts

Posted 15 September 2016 - 08:48 PM

404.  The only page that works is configurator.html



#30 ihf

ihf

    Cocooner

  • Registered
  • PipPip
  • 93 posts

Posted 15 September 2016 - 08:51 PM

Wait...is 8080 the port of the bridge or the webserver...they need to be different.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users