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

It only asked me for username and password once, then it just comes back with a blank page.
 
Or the error I mentioned earlier.
 
It should never ask for credentials if you enter that URL into the browser. As for the Parse error, perhaps heffnell can help as that is not the code I am using.
 
This is driving me crazy. I don't suppose there's any way to speak to one of you on the phone? Is there a way we can exchange private information?
 
Code is identical from my server so it should work.  I can only think that there is hidden characters in it perhaps? I use Brackets for my editor which is easy to use...
 
Not sure about the U/P request but if it runs in the browser and still doesn't work something is wrong.  You have the port for HaikuHelper and the IP in the beginning of the code set correctly right? The port is the port for HaikuHelper - not anything else?
 
If you're getting an error on that file there has to be something in the file because of the editor or something is missing when you modified?
 
I didn't modify anything in the file. I copied and pasted exactly what you posted.

<?php
define('HHAPI_URL', 'IP_OF_HAIKUHELPER:pORT_OF_HAIKUHELPER port/api');
define('HHAPI_USER', ‘XXXX’);
define('HHAPI_PASS', ‘YYYY!’);
 
//  hhapi calls
 
// Grab the name and date properties from the controller object
if (isset($_GET["dim"])) { // Check to see if DIM is defined so run the DIM command
    hhapi('controller.unitWithNumber('.$_GET["DeviceNum"].').setLevel('.$_GET["dim"].')');
}
elseif(isset($_GET["newTargetValue"])) { //See If we are passing a unit number to turn on or off
   if ($_GET["newTargetValue"] == 1){ //Value is 1 so turn switch ON
        hhapi('controller.unitWithNumber('.$_GET["DeviceNum"].').on()');
   }
   elseif($_GET["newTargetValue"] == 0){ //Value is 0 so turn switch OFF
   hhapi('controller.unitWithNumber('.$_GET["DeviceNum"].').off()');
   }
}
elseif (isset($_GET["Button"])) { //Passing a button name to exectute that button
   hhapi('controller.buttonWithName("'.$_GET["Button"].'").activate()');
}
elseif (isset($_GET["Temp"])) { //Passing a button name to exectute that button    
   hhapi('controller.thermostatWithNumber('.$_GET["Thermostat"].').setCoolSetpoint('.$_GET["Temp"].')');
 echo("Yay for Me!");
}
    
    
 
 
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);
}
?>
 
Change this: define('HHAPI_URL', 'IP_OF_HAIKUHELPER:pORT_OF_HAIKUHELPER port/api');
 
To: define('HHAPI_URL', '192.168.1.177:9399 port/api');
 
When I do that I get this error:
 
Parse error: parse error, expecting `"identifier (T_STRING)"' in /Library/WebServer/Documents/HaikuHelper.php on line 10
 
Is it because his username has a space in it?

define('HHAPI_USER', Pxx Hxx);

I'm guessing HH doesn't like a space in a username in rest API calls
 
Back
Top