forked from chriseng/nestgraph
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollectEnergy.php
53 lines (45 loc) · 1.04 KB
/
collectEnergy.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?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();
$energy = $nest->getEnergyLatest();
//Change nulls to 0
foreach ($energy->days as &$day)
{
foreach ($day->events as &$events)
{
if ( empty($events -> continuation) )
{
$events -> continuation = 0;
}
if ( empty($events -> touched_by) )
{
$events -> touched_by = 0;
}
if ( empty($events -> touched_when) )
{
$events -> touched_when = 0;
}
if ( empty($events -> touched_timezone_offset) )
{
$events -> touched_timezone_offset = 0;
}
if ( empty($events -> touched_where) )
{
$events -> touched_where = 0;
}
}
unset($events);
}
unset($day);
return $energy;
}
function c_to_f($c) {
return ($c * 1.8) + 32;
}
?>