From 5882aee3da5fd3546c88ee6939fdd52e1783d1dc Mon Sep 17 00:00:00 2001 From: Brett Napier Date: Thu, 16 Nov 2017 22:39:02 -0500 Subject: [PATCH] add web GUI with Bootstrap to control some functions of the thermostat --- index.html | 117 +++++++++++++++++++++++++++++++++++--------------- thermostat.js | 73 +++++++++++++++++++++++++++---- 2 files changed, 148 insertions(+), 42 deletions(-) diff --git a/index.html b/index.html index 19ff448..74f7625 100644 --- a/index.html +++ b/index.html @@ -1,59 +1,108 @@ - - + + + + -

Dashboard

- -
- Temp -
-
+ +
+
+

Temperature

+
+
24%
- -
-

Mode:

-
- Heat
- Off
- AC -
+ +
+

Function:

+
+ Single
+ Dual
- -
+
+
+

Fan:

-
- Auto
- Off
-
+ Auto
+ On
- -
-

Function:

-
- Single
- Dual
-
+
+
+
+

Mode:

+ Heat
+ Off
+ AC
- - - +
+
+ + diff --git a/thermostat.js b/thermostat.js index 442c818..a1c69a6 100644 --- a/thermostat.js +++ b/thermostat.js @@ -32,13 +32,14 @@ class Thermostat { console.log("Setting up thermostat!"); let HVACType = "conventional"; // "heat pump" let mode = "single"; // "single", "dual" - let switchMode = "heat"; // "heat" or "ac" + let switchMode = "heat"; // "heat", "ac" or "off" + let indoorBlowerFan = "on"; // "on" or "auto" let currentTemperature = 69; let desiredTemperature = 72; //for dual mode - let lowTempLimit = 65; - let highTempLimit = 76; + let lowTempLimit = 69; + let highTempLimit = 72; //toleranceInterval (for energy effeciency) @@ -58,17 +59,56 @@ class Thermostat { else if(mode == "single") { if(switchMode == "ac") { if(currentTemperature > desiredTemperature) { + //heatOff acOn(); } } else if(switchMode == "heat") { if(currentTemperature < desiredTemperature) { + //acOff heatOn(); } } + else if(switchMode == "off") { + //heatOff + //acOff + } } } + //button controls + this.setModeAC = function () { + switchMode = "ac"; + logButtonChange(switchMode); + } + this.setModeHeat = function () { + switchMode = "heat"; + logButtonChange(switchMode); + } + this.setModeOff = function () { + switchMode = "off"; + logButtonChange(switchMode); + } + this.setFunctionSingle = function () { + mode = "single"; + logButtonChange(mode); + } + this.setFunctionDual = function () { + mode = "dual"; + logButtonChange(mode); + } + this.setFanOn = function () { + indoorBlowerFan = "on"; + logButtonChange(indoorBlowerFan); + } + this.setFanAuto = function () { + indoorBlowerFan = "auto"; + logButtonChange(indoorBlowerFan); + } + let logButtonChange = function(value) { + console.log("Changed to: " + value); + } + let acOn = function() { console.log("AC on"); decreaseTemperature(); @@ -136,16 +176,33 @@ app.get('/', function(req, res,next) { io.on('connection', function(client) { console.log('Client connected...'); - // client.on('fanOn', function() { - // thermostat.fanOn(); - // }) - + client.on('setModeAC', function() { + thermostat.setModeAC(); + }) + client.on('setModeHeat', function() { + thermostat.setModeHeat(); + }) + client.on('setModeOff', function() { + thermostat.setModeOff(); + }) + client.on('setFanOn', function() { + thermostat.setFanOn(); + }) + client.on('setFanAuto', function() { + thermostat.setFanAuto(); + }) + client.on('setFunctionSingle', function() { + thermostat.setFunctionSingle(); + }) + client.on('setFunctionDual', function() { + thermostat.setFunctionDual(); + }) + setInterval(function myTimer3() { client.emit('updateTemp', thermostat.getCurrentTemperature()); }, 1000); }); - server.listen(5200); // END SERVER CODE