Skip to content

Commit

Permalink
Add basic (and insecure) web interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Franske committed Nov 14, 2014
1 parent c8a7ac1 commit f4757a9
Show file tree
Hide file tree
Showing 4 changed files with 387 additions and 0 deletions.
55 changes: 55 additions & 0 deletions www/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
if(isset($_POST['submit']))
{
if(isset($_POST['sysmode']))
{
$new_sysmode = $_POST['sysmode'];
exec('/home/homecontrol/pyStat/setStat.py -m '.$new_sysmode, $output);
}
if(isset($_POST['setpoint']))
{
$new_setpoint = $_POST['setpoint'];
exec('/home/homecontrol/pyStat/setStat.py -t '.$new_setpoint, $output);
}
if(isset($_POST['fanmode']))
{
$new_fanmode = $_POST['fanmode'];
exec('/home/homecontrol/pyStat/setStat.py -f '.$new_fanmode, $output);
}
if(isset($_POST['schedmode']))
{
$new_schedmode = $_POST['schedmode'];
exec('/home/homecontrol/pyStat/setStat.py -s '.$new_schedmode, $output);
}
}
exec('/home/homecontrol/pyStat/getStat.py -b 2>&1', $output);
preg_match('/Temperature: (?P<value>\d+)/',$output[0],$matches);
$data['temp']=$matches['value'];
preg_match('/Set Point: (?P<value>\d+)/',$output[1],$matches);
$data['setpoint']=$matches['value'];
preg_match('/Mode: (?P<value>\w+)/',$output[2],$matches);
$data['mode']=$matches['value'];
preg_match('/Fan Mode: (?P<value>\w+)/',$output[3],$matches);
$data['fanmode']=$matches['value'];
preg_match('/Schedule Mode: (?P<value>\w+)/',$output[4],$matches);
$data['schedmode']=$matches['value'];
?>
<html>
<head>
<title>Thermostat Information</title>
</head>
<body>
<h1>Temperature: <?php echo $data['temp']; ?></h1>
<h1>Set Point: <?php echo $data['setpoint']; ?></h1>
<h1>Mode: <?php echo $data['mode']; ?></h1>
<h1>Fan Mode: <?php echo $data['fanmode']; ?></h1>
<h1>Schedule Mode: <?php echo $data['schedmode']; ?></h1>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
New Set Point: <input type="text" name="setpoint"><br>
New System Mode: <input type="radio" name="sysmode" value="off"> Off <input type="radio" name="sysmode" value="heat"> Heat <input type="radio" name="sysmode" value="cool"> Cool<br>
New Fan Mode: <input type="radio" name="fanmode" value="on"> On <input type="radio" name="fanmode" value="auto"> Auto<br>
New Schedule Mode: <input type="radio" name="schedmode" value="run"> Run <input type="radio" name="schedmode" value="hold"> Hold<br>
<input type="submit" name="submit" value="Submit Form"><br>
</form>
</body>
</html>
34 changes: 34 additions & 0 deletions www/jquery.serialize-object.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* jQuery serializeObject
* @copyright 2014, macek <[email protected]>
* @link https://github.com/macek/jquery-serialize-object
* @license BSD
* @version 2.4.3
Copyright (c) 2014, Paul Macek
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* The names of its contributors will not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
!function(e,r){if("function"==typeof define&&define.amd)define(["exports","jquery"],function(e,i){return r(e,i)});else if("undefined"!=typeof exports){var i=require("jquery");r(exports,i)}else r(e,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,r){function i(e,i){function n(e,r,i){return e[r]=i,e}function a(e,r){for(var i,a=e.match(t.key);void 0!==(i=a.pop());)if(t.push.test(i)){var o=s(e.replace(/\[\]$/,""));r=n([],o,r)}else t.fixed.test(i)?r=n([],i,r):t.named.test(i)&&(r=n({},i,r));return r}function s(e){return void 0===h[e]&&(h[e]=0),h[e]++}function o(e){switch(r('[name="'+e.name+'"]',i).attr("type")){case"checkbox":return"on"===e.value?!0:e.value;default:return e.value}}function u(r){if(!t.validate.test(r.name))return this;var i=a(r.name,o(r));return c=e.extend(!0,c,i),this}function f(r){if(!e.isArray(r))throw new Error("formSerializer.addPairs expects an Array");for(var i=0,t=r.length;t>i;i++)this.addPair(r[i]);return this}function d(){return c}function l(){return JSON.stringify(d())}var c={},h={};this.addPair=u,this.addPairs=f,this.serialize=d,this.serializeJSON=l}var t={validate:/^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,key:/[a-z0-9_]+|(?=\[\])/gi,push:/^$/,fixed:/^\d+$/,named:/^[a-z0-9_]+$/i};return i.patterns=t,i.serializeObject=function(){return this.length>1?new Error("jquery-serialize-object can only serialize one form at a time"):new i(r,this).addPairs(this.serializeArray()).serialize()},i.serializeJSON=function(){return this.length>1?new Error("jquery-serialize-object can only serialize one form at a time"):new i(r,this).addPairs(this.serializeArray()).serializeJSON()},"undefined"!=typeof r.fn&&(r.fn.serializeObject=i.serializeObject,r.fn.serializeJSON=i.serializeJSON),e.FormSerializer=i,i});
Loading

0 comments on commit f4757a9

Please sign in to comment.