Initial commit
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
errors.txt
|
||||||
|
cookies.txt
|
||||||
|
logininfo.php
|
||||||
|
!logininfo.php.example
|
||||||
|
globals.php
|
||||||
|
!globals.php.example
|
||||||
12
README.md
Normal file
12
README.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#Stat stat
|
||||||
|
A set of tools to record and analyze data from a smart thermostat.
|
||||||
|
|
||||||
|
##Thermostat support
|
||||||
|
Currently, only Honeywell Thermostats controllable through their Total Connect system are supported.
|
||||||
|
|
||||||
|
##Installation
|
||||||
|
* Add your database info to globals.php.example. Rename to globals.php
|
||||||
|
* Add your Honeywell Total Connect info to logininfo.php.example. Rename to logininfo.php
|
||||||
|
* Run dbsetup.php
|
||||||
|
* Add a cron job to run scrape.php every 5 minutes.
|
||||||
|
* Wait for useful data to come in
|
||||||
53
current.php
Normal file
53
current.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$q = '';
|
||||||
|
if(isset($_GET)){
|
||||||
|
if(isset($_GET['q'])){
|
||||||
|
$q = $_GET['q'];
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
include('settings/globals.php');
|
||||||
|
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
|
||||||
|
// Check connection
|
||||||
|
if (!$conn) {
|
||||||
|
die("Connection failed: " . mysqli_connect_error());
|
||||||
|
}
|
||||||
|
$sql = '';
|
||||||
|
switch($q){
|
||||||
|
case "inside":
|
||||||
|
$sql = "SELECT dispTemperature from stat ORDER BY id DESC LIMIT 1";
|
||||||
|
break;
|
||||||
|
case 'outside':
|
||||||
|
$sql = "SELECT weatherTemperature from stat ORDER BY id DESC LIMIT 1";
|
||||||
|
break;
|
||||||
|
case 'set_heat':
|
||||||
|
$sql = "SELECT heatSetpoint from stat ORDER BY id DESC LIMIT 1";
|
||||||
|
break;
|
||||||
|
case 'set_cool':
|
||||||
|
$sql = "SELECT coolSetpoint from stat ORDER BY id DESC LIMIT 1";
|
||||||
|
break;
|
||||||
|
case 'humidity':
|
||||||
|
$sql = "SELECT weatherHumidity from stat ORDER BY id DESC LIMIT 1";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
die("No query");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
printf("Errormessage: %s\n", $conn->error);
|
||||||
|
}
|
||||||
|
$rows = array();
|
||||||
|
while($r = mysqli_fetch_assoc($result)) {
|
||||||
|
print array_values($r)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
55
db-get.php
Normal file
55
db-get.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$q = '';
|
||||||
|
if(isset($_GET)){
|
||||||
|
if(isset($_GET['q'])){
|
||||||
|
$q = $_GET['q'];
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
include('settings/globals.php');
|
||||||
|
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
|
||||||
|
// Check connection
|
||||||
|
if (!$conn) {
|
||||||
|
die("Connection failed: " . mysqli_connect_error());
|
||||||
|
}
|
||||||
|
$sql = '';
|
||||||
|
switch($q){
|
||||||
|
case "inside":
|
||||||
|
$sql = "SELECT UNIX_TIMESTAMP(date),dispTemperature from stat";
|
||||||
|
break;
|
||||||
|
case 'outside':
|
||||||
|
$sql = "SELECT UNIX_TIMESTAMP(date),weatherTemperature from stat";
|
||||||
|
break;
|
||||||
|
case 'set_heat':
|
||||||
|
$sql = "SELECT UNIX_TIMESTAMP(date),heatSetpoint from stat";
|
||||||
|
break;
|
||||||
|
case 'set_cool':
|
||||||
|
$sql = "SELECT UNIX_TIMESTAMP(date),coolSetpoint from stat";
|
||||||
|
break;
|
||||||
|
case 'humidity':
|
||||||
|
$sql = "SELECT UNIX_TIMESTAMP(date),weatherHumidity from stat";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
die("No query");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
printf("Errormessage: %s\n", $conn->error);
|
||||||
|
}
|
||||||
|
$rows = array();
|
||||||
|
while($r = mysqli_fetch_assoc($result)) {
|
||||||
|
$row = array_map('floatval',array_values($r));
|
||||||
|
$row[0] = $row[0]*1000;
|
||||||
|
$rows[] = $row;
|
||||||
|
}
|
||||||
|
print json_encode($rows);
|
||||||
|
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
43
dbsetup.php
Normal file
43
dbsetup.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include('settings/globals.php');
|
||||||
|
|
||||||
|
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
|
||||||
|
// Check connection
|
||||||
|
if (!$conn) {
|
||||||
|
die("Connection failed: " . mysqli_connect_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "CREATE TABLE IF NOT EXISTS `stat` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`coolLowerSetpLimit` float NOT NULL,
|
||||||
|
`coolNextPeriod` int(11) NOT NULL,
|
||||||
|
`coolSetpoint` float NOT NULL,
|
||||||
|
`coolUpperSetptLimit` float NOT NULL,
|
||||||
|
`deviceID` int(11) NOT NULL,
|
||||||
|
`dispTemperature` float NOT NULL,
|
||||||
|
`displayedUnits` varchar(1) COLLATE latin1_german2_ci NOT NULL,
|
||||||
|
`heatLowerSetptLimit` float NOT NULL,
|
||||||
|
`heatNextPeriod` int(11) NOT NULL,
|
||||||
|
`heatSetpoint` float NOT NULL,
|
||||||
|
`heatUpperSetptLimit` float NOT NULL,
|
||||||
|
`isInVacationHoldMode` tinyint(1) NOT NULL,
|
||||||
|
`schedCoolSp` float NOT NULL,
|
||||||
|
`schedHeatSp` float NOT NULL,
|
||||||
|
`scheduleCapable` tinyint(1) NOT NULL,
|
||||||
|
`statusCool` int(11) NOT NULL,
|
||||||
|
`statusHeat` int(11) NOT NULL,
|
||||||
|
`systemSwitchPosition` int(11) NOT NULL,
|
||||||
|
`weatherHumidity` varchar(32) COLLATE latin1_german2_ci NOT NULL,
|
||||||
|
`weatherPhrase` int(11) NOT NULL,
|
||||||
|
`weatherTemperature` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci AUTO_INCREMENT=1 ;";
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
printf("Errormessage: %s\n", $conn->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
123
delay.html
Normal file
123
delay.html
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Stat delay</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.5.0/bootstrap-table.min.css">
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||||
|
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||||
|
<script src="http://code.highcharts.com/highcharts.js"></script>
|
||||||
|
<script src="http://code.highcharts.com/modules/exporting.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
console.log('load');
|
||||||
|
var seriesOptions = [];
|
||||||
|
var createChart = function(){
|
||||||
|
console.log('create');
|
||||||
|
$('#container').highcharts({
|
||||||
|
chart: {
|
||||||
|
type: 'scatter',
|
||||||
|
zoomType: 'xy'
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
text: 'Time to heat or cool vs outside temperature'
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
text: 'Because science'
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
title: {
|
||||||
|
enabled: true,
|
||||||
|
text: 'Minutes per degree change'
|
||||||
|
},
|
||||||
|
startOnTick: true,
|
||||||
|
endOnTick: true,
|
||||||
|
showLastLabel: true
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
title: {
|
||||||
|
text: 'Outside temp'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
layout: 'vertical',
|
||||||
|
align: 'left',
|
||||||
|
verticalAlign: 'top',
|
||||||
|
x: 100,
|
||||||
|
y: 70,
|
||||||
|
floating: true,
|
||||||
|
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
|
||||||
|
borderWidth: 1
|
||||||
|
},
|
||||||
|
plotOptions: {
|
||||||
|
scatter: {
|
||||||
|
marker: {
|
||||||
|
radius: 5,
|
||||||
|
states: {
|
||||||
|
hover: {
|
||||||
|
enabled: true,
|
||||||
|
lineColor: 'rgb(100,100,100)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
states: {
|
||||||
|
hover: {
|
||||||
|
marker: {
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
headerFormat: '<b>{series.name}</b><br>',
|
||||||
|
pointFormat: '{point.x} min per degree, {point.y} degrees'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
series: seriesOptions,
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$.getJSON('delay.php', function (data) {
|
||||||
|
console.log("data");
|
||||||
|
seriesOptions[0] = {
|
||||||
|
name: "Heat, Heating",
|
||||||
|
data: data[0]
|
||||||
|
};
|
||||||
|
seriesOptions[1] = {
|
||||||
|
name: "Heat, down",
|
||||||
|
data: data[1]
|
||||||
|
};
|
||||||
|
|
||||||
|
createChart();
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- Fixed navbar -->
|
||||||
|
<nav class="navbar navbar-inverse">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<a class="navbar-brand" href="#">Stat stats</a>
|
||||||
|
</div>
|
||||||
|
<div id="navbar" class="navbar-collapse collapse">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li><a href="index.html">Home</a></li>
|
||||||
|
<li><a href="graph.html">Graph</a></li>
|
||||||
|
<li class="active"><a href="delay.html">Delay</a></li>
|
||||||
|
</ul>
|
||||||
|
</div><!--/.nav-collapse -->
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div id="container" style="min-width: 310px; height: 400px; max-width: 800px; margin: 0 auto"></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body></html>
|
||||||
82
delay.php
Normal file
82
delay.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
include('settings/globals.php');
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
|
||||||
|
// Check connection
|
||||||
|
if (!$conn) {
|
||||||
|
die("Connection failed: " . mysqli_connect_error());
|
||||||
|
}
|
||||||
|
$sql = 'SELECT UNIX_TIMESTAMP(date),dispTemperature,weatherTemperature,heatSetPoint,systemSwitchPosition from stat';
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
printf("Errormessage: %s\n", $conn->error);
|
||||||
|
}
|
||||||
|
$rows = array();
|
||||||
|
while($r = mysqli_fetch_assoc($result)) {
|
||||||
|
$r['date'] = $r['UNIX_TIMESTAMP(date)'];
|
||||||
|
unset($r['UNIX_TIMESTAMP(date)']);
|
||||||
|
$rows[] = $r;
|
||||||
|
}
|
||||||
|
// print("<pre>");
|
||||||
|
// print_r($rows);
|
||||||
|
$startTime = -1;
|
||||||
|
$startTemp = NULL;
|
||||||
|
$startSetPoint = NULL;
|
||||||
|
$targetSetPoint = NULL;
|
||||||
|
|
||||||
|
$heat_up = NULL;
|
||||||
|
$heat_down = NULL;
|
||||||
|
$cool_up = NULL;
|
||||||
|
$cool_down = NULL;
|
||||||
|
$type = NULL;
|
||||||
|
|
||||||
|
for($i = 1; $i < count($rows); $i++){
|
||||||
|
$now = $rows[$i];
|
||||||
|
$last= $rows[$i-1];
|
||||||
|
// echo $startTime;
|
||||||
|
// print_r($now);
|
||||||
|
if($startTime == -1){
|
||||||
|
// echo "no start <br/>";
|
||||||
|
if($now['heatSetPoint'] <> $last['heatSetPoint']){
|
||||||
|
//Down!
|
||||||
|
// echo "down<br/>";
|
||||||
|
$startTime = $now['date'];
|
||||||
|
$startTemp = $now['dispTemperature'];
|
||||||
|
$startSetPoint = $last['heatSetPoint'];
|
||||||
|
$targetSetPoint = $now['heatSetPoint'];
|
||||||
|
if($now['heatSetPoint'] > $last['heatSetPoint']){
|
||||||
|
$type = "up";
|
||||||
|
} else {
|
||||||
|
$type = "down";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else{
|
||||||
|
//looking for end
|
||||||
|
// echo "yes start <br/>";
|
||||||
|
if($now['dispTemperature'] == $targetSetPoint || $now['heatSetPoint'] <> $targetSetPoint){
|
||||||
|
$changeTime = ($now['date']-$startTime)/60;
|
||||||
|
$changeTemp = abs($startTemp - $now['dispTemperature']);
|
||||||
|
$outside = $now['weatherTemperature'];
|
||||||
|
$minperdeg = $changeTime/$changeTemp;
|
||||||
|
|
||||||
|
if($type == "up"){
|
||||||
|
$heat_up[] = [$minperdeg,intval($outside)];
|
||||||
|
} else{
|
||||||
|
$heat_down[] = [$minperdeg,intval($outside)];
|
||||||
|
}
|
||||||
|
|
||||||
|
$startTime = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = [$heat_up, $heat_down];
|
||||||
|
|
||||||
|
print json_encode($return);
|
||||||
|
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
?>
|
||||||
104
graph.html
Normal file
104
graph.html
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Stat tracker</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.5.0/bootstrap-table.min.css">
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||||
|
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||||
|
<script src="http://code.highcharts.com/stock/highstock.js"></script>
|
||||||
|
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
Highcharts.setOptions({
|
||||||
|
global: {
|
||||||
|
timezoneOffset: 5 * 60
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var names = ['inside','outside','set_heat','set_cool','humidity'];
|
||||||
|
seriesOptions = [],
|
||||||
|
seriesCounter = 0,
|
||||||
|
createChart = function () {
|
||||||
|
|
||||||
|
$('#container').highcharts('StockChart', {
|
||||||
|
|
||||||
|
rangeSelector: {
|
||||||
|
selected: 4
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
yAxis: {
|
||||||
|
title: {
|
||||||
|
text: 'Temperature <20>'
|
||||||
|
},
|
||||||
|
labels: {
|
||||||
|
formatter: function () {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plotLines: [{
|
||||||
|
value: 0,
|
||||||
|
width: 2,
|
||||||
|
color: 'silver'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tooltip: {
|
||||||
|
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b><br/>',
|
||||||
|
valueDecimals: 0
|
||||||
|
},
|
||||||
|
|
||||||
|
series: seriesOptions,
|
||||||
|
legend: {
|
||||||
|
enabled: true,
|
||||||
|
borderWidth: 1,
|
||||||
|
backgroundColor: '#FFFFFF',
|
||||||
|
shadow: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$.each(names, function (i, name) {
|
||||||
|
$.getJSON('db-get.php?q='+name, function (data) {
|
||||||
|
|
||||||
|
seriesOptions[i] = {
|
||||||
|
name: name,
|
||||||
|
data: data
|
||||||
|
};
|
||||||
|
seriesCounter += 1;
|
||||||
|
|
||||||
|
if (seriesCounter === names.length) {
|
||||||
|
createChart();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- Fixed navbar -->
|
||||||
|
<nav class="navbar navbar-inverse">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<a class="navbar-brand" href="#">Stat stats</a>
|
||||||
|
</div>
|
||||||
|
<div id="navbar" class="navbar-collapse collapse">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li><a href="index.html">Home</a></li>
|
||||||
|
<li class="active"><a href="graph.html">Graph</a></li>
|
||||||
|
<li><a href="delay.html">Delay</a></li>
|
||||||
|
</ul>
|
||||||
|
</div><!--/.nav-collapse -->
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div id="container" style="height: 400px; min-width: 310px"></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
50
index.html
Normal file
50
index.html
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||||
|
<title>Stat stat</title>
|
||||||
|
|
||||||
|
<!-- Bootstrap -->
|
||||||
|
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||||
|
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||||
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- Fixed navbar -->
|
||||||
|
<nav class="navbar navbar-inverse">
|
||||||
|
<div class="container">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<a class="navbar-brand" href="#">Stat stat</a>
|
||||||
|
</div>
|
||||||
|
<div id="navbar" class="navbar-collapse collapse">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="active"><a href="index.htmll=">Home</a></li>
|
||||||
|
<li><a href="graph.html">Graph</a></li>
|
||||||
|
<li><a href="delay.html">Delay</a></li>
|
||||||
|
</ul>
|
||||||
|
</div><!--/.nav-collapse -->
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container" role="main">
|
||||||
|
<h1>Honeywell Thermostat tracker</h1>
|
||||||
|
|
||||||
|
<a href="graph.html"><button type="button" class="btn btn-lg btn-default">Graph</button></a>
|
||||||
|
<a href="delay.html"><button type="button" class="btn btn-lg btn-default">Delay</button></a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
|
||||||
|
<!-- Include all compiled plugins (below), or include individual files as needed -->
|
||||||
|
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
||||||
require_once('settings.php');
|
require_once('settings/logininfo.php');
|
||||||
|
|
||||||
function get_session(){
|
function get_session(){
|
||||||
$url = "https://mytotalconnectcomfort.com/portal";
|
$url = "https://mytotalconnectcomfort.com/portal";
|
||||||
@@ -52,6 +52,9 @@ function get_session(){
|
|||||||
// print "<pre>Sent headers: <br />";
|
// print "<pre>Sent headers: <br />";
|
||||||
// var_dump($sentHeaders);
|
// var_dump($sentHeaders);
|
||||||
// print "</pre><br />";
|
// print "</pre><br />";
|
||||||
|
|
||||||
|
// $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
// echo $code;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +120,7 @@ function login($usr, $pwd){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getStatus($device){
|
function getStatus($device){
|
||||||
print "<hr><br>Get Status<br><br><pre>";
|
// print "<hr><br>Get Status<br><br><pre>";
|
||||||
|
|
||||||
$time = round(microtime(true) * 1000);
|
$time = round(microtime(true) * 1000);
|
||||||
$url = "https://mytotalconnectcomfort.com/portal/Device/Control/".$device;
|
$url = "https://mytotalconnectcomfort.com/portal/Device/Control/".$device;
|
||||||
@@ -190,9 +193,42 @@ function cleanCookies(){
|
|||||||
file_put_contents($cookie_file_path,$file_contents);
|
file_put_contents($cookie_file_path,$file_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_session();
|
function add_data($data){
|
||||||
//login($username, $password);
|
include('globals.php');
|
||||||
//$data = getStatus($device_number);
|
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
|
||||||
|
// Check connection
|
||||||
|
if (!$conn) {
|
||||||
|
die("Connection failed: " . mysqli_connect_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
$good_columns = array("coolLowerSetpLimit","coolNextPeriod","coolSetpoint","coolUpperSetptLimit","deviceID","dispTemperature","displayedUnits","heatLowerSetptLimit","heatNextPeriod","heatSetpoint","heatUpperSetptLimit","isInVacationHoldMode","schedCoolSp","schedHeatSp","scheduleCapable","statusCool","statusHeat","systemSwitchPosition","weatherHumidity","weatherPhrase","weatherTemperature");
|
||||||
|
|
||||||
|
$clean_data = array();
|
||||||
|
foreach($good_columns as $col){
|
||||||
|
$clean_data[$col] = $data[$col];
|
||||||
|
}
|
||||||
|
//$clean_data['weatherPhrase'] = $conn->real_escape_string($clean_data['weatherPhrase']);
|
||||||
|
$columns = implode(", ",array_keys($clean_data));
|
||||||
|
$values = implode(", ", array_values($clean_data));
|
||||||
|
|
||||||
|
$sql = "INSERT INTO `stat`(".$columns.") VALUES (".$values.")";
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
echo $sql;
|
||||||
|
echo "\n";
|
||||||
|
echo $result;
|
||||||
|
if (!$result) {
|
||||||
|
printf("Errormessage: %s\n", $conn->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
}
|
||||||
|
//get_session();
|
||||||
|
login($username, $password);
|
||||||
|
$data = getStatus($device_number);
|
||||||
|
|
||||||
|
add_data($data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
6
settings/globals.php.example
Normal file
6
settings/globals.php.example
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
define('DB_HOST','');
|
||||||
|
define('DB_NAME', '');
|
||||||
|
define('DB_USER', '');
|
||||||
|
define('DB_PASSWORD', '');
|
||||||
|
?>
|
||||||
6
settings/logininfo.php.example
Normal file
6
settings/logininfo.php.example
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
//Total Connect info
|
||||||
|
$username="";
|
||||||
|
$password="";
|
||||||
|
$device_number = "";
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user