mirror of
https://github.com/mtan93/homeassistnest.git
synced 2026-03-08 05:31:53 +00:00
Create cancel_hot_water.php
This commit is contained in:
30
cancel_hot_water.php
Normal file
30
cancel_hot_water.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Edit these variables
|
||||||
|
$access_key = "accessk3y";
|
||||||
|
$nest_username = "emailaddy";
|
||||||
|
$nest_password = "passw0";
|
||||||
|
|
||||||
|
require_once('nest-php-api.php');
|
||||||
|
|
||||||
|
$date = new DateTime();
|
||||||
|
$str_date = $date->format('Y-m-d H:i:s');
|
||||||
|
// Check if a key has been sent?
|
||||||
|
if (empty($_GET['key'])) {
|
||||||
|
$return = json_encode( array("error"=>array( "code"=>401, "text"=>"Access Denied", "message"=>"The key was missing" )));
|
||||||
|
}
|
||||||
|
// If it has check if it is correct
|
||||||
|
else if ($_GET['key']==$access_key) {
|
||||||
|
$nest = new Nest($nest_username,$nest_password);
|
||||||
|
$return = $nest->setHotWaterBoost(0);
|
||||||
|
}
|
||||||
|
//If not correct one has been passed but it is wrong
|
||||||
|
else {
|
||||||
|
$return = json_encode( array("error"=>array( "code"=>401, "text"=>"Access Denied", "message"=>"The key was wrong" )));
|
||||||
|
}
|
||||||
|
|
||||||
|
// return json response and log to testing file
|
||||||
|
echo $return;
|
||||||
|
file_put_contents("test.txt","$str_date $return", FILE_APPEND);
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user