forked from chriseng/nestgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollect.php
28 lines (22 loc) · 786 Bytes
/
collect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require 'inc/config.php';
require 'nest-api-master/nest.class.php';
define('USERNAME', $config['nest_user']);
define('PASSWORD', $config['nest_pass']);
date_default_timezone_set($config['local_tz']);
function get_nest_data() {
$nest = new Nest();
$info = $nest->getDeviceInfo();
$data = array('heating' => ($info->current_state->heat == 1 ? 1 : 0),
'timestamp' => $info->network->last_connection,
'target_temp' => sprintf("%.02f", (preg_match("/away/", $info->current_state->mode) ?
$info->target->temperature[0] : $info->target->temperature)),
'current_temp' => sprintf("%.02f", $info->current_state->temperature),
'humidity' => $info->current_state->humidity
);
return $data;
}
function c_to_f($c) {
return ($c * 1.8) + 32;
}
?>