Skip to content

Commit

Permalink
#14
Browse files Browse the repository at this point in the history
V5.0
  • Loading branch information
oddwires committed Oct 11, 2017
1 parent 8af531d commit 5891541
Show file tree
Hide file tree
Showing 236 changed files with 3,577 additions and 27,150 deletions.
59 changes: 59 additions & 0 deletions AccessPageAjaxCall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php include("readvars.php"); ?> <!-- common code to read variables from file STATUS.TXT -->

<div data-role="header" data-position="fixed" data-fullscreen="true" data-tap-toggle="false">
<table style="width:98%;" border="0" align="center"><tr>
<td style="width: 25%"><a href="#sidePanel" class="menuButton"data-role="button" data-icon="bars">Menu</a></td>
<td style="width: 35%"><h1 class="titleLabel ui-title" id="accessTitle">Access</h1></td>
<td style="width: 40%; text-align: right;">
<a href="#" data-role="button" data-icon="search" class="searchButton" data-iconpos="notext" style="font-size: 19px;">!</a>
<a href="#" data-role="button" data-icon="plus" class="AddDel_Button" id="accessButton">Add</a></td></tr>
</table>
</div>
<input class="lineCount" type="hidden" value="<?php echo $USRNum; ?>">

<p data-role="screenSpacer"><br></p> <!-- stop first item from getting stuck behind the header -->
<!-- Make all task configuration data available on the page just in case we want to drill down and start editing -->
<!-- Note added a spare entry at the end in case we want to create a new alarm zone -->

<ul data-role="listview" data-inset="true" id="accessList" style="padding: 0em; background-color:#D4CBAC; border-style: none; margin: 5px;">
<?php for($i=0; $i<$USRNum; $i++) { ?>
<li class="editable" id="account_<?php echo $i; ?>">
<a href="#" class="ui-btn ui-shadow ui-corner-all ui-icon-plus ui-btn-icon-right" style="border-radius: 6px;"><?php echo $user[$i][1]; ?></a>
<!-- Make all user data available on the page just in case we want to drill down and start editing -->
<input type="hidden" id="AccountName_<?php echo $i; ?>" value="<?php echo $user[$i][1]; ?>"></li>
<input type="hidden" id="AccountEmail_<?php echo $i; ?>" value="<?php echo $user[$i][2]; ?>"></li>
<?php } ?>
<!-- Extra line added for when creating a new alarm zone. -->
<li class="editable" style="display:none;" id="account_<?php echo $USRNum; ?>"
<a href="#" class="ui-btn ui-shadow ui-corner-all ui-icon-plus ui-btn-icon-right" style="border-radius: 6px;"><?php echo $user[$i][1]; ?>New logon</a>
<!-- Make all user data available on the page just in case we want to drill down and start editing -->
<input type="hidden" id="AccountName_<?php echo $i; ?>" value="New logon"></li>
<input type="hidden" id="AccountEmail_<?php echo $i; ?>" value=""></li>
<!-- End of extra line -->
<!-- Editor screen. This bit gets around a bit, and will be tagged onto the end of any selected power switch lines -->
<li style="display: none; background-color: #D4CBAC" id="accessEditor";>
<table style="width: 100%" border="0">
<tr><th>Name:</td><td><input data-wrapper-class="address" type="text" id="AccountName" ></td></tr>
<tr><th>Email:</td><td><input data-wrapper-class="address" type="text" id="AccountEmail" placeholder="SomeEmail@SomeAddress.com" ></td></tr>
<tr><th>Password:</td><td>
<a href="#PwordPopup" data-rel="popup" class="ui-btn ui-btn-inline ui-mini ui-corner-all" data-transition="slideup" data-position-to="body">Set</a>
</td></tr>
</table>
</li>
<!-- End of editor -->
</ul>
<!-- put some blank space at the end of the list. Gives CronEditor some room to work in for the last items in the list view. -->
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>

