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

1. That is the ip address and port for HH.
2. Yes, those are your HH credentials (just as you use for the Web interface.
3. Post your PHP code (minus your authentication)...thgough I would also suggest tyring the URL of the .php file from a browser and see what happens (also check the apache2 log)
 
<?php
define('HHAPI_URL', ‘http://192.168.1.177:9399/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);
}
 
I think you said you wanted to control device #66 so try changing the 3 to 66 in the unitWithNumber references.
 
This is what Ive pasted the the url in the ha bridge website
 
/Library/WebServer/Documents/Living Room Fireplace.php
 
I went with my fireplace light because that's device #3 same as post #20
 
When I went to 192.168.1.177:9399/Library/WebServer/Documents/Living Room Fireplace.php it asked for a username and password.  I entered my HH web interface username and password.  When I hit enter the page was blank.
 
Where do I go to get the  /var/log/apache2/access.log and error.log?
 
the Library/Webserver/Documents is added by the webserver. The URL is just http://192.168.1.177:9399/Living Room Fireplace.php
 
To access the logs, open a Terminal on the mini and cd /var/log/apache2. Then see what the end of the access.log and error.log fields say.
 
The URL still comes up with a blank page.
 
In the Terminal I typed in cd /var/log/apache2/access.log and cd /var/log/apache2/error.log.
 
Both came back with no such file or directory.
 
I also tried cd /var/log/apache2.  That change to the apache2 folder. Then I typed error.log...says command not found
 
Same when I typed access.log.
 
Ok you have to put some basic echo output in your code. I had some problems with the code. I thought I posted exactly what I was using in it's entirety. I'm still on vacation so I'm a bit useless but google php output and try adding some echo lines so you know you're Inc the right place.
 
you can't cd to a file. try ls or cd to /var/log/apache2 and do an ls -tl
 
the url will not come back with anything, it will just use the api
 
try typing  tail /var/log/apache2/access.log or error.log  that should show the most recent entries.
 
Paddack-Mac-mini:~ dwpaddack$ tail /var/log/apache2/access.log
tail: /var/log/apache2/access.log: No such file or directory
 
Paddack-Mac-mini:~ dwpaddack$ tail /var/log/apache2/error.log
tail: /var/log/apache2/error.log: No such file or directory
 
No worries at all. That did the trick
 
Paddack-Mac-mini:~ dwpaddack$ tail /var/log/apache2/access_log
::1 - - [20/Oct/2016:21:02:09 -0500] "GET /~user/file.php HTTP/1.1" 404 212
::1 - - [20/Oct/2016:21:02:09 -0500] "GET / HTTP/1.1" 200 45
::1 - - [20/Oct/2016:21:02:17 -0500] "GET /~user/file.php HTTP/1.1" 404 212
::1 - - [20/Oct/2016:21:02:24 -0500] "GET /~user/file.php HTTP/1.1" 404 212
::1 - - [20/Oct/2016:21:02:24 -0500] "GET /~user/file.php HTTP/1.1" 404 212
::1 - - [20/Oct/2016:21:09:44 -0500] "GET / HTTP/1.1" 200 45
::1 - - [20/Oct/2016:21:10:02 -0500] "GET / HTTP/1.1" 200 45
::1 - - [20/Oct/2016:21:12:43 -0500] "GET / HTTP/1.1" 200 45
::1 - - [20/Oct/2016:21:18:46 -0500] "GET / HTTP/1.1" 200 45
::1 - - [21/Oct/2016:10:36:56 -0500] "GET /Living%20Room%20Fireplace.php HTTP/1.1" 200 176
 
Paddack-Mac-mini:~ dwpaddack$ tail /var/log/apache2/error_log
[Wed Oct 19 21:36:38.691650 2016] [core:notice] [pid 525] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Thu Oct 20 20:57:37.271705 2016] [mpm_prefork:notice] [pid 525] AH00169: caught SIGTERM, shutting down
No log handling enabled - using stderr logging
Created directory: /var/db/net-snmp
Created directory: /var/db/net-snmp/mib_indexes
[Thu Oct 20 20:57:38.352178 2016] [mpm_prefork:notice] [pid 2513] AH00163: Apache/2.4.18 (Unix) PHP/5.5.36 configured -- resuming normal operations
[Thu Oct 20 20:57:38.352291 2016] [core:notice] [pid 2513] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Thu Oct 20 21:11:31.281418 2016] [mpm_prefork:notice] [pid 2513] AH00169: caught SIGTERM, shutting down
[Thu Oct 20 21:11:54.566095 2016] [mpm_prefork:notice] [pid 76] AH00163: Apache/2.4.18 (Unix) PHP/5.5.36 configured -- resuming normal operations
[Thu Oct 20 21:11:54.581350 2016] [core:notice] [pid 76] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
 
Back
Top