<div data-role="popup" id="PwordPopup" class="ui-content" data-overlay-theme="b">
<form>
<div style="padding: 10px 20px;">
<h3 style ="margin-top: 0px;">Enter a new password</h3>
<input type="password" id="Pword1" placeholder="New password:"/>
<input type="password" id="Pword2" placeholder="Confirm password:"/>
<input type="hidden" id="AccountNum"/>
<a href="#home" id="PopUpBtn2" class="whiteButton" data-role="button" onclick="PwordCheck();">Save</a>
</div>
</form>
</div>
22 changes: 11 additions & 11 deletions ConfigFiles/Generic_ContactSensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ var DOOR = {
var err = null; // in case there were any problems
fs.readFile("/var/www/data/status.txt", 'utf8', function(err, data) {
if(err) { return console.log(err); }
var lines = data.split('\n');
var lines = data.split('\n');
for(var i = 0; i < lines.length; i++){
if ((lines[i].indexOf("zcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) {
if ((lines[i].indexOf("zcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) {
var svalues = lines[i].split(':');
if (svalues[8].toString().trim() === '0') {
if(this.outputLogs) console.log('Parm1 open')
DOOR.open = true;
if (svalues[8].toString().trim() === '0') {
if(this.outputLogs) console.log('Parm1 open')
DOOR.open = true;
} else {
if(this.outputLogs) console.log('Parm1 closed')
DOOR.open = false;
if(this.outputLogs) console.log('Parm1 closed')
DOOR.open = false;
}
}
}
});
}
}
});
},
identify: function() {
console.log("Identify the Parm1");
Expand Down Expand Up @@ -71,7 +71,7 @@ door
});

setInterval(function() {
DOOR .read()
DOOR .read()

// update the characteristic value so interested iOS devices can get notified
door
Expand Down
42 changes: 21 additions & 21 deletions ConfigFiles/Generic_Fan.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ var GENERIC_Fan01 = {
powerOn: false,
setPowerOn: function(on) {
console.log("Turning the Parm1 fan %s", on ? "on" : "off");
if (on) {
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) {
if (on) {
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) {
if(err) { return console.log(err); }
console.log("Parm1 fan on Success");
});
} else {
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) {
} else {
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) {
if(err) { return console.log(err); }
console.log("Parm1 fan off Success");
});
}
});
}
},
}

Expand Down Expand Up @@ -73,22 +73,22 @@ fan01
if(err) { return console.log(err); }
var lines = data.split('\n');
for(var i = 0; i < lines.length; i++){
if ((lines[i].indexOf("rcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) {
// falls through here when we have found the line for this device in the status file
// console.log(lines[i]);
var values = lines[i].split(':');
// read the actual status of the accessory from the file
console.log(values[5]);
if (values[5].indexOf("on") !=-1) {
console.log("Current status: on");
GENERIC_Fan01.powerOn = true;
callback(err, true);
if ((lines[i].indexOf("rcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) {
// falls through here when we have found the line for this device in the status file
// console.log(lines[i]);
var values = lines[i].split(':');
// read the actual status of the accessory from the file
console.log(values[5]);
if (values[5].indexOf("on") !=-1) {
console.log("Current status: on");
GENERIC_Fan01.powerOn = true;
callback(err, true);
} else {
console.log("Current status: off");
GENERIC_Fan01.powerOn = false;
callback(err, false);
console.log("Current status: off");
GENERIC_Fan01.powerOn = false;
callback(err, false);
}
}
}
}
}
});
});
44 changes: 22 additions & 22 deletions ConfigFiles/Generic_Light.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ var GENERIC_LIGHT01 = {
powerOn: false,
setPowerOn: function(on) {
console.log("Turning the Parm1 light %s", on ? "on" : "off");
if (on) {
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) {
if(err) { return console.log(err); }
if (on) {
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) {
if(err) { return console.log(err); }
console.log("Parm1 light on Success");
});
} else {
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) {
} else {
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) {
if(err) { return console.log(err); }
console.log("Parm1 light off Success");
});
}
});
}
},
}

Expand Down Expand Up @@ -73,22 +73,22 @@ light01
if(err) { return console.log(err); }
var lines = data.split('\n');
for(var i = 0; i < lines.length; i++){
if ((lines[i].indexOf("rcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) {
// falls through here when we have found the line for this device in the status file
// console.log(lines[i]);
var values = lines[i].split(':');
// read the actual status of the accessory from the file
console.log(values[5]);
if (values[5].indexOf("on") !=-1) {
console.log("Current status: on");
GENERIC_LIGHT01.powerOn = true;
callback(err, true);
if ((lines[i].indexOf("rcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) {
// falls through here when we have found the line for this device in the status file
// console.log(lines[i]);
var values = lines[i].split(':');
// read the actual status of the accessory from the file
console.log(values[5]);
if (values[5].indexOf("on") !=-1) {
console.log("Current status: on");
GENERIC_LIGHT01.powerOn = true;
callback(err, true);
} else {
console.log("Current status: off");
GENERIC_LIGHT01.powerOn = false;
callback(err, false);
console.log("Current status: off");
GENERIC_LIGHT01.powerOn = false;
callback(err, false);
}
}
}
}
}
});
});
42 changes: 21 additions & 21 deletions ConfigFiles/Generic_Outlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ var GENERIC_OUTLET01 = {
powerOn: false,
setPowerOn: function(on) {
console.log("Turning the Parm1 outlet %s", on ? "on" : "off");
if (on) {
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) {
if (on) {
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) {
if(err) { return console.log(err); }
console.log("Parm1 outlet on Success");
});
} else {
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) {
} else {
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) {
if(err) { return console.log(err); }
console.log("Parm1 outlet off Success");
});
}
});
}
},
}

Expand Down Expand Up @@ -73,22 +73,22 @@ outlet01
if(err) { return console.log(err); }
var lines = data.split('\n');
for(var i = 0; i < lines.length; i++){
if ((lines[i].indexOf("rcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) {
// falls through here when we have found the line for this device in the status file
// console.log(lines[i]);
var values = lines[i].split(':');
// read the actual status of the accessory from the file
console.log(values[5]);
if (values[5].indexOf("on") !=-1) {
console.log("Current status: on");
GENERIC_OUTLET01.powerOn = true;
callback(err, true);
if ((lines[i].indexOf("rcon") !=-1) && (lines[i].indexOf("Parm1") !=-1)) {
// falls through here when we have found the line for this device in the status file
// console.log(lines[i]);
var values = lines[i].split(':');
// read the actual status of the accessory from the file
console.log(values[5]);
if (values[5].indexOf("on") !=-1) {
console.log("Current status: on");
GENERIC_OUTLET01.powerOn = true;
callback(err, true);
} else {
console.log("Current status: off");
GENERIC_OUTLET01.powerOn = false;
callback(err, false);
console.log("Current status: off");
GENERIC_OUTLET01.powerOn = false;
callback(err, false);
}
}
}
}
}
});
});
60 changes: 30 additions & 30 deletions ConfigFiles/Generic_Radiator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ var GENERIC_radiator = {
heatOn: false,
setHeatOn: function(on) {
console.log("Turning the Parm1 radiator %s", on ? "on" : "off");
if (on) {
TEMP_SENSOR.TargetHeatingCoolingState = 0;
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) {
if (on) {
TEMP_SENSOR.TargetHeatingCoolingState = 0;
fs.appendFile("/var/www/data/input.txt", "Parm3", function(err) {
if(err) { return console.log(err); }
console.log("Parm1 radiator on Success");
});
} else {
TEMP_SENSOR.TargetHeatingCoolingState = 1;
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) {
} else {
TEMP_SENSOR.TargetHeatingCoolingState = 1;
fs.appendFile("/var/www/data/input.txt", "Parm4", function(err) {
if(err) { return console.log(err); }
console.log("Parm1 radiator off Success");
});
}
});
}
},
}

Expand All @@ -53,24 +53,24 @@ var TEMP_SENSOR = {
TEMP_SENSOR.currentTemperature = Math.round((15 + Math.random() * 10));
},
incTemperature: function() {
if (TEMP_SENSOR.currentTemperature >= 25) { step = -1; }
if (TEMP_SENSOR.currentTemperature <= 20) { step = 1; }
if (TEMP_SENSOR.currentTemperature >= 25) { step = -1; }
if (TEMP_SENSOR.currentTemperature <= 20) { step = 1; }
// if (TEMP_SENSOR.targetTemperature > TEMP_SENSOR.currentTemperature)
if (TEMP_SENSOR.currentTemperature > 23)
{ TEMP_SENSOR.TargetHeatingCoolingState = 1;
{ TEMP_SENSOR.TargetHeatingCoolingState = 1;
// console.log("Greater than 23.");
}
else
{ TEMP_SENSOR.TargetHeatingCoolingState = 0;
}
else
{ TEMP_SENSOR.TargetHeatingCoolingState = 0;
// console.log("Less than 23.");
}
// if (TEMP_SENSOR.currentTemperature >= 23 ) {
// GENERIC_radiator.setHeatOn(false);
// } else {
// GENERIC_radiator.setHeatOn(true);
// }
// console.log(step);
// if (TEMP_SENSOR.currentTemperature >= 23 ) {
// GENERIC_radiator.setHeatOn(false);
// } else {
// GENERIC_radiator.setHeatOn(true);
// }
// console.log(step);
TEMP_SENSOR.currentTemperature = TEMP_SENSOR.currentTemperature + step;
}
}
Expand Down Expand Up @@ -98,27 +98,27 @@ sensor

sensor
.getService(Service.Thermostat)
.getCharacteristic(Characteristic.TargetHeatingCoolingState)
.getCharacteristic(Characteristic.TargetHeatingCoolingState)
.setProps({
// validValues: [0, 1, 2, 3] // Off, Heat, Cool & Auto
validValues: [0, 1, 3] // Off, Heat & Auto
})
})
.on('set', function(value, callback) {
GENERIC_radiator.setHeatOn(value);
callback();
});

sensor
.getService(Service.Thermostat)
.getCharacteristic(Characteristic.TargetTemperature)
.setProps({
maxValue: 25,
minValue: 0 // can't seem to bring value up, will only go down :(
.getCharacteristic(Characteristic.TargetTemperature)
.setProps({
maxValue: 25,
minValue: 0 // can't seem to bring value up, will only go down :(
})
.on('set', function(value, callback) {
console.log("Parm1 radiator target temp:",value);
callback();
});
console.log("Parm1 radiator target temp:",value);
callback();
});


// cycle the temperature reading
Expand Down
Loading

0 comments on commit 5891541

Please sign in to comment.